Repository navigation
feat: support named :name query placeholders - #55
Merged
Merged
Conversation
A query may write :name placeholders instead of $N. Each distinct name is one parameter numbered by first occurrence and names its method parameter; every occurrence compiles to a JDBC ? bound in textual order. Mixed $N and :name, qualified, quoted, and &name placeholders anywhere in the statement, unanalyzed locations, and conflicting types are rejected with the placeholder as written. Queries using only $N are unchanged.
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
Queries can now write
:nameplaceholders instead of$N, so parameters read as their meaning and the generated method parameters carry the names the query author chose. Each named placeholder compiles to a JDBC?and is analyzed wherever an indexed placeholder is.Changes
:name(a colon directly followed by an unquoted ASCII identifier, compared exactly as written) to?; placeholder text in string literals, quoted identifiers, and comments is untouched, and: nameis not a placeholder.?position in textual order.INlists,LIKE/ILIKEpatterns,BETWEENbounds,INSERTvalues,UPDATEassignments,LIMIT, andOFFSET; the method parameter is named after the placeholder, soLIMIT :pageSizegeneratespageSize.$Nand:name, a qualified (:a.b), quoted (:"x"), or&nameplaceholder anywhere in the statement, a named placeholder in an unanalyzed location, and one name used with conflicting types, with diagnostics that write the placeholder as the query spells it.Scope and non-goals
$Nplaceholders produce unchanged models, executable SQL, generated code, and diagnostics.:name::text, non-placeholderINSERT/UPDATEexpressions,= ANY, upsert,@nameor macro syntax, and:1are not supported by this change.