Repository navigation
fix: read a cast after a SELECT modifier or in parentheses #1760
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+225
−17
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
4df30c7
fix: read a cast after a SELECT modifier or in parentheses
ralphstodomingo 36bd06a
test: keep the DISTINCT ON cases to Postgres
ralphstodomingo 946651c
fix: count parenthesis depth by UTF-16 index
ralphstodomingo f6183a0
fix: a qualified column named end or null keeps its name
ralphstodomingo 945b54c
fix: a decimal literal under a cast is not a column
ralphstodomingo e1cfcee
fix: find AS in a cast beside a quoted name
ralphstodomingo 4bac89e
refactor: read casts with a small tokenizer instead of regex slices
ralphstodomingo 4c8e0ee
fix: a type modifier may be a name, and a quote unescapes only itself
ralphstodomingo 4612013
docs: the cast grammar names a type modifier as a number or a name
ralphstodomingo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor (Codex; lead reproduced). A Postgres escape string with
\'can shift the SELECT items, so a real cast gets another column's name. This doesn't block: it needs constructed input, and main already does the same with the plain form.Repro on Postgres (
f = select 1 as id, 2 as b, 3 as c):stripSqlends the literal at\', soselectItemsreturnsid,E''s,(b)::int,example', … The engine's realc::intedge (_col_2) is then read against the fake item(b)::int.columnAnswer(f, c)givesf.c → r.b → child.b, with nothing inmay_carry. Base:r._col_2, withchildinmay_carry.E'it\'s, b::int, example', c::int, …, which also givesr.b, child.bat bdd275f. So the cause is older than this PR. The new parenthesised operand only widens it.Why it isn't a block: the string has to be an
E'…'literal with a backslash-escaped quote, and its text has to contain a comma and then a cast of a column. That is constructed SQL, not something ordinary models write. Codex agrees it is minor.A fix I checked locally, fine for a follow-up: in
stripSql, add(?<![\w$])[eE]'(?:[^'\\]|\\[\s\S]|'')*'before the plain'…'alternative, and empty it to''like the others. With it, the repro givesf.c → r.c → child.c(the plain form too), andcolumn-answer.test.tspasses 84/84.