Repository navigation
Escape quotes and quote times in QueryString.__str__ - #1447
Merged
dantownsend merged 1 commit intoOct 28, 2026
Merged
Conversation
Check constraints build their DDL from QueryString.__str__, which put a string argument between single quotes without doubling the quotes inside it and left datetime.time values unquoted. A condition such as genre != "rock'n'roll" or opens >= time(9, 0) produced DDL that PostgreSQL rejects. Double embedded quotes and quote times like dates.
Member
|
I've tested this locally, and it works well. Thanks for the fix 👍 I realised we might also have problems with |
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.
Checkconstraints get their DDL fromQueryString.__str__(viaget_condition_str), which puts a string argument between single quotes without doubling the quotes inside it, and leaves adatetime.timeunquoted because onlydatetimeanddateare handled:PostgreSQL's parser (checked with pglast / libpg_query) rejects both, so
create_table()and the migration fail. With this change they become'rock''n''roll'and'09:00:00', which parse. Strings without a quote and other types print as before; the only other visible change is thatprint(query)now shows''for a quote inside a string.Two tests are added to
tests/query/test_querystring.py; they fail on master. The non-integration tests (sqlite) andscripts/lint.shpass; the Postgres jobs need a server I didn't run.Written with AI assistance (Claude); I have reviewed the change.