Skip to content
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

fix: Fix tables creation depending on each other via foreignKey constraint #1649

Merged

Conversation

naftalmm
Copy link
Contributor

This PR fixes #1643

Copy link
Collaborator

@joc-a joc-a left a comment

Choose a reason for hiding this comment

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

Hi @naftalmm. Thank you for your contribution. Could you please rebase on the main branch?

@naftalmm naftalmm force-pushed the fix_tables_creation_with_foreign_key_reference branch from 53f9cff to cf1f837 Compare August 13, 2023 14:46
@joc-a joc-a requested review from e5l and bog-walk August 14, 2023 16:21
Copy link
Member

@e5l e5l left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution, lgtm! please consider adding a test

@joc-a
Copy link
Collaborator

joc-a commented Sep 1, 2023

@naftalmm Thanks for adding tests. Could you please rebase on the main branch and resolve conflicts?

@naftalmm naftalmm force-pushed the fix_tables_creation_with_foreign_key_reference branch from 915c1bd to 7f653d7 Compare September 3, 2023 09:21
@joc-a joc-a changed the title Fix tables creation depending on each other via foreignKey constraint fix: Fix tables creation depending on each other via foreignKey constraint Sep 4, 2023
@joc-a joc-a merged commit f3a295a into JetBrains:main Sep 4, 2023
2 checks passed
saral pushed a commit to saral/Exposed that referenced this pull request Oct 3, 2023
…raint (JetBrains#1649)

* fix tables creation depending on each other via foreignKey constraint: fix table sorting by references, simplify code

* add tests

in case there are two tables (parent and child), with the child table referring the parent by the means of a composite foreign key only, the reference is not taken into account by the call SchemaUtils.create and, subsequently, by SchemaUtils.sortTablesByReferences

this causes the SchemaUtils to try to create the child table first, resulting in an SQL error:
CREATE TABLE IF NOT EXISTS child ..., CONSTRAINT fk_name FOREIGN KEY (col1, col2) REFERENCES parent(col1 col2) ...
[42102-199]. Statement(s): ...
Table parent not found

---------

Co-authored-by: Jocelyne <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

incorrect behaviour of SchemaUtils.create in a certain scenario involving composite foreign keys
4 participants