Skip to content

Conversation

@IlyaFaer
Copy link
Contributor

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.

@IlyaFaer IlyaFaer added the type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. label Aug 31, 2022
@product-auto-label product-auto-label bot 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
Contributor 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


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
Contributor 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 main Sep 2, 2022
@IlyaFaer IlyaFaer deleted the autogen_migrations branch September 2, 2022 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: spanner Issues related to the googleapis/python-spanner-sqlalchemy API. type: bug Error 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