Repository navigation
Conversation
…quote_name quote_name() returned valid unreserved regular ASCII identifiers unquoted, which required tracking SPANNER_RESERVED_KEYWORDS. Remove the fast path so all identifiers are escaped and wrapped in backticks, and update the unit and mockserver SQL expectations accordingly. Fixes googleapis#19072
Contributor
There was a problem hiding this comment.
Code Review
This pull request simplifies the identifier quoting logic in django_spanner/operations.py by unconditionally escaping and wrapping all table, index, and column names in backticks. This change removes the need for tracking Spanner's reserved keywords and regular identifiers, leading to the removal of SPANNER_RESERVED_KEYWORDS and _REGULAR_IDENTIFIER_RE. Consequently, numerous test cases across the test suite have been updated to expect backticks around identifiers in the generated SQL. No review comments were provided, and I have no additional feedback to offer as the changes are clean and consistent.
Author
|
@olavloite could you please look into this, when your free? |
This branch has not been deployed
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
DatabaseOperations.quote_name()in django-google-spanner returned valid unreserved regular ASCII identifiers unquoted, so the backend had to trackSPANNER_RESERVED_KEYWORDSto decide when quoting was required. This change removes that fast path so all identifiers are escaped and wrapped in backticks as a single identifier.Fixes #19072
Changes
django_spanner/operations.py: remove the_REGULAR_IDENTIFIER_RE/SPANNER_RESERVED_KEYWORDSfast path inquote_name()and the now unused import and regex. Already quoted identifiers are still returned unchanged, the empty string is still returned as is, and theRUNNING_SPANNER_BACKEND_TESTS=1character replacements still happen before quoting. The OpenTelemetrymodel_namespan attributes inschema.pyalready pass the unquotedmodel._meta.db_table(fixed in fix(django-google-spanner): use unquoted table names for OpenTelemetry model_name attributes #19096), and check constraint DDL quoting was fixed in fix(django-google-spanner): fix column check constraint DDL #19070, so no schema change is needed.THEN RETURNcolumns, and indexSTORINGcolumns).Testing
pytest tests/unit tests/mockserver_tests: 223 passed on Django 5.2 (two runs) and 223 passed on Django 6.0.quote_name()implementation (84 failures) and pass with this change.ruff formatandruff check --select I(ruff 0.14.14, as pinned in the package noxfile) are clean for the package.