Skip to content

feat(experimental)!: write only raw values as SQL and quote names whole - #136

Merged
wellwelwel merged 2 commits into
nextfrom
raw-by-mark
Dec 4, 2026
Merged

wellwelwel merged 2 commits into
nextfrom
raw-by-mark

Conversation

@wellwelwel

Copy link
Copy Markdown
Member

format and escape write a value as raw SQL only when raw() created it. The mark is an own property, so JSON, a polluted prototype, or a Proxy that answers every key cannot pass for one, and no method of the value is called. Any other object with a toSqlString method is an ordinary object. unsafe: { toSqlString: true } brings back detection by method with the same output.

escapeId, ??, and the keys of expanded objects keep a dot inside the name, as the server's own client quotes a name. unsafe: { qualifiedNames: true } brings back the split on dots, and a qualified name written by the developer uses ??.?? or escapeId on each part. escape takes qualifiedNames for the keys it writes, and forbidQualified is no longer an option.

On Node, escapeId and ?? cost less without options, a raw value costs about 3 ns more, and the unsafe uses cost nothing extra in an object made by createOptions.

…hole by default

format and escape write as SQL only a value raw() created, recognized by
an own mark shared through Symbol.for, and read its SQL without calling
its methods. Any other object with a toSqlString method is written as
any other object. unsafe: { toSqlString: true }, in format, escape, and
createOptions, brings back the method with the output of 1.x.

A name given to escapeId or bound to ??, and each key of an expanded
object, objectToValues included, is quoted as one identifier, keeping a
dot inside it. unsafe: { qualifiedNames: true }, in escapeId, format,
escape, and createOptions, splits it on each dot as 1.x did.
forbidQualified is no longer an option.
@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@cb05323). 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      #136   +/-   ##
========================================
  Coverage        ?   100.00%           
========================================
  Files           ?        33           
  Lines           ?      3094           
  Branches        ?       772           
========================================
  Hits            ?      3094           
  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 marked this pull request as ready for review December 4, 2026 16:33
@wellwelwel
wellwelwel merged commit cfcea6c into next Dec 4, 2026
12 checks passed
@wellwelwel
wellwelwel deleted the raw-by-mark branch December 4, 2026 16:36
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