Skip to content

get_multi_foreign_keys Returns Columns in Composite Foreign Key Out of Order #779

@waltaskew

Description

@waltaskew

Environment details

  • Programming language: Python
  • OS: Linux
  • Language runtime version: 3.12.2
  • Package version: 1.16.0

Steps to reproduce

Creating a table like:

CREATE TABLE composite_fk (
  a STRING(MAX),
  b STRING(MAX),
  c STRING(MAX),
  CONSTRAINT composite_fk FOREIGN KEY (a, b) REFERENCES composite_pk(a, b),
) PRIMARY KEY (a, b, c);

get_multi_foreign_keys returns referred_columns and constrained_columns in different orders.

I see {"referred_columns": ["b", "a"], "constrained_columns": ["a", "b"]}

This in turn affects alembic auto-generation, because it attempts to drop and recreate the foreign key which appears to have a different order than what I've defined.

#271 reports and #289 offers a fix for the constrained columns, but the referred columns are still effectively unordered.

Metadata

Metadata

Assignees

Labels

api: spannerIssues related to the googleapis/python-spanner-sqlalchemy API.priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions