Skip to content
This repository was archived by the owner on May 14, 2026. It is now read-only.

fix: Spanner auto managed indexes should not be introspected - #241

Merged
IlyaFaer merged 8 commits into
mainfrom
autogen_migrations
Sep 2, 2022
Merged

fix: Spanner auto managed indexes should not be introspected#241
IlyaFaer merged 8 commits into
mainfrom
autogen_migrations

Conversation

@IlyaFaer

Copy link
Copy Markdown

Towards #231

SQLAlchemy introspection method returns all the indexes, including those managed by Spanner internally. As any manipulations with indexes auto managed by Spanner can cause troubles, it's fair to prevent dialect from noticing these indexes. Fortunately, information_schema includes a flag, which makes it easy.

@IlyaFaerIlyaFaer added the type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. label Aug 31, 2022
@product-auto-labelproduct-auto-labelBot added the api: spanner Issues related to the googleapis/python-spanner-sqlalchemy API. label Aug 31, 2022
WHERE
i.table_name="{table_name}"
AND i.index_type != 'PRIMARY_KEY'
AND i.spanner_is_managed = FALSE

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Don't show automatic indexes ruled by Spanner under the hood

Comment threadtest/test_suite_13.py

index_names = [d["name"] for d in indexes]
exp_index_names = [d["name"] for d in expected_indexes]
assert sorted(index_names) == sorted(exp_index_names)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Overriding the test to check indexes in ordered fashion

@IlyaFaer
IlyaFaer marked this pull request as ready for review September 1, 2022 06:44
@IlyaFaer
IlyaFaer merged commit c3b5907 into mainSep 2, 2022
@IlyaFaer
IlyaFaer deleted the autogen_migrations branch September 2, 2022 07:03
@release-pleaserelease-pleaseBot mentioned this pull request Oct 4, 2022
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

api: spannerIssues related to the googleapis/python-spanner-sqlalchemy API.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@IlyaFaer@ansh0l