Repository navigation
feat(experimental)!: expand only an object marked with expand - #135
Merged
Merged
Conversation
…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 Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
expand
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
stringifyObjectsis no longer an option.formatandescapewrite an object not marked withexpand()as a quoted string, asstringifyObjects: truedid, andformatthrows for one in aSETorON DUPLICATE KEY UPDATElist, pointing toexpand(). PassingstringifyObjectsthrows aTypeErrorthat names what replaces it and links to the migration guide.unsafe: { expandObjects: true }keeps the expansion a false or missingstringifyObjectsgave:formatexpands an unmarked object insideSETand writes text elsewhere, andescapeexpands 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, asexpand(value)did.columnsis 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]'.