Fix SQL emitted for compound queries - #5
Merged
Conversation
Previously SQL like "... = $2LIMIT $3", was emitted, resulting in an error like: > trailing junk after parameter at or near "$2LIMIT" (PQ::PQError)
The & combinator used the wrong keyword, resulting in an error like: > syntax error at or near "INTERSECTION" (PQ::PQError)
jgaskins
approved these changes
Aug 16, 2026
|
|
||
| def &(other : self) : CompoundQuery | ||
| CompoundQuery.new(self, "INTERSECTION", other, connection(CONFIG.read_db)) | ||
| CompoundQuery.new(self, "INTERSECT", other, connection(CONFIG.read_db)) |
Owner
There was a problem hiding this comment.
I make this exact mistake every time I need an INTERSECT query. Well, at least I'm consistent.
I'm surprised I've never needed to do it with Interro, though.
| str << rhs | ||
| if @limit | ||
| str << "LIMIT $" << (arg_count += 1) | ||
| str << " LIMIT $" << (arg_count += 1) |
Owner
|
Thanks! |
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.
Two small fixes, each with a regression spec:
first(n)on a compound query emitted no space beforeLIMIT.&combinator emittedINTERSECTION, which isn't a SQL keyword.Both specs fail on master and pass with the fixes.