Skip to content

refactor(sqlalchemy-spanner): clean up dead JSON operator code - #19045

Open
olavloite wants to merge 1 commit into
mainfrom
spanner-sqlalchemy-clean-up-dead-json-code
Open

olavloite wants to merge 1 commit into
mainfrom
spanner-sqlalchemy-clean-up-dead-json-code

Conversation

@olavloite

Copy link
Copy Markdown
Contributor

Historically, the Spanner dialect patched SQLAlchemy's global operator table at module import time to support single-key JSON indexing, routing compilation through an internal fallback method.

Now that the dialect implements dedicated compiler visitor methods for JSON indexing, this global monkey-patch and fallback override are no longer used.

This change:

  • Removes the mutation of SQLAlchemy's global operator dictionary at import time, preventing unintended side effects on other database dialects running in the same process.
  • Removes the obsolete compiler fallback override for JSON expressions.
  • Adds test coverage to verify that the global operator dictionary remains untouched and that JSON subscripting in filter conditions works as expected.

Historically, the Spanner dialect patched SQLAlchemy's global operator
table at module import time to support single-key JSON indexing, routing
compilation through an internal fallback method.

Now that the dialect implements dedicated compiler visitor methods for
JSON indexing, this global monkey-patch and fallback override are no longer
used.

This change:
- Removes the mutation of SQLAlchemy's global operator dictionary at import
  time, preventing unintended side effects on other database dialects running
  in the same process.
- Removes the obsolete compiler fallback override for JSON expressions.
- Adds test coverage to verify that the global operator dictionary remains
  untouched and that JSON subscripting in filter conditions works as expected.
@olavloite
olavloite requested a review from a team as a code owner November 11, 2026 14:15

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the SQLAlchemy Spanner dialect to avoid mutating the global SQLAlchemy OPERATORS table. It removes the custom _generate_generic_binary override and instead relies on standard visitor dispatching (visit_json_getitem_op_binary) for JSON indexing. Additionally, new unit and mock server tests have been added to verify JSON binary dispatch, operator table integrity, and JSON filtering behavior. I have no feedback to provide as there are no review comments.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant