Skip to content

django: implement DatabaseIntrospection.get_relations() #311

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
timgraham opened this issue Mar 6, 2020 · 4 comments
Closed

django: implement DatabaseIntrospection.get_relations() #311

timgraham opened this issue Mar 6, 2020 · 4 comments
Assignees
Labels
🚨 This issue needs some love. triage me I really want to be triaged.

Comments

@timgraham
Copy link
Contributor

Test: introspection.tests.IntrospectionTests.test_get_relations

@odeke-em odeke-em self-assigned this Mar 9, 2020
@odeke-em
Copy link
Contributor

I think we can run this SQL:

SELECT tc.COLUMN_NAME as orig_col, ccu.TABLE_NAME, ccu.COLUMN_NAME as ref_col
from
	INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS tc
JOIN
    INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS as rc
ON
    tc.CONSTRAINT_NAME = rc.CONSTRAINT_NAME
JOIN
    INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE as ccu
ON
    rc.UNIQUE_CONSTRAINT_NAME = ccu.CONSTRAINT_NAME
WHERE
   tc.TABLE_NAME=tableName

@odeke-em
Copy link
Contributor

I've prepared a PR and will mail it shortly.

@odeke-em
Copy link
Contributor

Actually we can't support this feature until we've figured out how to handle foreign keys as per #313. I've written the code for it, but then I noticed that we don't even issue the FOREIGN KEY constraints thus the tests will perennially fail.

odeke-em added a commit that referenced this issue Mar 10, 2020
…elations

Implemented:
* DatabaseIntrospection.get_primary_key_column
* DatabaseIntrospection.get_relations

However, get_relations tests CANNOT yet be enabled because
Cloud Spanner doesn't yet have ON DELETE cascading for
FOREIGN KEYS which limits #313, which renders the method
useless as it will always return {} instead of being populated
with values that are derived from FOREIGN KEYs.

Fixes #312
Updates #311
odeke-em added a commit that referenced this issue Mar 10, 2020
…elations

Implemented:
* DatabaseIntrospection.get_primary_key_column
* DatabaseIntrospection.get_relations

However, get_relations tests CANNOT yet be enabled because
Cloud Spanner doesn't yet have ON DELETE cascading for
FOREIGN KEYS which limits #313, which renders the method
useless as it will always return {} instead of being populated
with values that are derived from FOREIGN KEYs.

Fixes #312
Updates #311
odeke-em added a commit that referenced this issue Mar 10, 2020
…elations

Implemented:
* DatabaseIntrospection.get_primary_key_column
* DatabaseIntrospection.get_relations

However, get_relations tests CANNOT yet be enabled because
Cloud Spanner doesn't yet have ON DELETE cascading for
FOREIGN KEYS which limits #313, which renders the method
useless as it will always return {} instead of being populated
with values that are derived from FOREIGN KEYs.

Fixes #312
Updates #311
odeke-em added a commit that referenced this issue Mar 10, 2020
…elations

Implemented:
* DatabaseIntrospection.get_primary_key_column
* DatabaseIntrospection.get_relations

However, get_relations tests CANNOT yet be enabled because
Cloud Spanner doesn't yet have ON DELETE cascading for
FOREIGN KEYS which limits #313, which renders the method
useless as it will always return {} instead of being populated
with values that are derived from FOREIGN KEYs.

Fixes #312
Updates #311
odeke-em added a commit that referenced this issue Mar 12, 2020
…elations

Implemented:
* DatabaseIntrospection.get_primary_key_column
* DatabaseIntrospection.get_relations

However, get_relations tests CANNOT yet be enabled because
Cloud Spanner doesn't yet have ON DELETE cascading for
FOREIGN KEYS which limits #313, which renders the method
useless as it will always return {} instead of being populated
with values that are derived from FOREIGN KEYs.

Fixes #312
Updates #311
odeke-em added a commit that referenced this issue Mar 13, 2020
…elations

Implemented:
* DatabaseIntrospection.get_primary_key_column
* DatabaseIntrospection.get_relations

However, get_relations tests CANNOT yet be enabled because
Cloud Spanner doesn't yet have ON DELETE cascading for
FOREIGN KEYS which limits #313, which renders the method
useless as it will always return {} instead of being populated
with values that are derived from FOREIGN KEYs.

Fixes #312
Updates #311
@timgraham
Copy link
Contributor Author

Implemented in 9ca5262.

@yoshi-automation yoshi-automation added triage me I really want to be triaged. 🚨 This issue needs some love. labels Apr 7, 2020
@vi3k6i5 vi3k6i5 assigned vi3k6i5 and unassigned timgraham Oct 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🚨 This issue needs some love. triage me I really want to be triaged.
Projects
None yet
Development

No branches or pull requests

4 participants