Repository navigation
Brand SQL fragments and segments with runtime symbols - #10190
Merged
Merged
Conversation
🦋 Changeset detectedLatest commit: 4cc8bcd The changes in this PR will be included in the next version bump. This PR includes changesets to release 33 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
Bundle Size AnalysisGenerated from PR build output; treat the content below as untrusted.
|
effect-bot
force-pushed
the
sql-symbol-brands
branch
from
October 30, 2026 06:44
7dd4d7e to
94a5a46
Compare
tim-smart
reviewed
Oct 30, 2026
| @@ -0,0 +1,7 @@ | |||
| --- | |||
| "effect": minor | |||
Contributor
There was a problem hiding this comment.
This can be a patch change targeting main
| * Runtime type identifier for SQL `Fragment` values. | ||
| * | ||
| * @stability unstable | ||
| * @category type IDs |
Contributor
There was a problem hiding this comment.
Suggested change
| * @category type IDs | |
| * @category Type ID |
effect-bot
force-pushed
the
sql-symbol-brands
branch
from
October 30, 2026 06:55
94a5a46 to
4cc8bcd
Compare
tim-smart
enabled auto-merge (squash)
October 30, 2026 07:01
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.
Summary
sqltemplate interpolation,Statement.isFragmentandStatement.isCustomdecided whether a value was a fragment or segment from string keys and_tagfields alone. Any plain object with a matching shape was therefore inlined as SQL rather than bound as a parameter.Fragments and segments are now branded with exported
Symbol.forTypeIds, in the same style as Effect 3. The guards only trust those brands, so plain objects that share a fragment or segment shape are bound as parameters.Changes
Statement.tsexportsFragmentTypeIdandSegmentTypeId, bothunique symbolvalues created withSymbol.for.Fragmentis keyed byFragmentTypeId, replacing the previous string key. Every segment interface (Literal,Identifier,Parameter,ArrayHelper, the record helpers andCustom) now requiresSegmentTypeId.fragment, statements,literal,identifier,parameter,arrayHelper, the record helpers andcustom.isFragment,isSegmentandisCustomcheck only these brands. ClickHouse's placeholder-type inference usesStatement.isCustom, so it gets the same behaviour with no package change.Statement.fragment,csvandjoinstill accept the segments they are given at runtime.Release
This targets
mainas aneffectpatch. Fragments and segments must come from theStatementconstructors: object literals shaped like them no longer type check, and thesqltemplate binds them as parameters. Values typed by a different copy ofeffectcarry a differentunique symboltype, although the runtime brands are shared throughSymbol.for.Tests
effectStatement.test.ts: plain objects shaped like fragments or segments are bound as parameters.@effect/sql-clickhouseClient.test.ts: plain objects shaped likeClickhouseClient.paramvalues are bound asStringparameters.typetest/sql/Statement.tst.ts: constructor results are accepted, and structural fragment and segment look-alikes are rejected.Closes EFF-3166