Skip to content

Commit

Permalink
fix: don't introspect internal UNIQUE constraints (#244)
Browse files Browse the repository at this point in the history
  • Loading branch information
IlyaFaer authored Sep 19, 2022
1 parent c3b5907 commit 51cdc53
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion create_test_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def create_test_instance():
configs = list(CLIENT.list_instance_configs())
if not USE_EMULATOR:
# Filter out non "us" locations
configs = [config for config in configs if "-us-" in config.name]
configs = [config for config in configs if "europe-north1" in config.name]

instance_config = configs[0].name
create_time = str(int(time.time()))
Expand Down
7 changes: 6 additions & 1 deletion google/cloud/sqlalchemy_spanner/sqlalchemy_spanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,12 @@ def get_unique_constraints(self, connection, table_name, schema=None, **kw):
FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS AS tc
JOIN INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE AS ccu
ON ccu.CONSTRAINT_NAME = tc.CONSTRAINT_NAME
WHERE tc.TABLE_NAME="{table_name}" AND tc.CONSTRAINT_TYPE = "UNIQUE"
LEFT JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS AS rc
on tc.CONSTRAINT_NAME = rc.CONSTRAINT_NAME
WHERE
tc.TABLE_NAME="{table_name}"
AND tc.CONSTRAINT_TYPE = "UNIQUE"
AND rc.CONSTRAINT_NAME IS NOT NULL
""".format(
table_name=table_name
)
Expand Down

0 comments on commit 51cdc53

Please sign in to comment.