fix: include schema when creating indices #637
Merged
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.
Fixes an issue where indices aren't able to be created for tables in schemas. At present,
create_index
emits SQL likewhich results in an error when creating the table:
because the name needs to be prefixed by schema.
drop_index
does emit the correct SQL with the schema prefix.This is due to an odd issue where the base class's
visit_create_index
method has in its signatureinclude_schema=False
:https://github.com/sqlalchemy/sqlalchemy/blob/299284cec65076fd4c76bf1efaae60b60f4d4f7b/lib/sqlalchemy/sql/compiler.py#L6828C23-L6828C43
but
visit_drop_index
hard-codes the value toTrue
:https://github.com/sqlalchemy/sqlalchemy/blob/299284cec65076fd4c76bf1efaae60b60f4d4f7b/lib/sqlalchemy/sql/compiler.py#L6870
The dialects handle this by hard-coding
include_schema=True
invisit_create_index
, e.g.sqlite:
https://github.com/sqlalchemy/sqlalchemy/blob/299284cec65076fd4c76bf1efaae60b60f4d4f7b/lib/sqlalchemy/dialects/sqlite/base.py#L1740
The difference in defaults is odd in the base class, but it seems like include_schema=True is the appropriate setting for Spanner.
Part of #638