refactor(postgres): represent SQL as typed text/data segments #9
Open
opened 2026-07-20 21:25:06 +02:00 by codinget
·
0 comments
Labels
Clear labels
Agentic
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Agent
Fable
Work made by a Claude Fable agent
Agent
gpt-5.6-luna
Work made by a gpt-5.6-luna agent
Agent
gpt-5.6-sol
Work made by a gpt-5.6-sol agent
Agent
gpt-5.6-terra
Work made by a gpt-5.6-terra agent
Work made by an agent
Agent
Opus
Work made by a Claude Opus agent
Agent
Sonnet
Work made by a Claude Sonnet agent
Breaking change that won't be backward compatible
Something is not working
Documentation changes
Improve existing functionality
New functionality
This is security issue
Issue or pull request related to testing
Priority
Critical
1
The priority is critical
Priority
High
2
The priority is high
Priority
Low
4
The priority is low
Priority
Medium
3
The priority is medium
Reviewed
Confirmed
1
Issue has been confirmed
Reviewed
Duplicate
2
This issue or pull request already exists
Reviewed
Invalid
3
Invalid issue
Reviewed
Won't Fix
3
This issue won't be fixed
Status
Abandoned
3
Somebody has started to work on this but abandoned work
Status
Blocked
1
Something is blocking this issue or pull request
Status
Need More Info
2
Feedback is required to reproduce issue or to continue work
Milestone
No items
No Milestone
Projects
Clear projects
No projects
Notifications
Due Date
No due date set.
Reference: codinget/abode#9
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Problem
The PostgreSQL SQL template currently renders parameters through literal
?placeholders and later rewrites every?to a numbered PostgreSQL parameter. That representation is fragile: PostgreSQL uses?,?|, and?&as real JSONB operators, and SQL text containing those operators cannot be distinguished safely from parameter placeholders.Rework the intermediate representation so SQL text and typed data remain separate until final expansion.
Proposed representation
Use a segment array along these lines:
The underscore-prefixed discriminants are reserved for the SQL builder. Template values should continue to be accepted through typed helpers rather than allowing callers to construct arbitrary underscore-prefixed properties accidentally. Preserve the currently supported value semantics, including an explicit representation for nullable values if required.
Composition and expansion
catSql/concatenation only concatenates segment arrays. It must not renumber, copy, or render parameters.SqlCodevalues splice their segments directly into the surrounding array._sqlsegments are appended verbatim.$n::type.$n::typeand does not append the value again.For example, reusing one typed data object twice should produce SQL equivalent to
$1::text || $1::textwith a one-element parameter array.Acceptance criteria
?, JSONB?,?|, and?&operators survive expansion unchanged.