Skip to content

Fix MySQL Foreign Key schema query#6169

Closed
weckx wants to merge 2 commits intotypeorm:masterfrom
weckx:fix-mysql-schema-fk-load
Closed

Fix MySQL Foreign Key schema query#6169
weckx wants to merge 2 commits intotypeorm:masterfrom
weckx:fix-mysql-schema-fk-load

Conversation

@weckx
Copy link

@weckx weckx commented May 31, 2020

Add a new clause for the join with INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS to prevent errors when there is more than one database in the server with foreign keys with same name.

Closes #6168

@imnotjames
Copy link
Contributor

Unfortunately, we did pull in a different PR that accomplished this 🤔 but looking at this, I like that you used the inner join to make the query.

I'll be closing this but I will probably make the change you made here the actual change we keep in the repo.

@imnotjames imnotjames closed this Oct 5, 2020
imnotjames added a commit to imnotjames/typeorm that referenced this pull request Oct 5, 2020
in typeorm#6268 we pulled in a change that fixed the wrong FK
getting loaded in a multi-database / multi-schema environment
but in typeorm#6169 the approach was more desirable as it creates
a simpler query that should be easier to change in the future

as such, this pulls over that change from typeorm#6169
imnotjames added a commit to imnotjames/typeorm that referenced this pull request Oct 5, 2020
in typeorm#6268 we pulled in a change that fixed the wrong FK
getting loaded in a multi-database / multi-schema environment
but in typeorm#6169 the approach was more desirable as it creates
a simpler query that should be easier to change in the future

as such, this pulls over that change from typeorm#6169
imnotjames added a commit to imnotjames/typeorm that referenced this pull request Oct 5, 2020
in typeorm#6268 we pulled in a change that fixed the wrong FK
getting loaded in a multi-database / multi-schema environment
but in typeorm#6169 the approach was more desirable as it creates
a simpler query that should be easier to change in the future

as such, this pulls over that change from typeorm#6169
pleerock pushed a commit that referenced this pull request Oct 5, 2020
in #6268 we pulled in a change that fixed the wrong FK
getting loaded in a multi-database / multi-schema environment
but in #6169 the approach was more desirable as it creates
a simpler query that should be easier to change in the future

as such, this pulls over that change from #6169
zaro pushed a commit to zaro/typeorm that referenced this pull request Jan 12, 2021
in typeorm#6268 we pulled in a change that fixed the wrong FK
getting loaded in a multi-database / multi-schema environment
but in typeorm#6169 the approach was more desirable as it creates
a simpler query that should be easier to change in the future

as such, this pulls over that change from typeorm#6169
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.

Wrong foreign key information loaded from schema

2 participants