Skip to content

feat(experimental)!: expand only an object marked with expand - #135

Merged
wellwelwel merged 2 commits into
nextfrom
intent-in-value
Dec 4, 2026
Merged

wellwelwel merged 2 commits into
nextfrom
intent-in-value

Conversation

@wellwelwel

@wellwelwel wellwelwel commented Dec 4, 2026 •

Copy link
Copy Markdown
Member

stringifyObjects is no longer an option. format and escape write an object not marked with expand() as a quoted string, as stringifyObjects: true did, and format throws for one in a SET or ON DUPLICATE KEY UPDATE list, pointing to expand(). Passing stringifyObjects throws a TypeError that names what replaces it and links to the migration guide.

unsafe: { expandObjects: true } keeps the expansion a false or missing stringifyObjects gave: format expands an unmarked object inside SET and writes text elsewhere, and escape expands it. It is deprecated from the start, as the bridge for callers that expand unmarked objects by default.

expand(value, { columns }) now requires the columns. unsafe: { allColumns: true } expands every own key, as expand(value) did. columns is read once while each name is checked, so only checked names are written.

Arrays are still written as lists, and an object without its own text is still '[object Object]'.

…xpansion as an unsafe use

stringifyObjects leaves the options. format and escape write an object
not marked with expand() as a quoted string, as stringifyObjects: true
wrote it, and format throws for one where a SET or ON DUPLICATE KEY
UPDATE clause expects key = value pairs. An options object that carries
stringifyObjects throws a TypeError that says what replaces it and links
to the migration guide, in createOptions too.

unsafe: { expandObjects: true } in format, escape, and createOptions
writes what a falsy stringifyObjects wrote: format expands an unmarked
object in SET and writes it as text elsewhere, and escape expands it.
It is deprecated, as a bridge until MySQL2 makes its own major version.

expand takes its columns in an options object, read as strictly as the
options of escape: expand(value, { columns }). unsafe: { allColumns: true }
expands every own key, as expand(value) did. Giving neither or both,
or the columns as the second argument, throws a TypeError.

The judge and the benchmark pass the bridge, which writes what they
wrote. MIGRATION.md maps each changed call, backed by a test.

BREAKING CHANGE: stringifyObjects throws, an unmarked object is written
as text by escape and refused in SET by format unless unsafe.expandObjects
is true, and expand requires { columns } or unsafe: { allColumns: true }.
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (next@50b0ae8). Learn more about missing BASE report.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff            @@
##             next      #135   +/-   ##
========================================
  Coverage        ?   100.00%           
========================================
  Files           ?        32           
  Lines           ?      3042           
  Branches        ?       755           
========================================
  Hits            ?      3042           
  Misses          ?         0           
  Partials        ?         0           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@wellwelwel wellwelwel changed the title feat(experimental)!: expand only an object marked with expand(), and keep the 1.x expansion as an unsafe use feat(experimental)!: expand only an object marked with expand Dec 4, 2026
@wellwelwel
wellwelwel marked this pull request as ready for review December 4, 2026 06:38
@wellwelwel
wellwelwel merged commit cb05323 into next Dec 4, 2026
12 checks passed
@wellwelwel
wellwelwel deleted the intent-in-value branch December 4, 2026 06:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants