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: add referencedSchema to PostgresQueryRunner #8566

Merged
merged 2 commits into from
Feb 12, 2022
Merged

fix: add referencedSchema to PostgresQueryRunner #8566

merged 2 commits into from
Feb 12, 2022

Conversation

JasonMan34
Copy link
Contributor

@JasonMan34 JasonMan34 commented Jan 25, 2022

Description of change

Right now, when using PostgreSQL, relations that point to tables in a different schema will have their foreign constraints generated every migration, even if they already exist.
This is because when checking for the constraint's target, referencedSchema is used to prefix the column name(s). However, in PostgresQueryRunner, referencedSchema is never set, so the query runner thinks the existing constraint is pointing to public schema, even if it isn't

This PR adds referencedSchema to the PostgresQueryRunner loading of foreign keys.

Fixes #8565

Pull-Request Checklist

  • Code is up-to-date with the master branch
  • npm run lint passes with this change
  • npm run test passes with this change
  • This pull request links relevant issues as Fixes #0000
  • There are new or updated unit tests validating the change N/A
  • Documentation has been updated to reflect this change N/A
  • The new commits follow conventions explained in CONTRIBUTING.md

I didn't know what tests to add as there were no existing tests regarding referencedSchema
Also I don't believe this exists in the documentation

@JasonMan34 JasonMan34 changed the title Add referencedSchema to PostgresQueryRunner fix: add referencedSchema to PostgresQueryRunner Jan 25, 2022
@JasonMan34
Copy link
Contributor Author

JasonMan34 commented Jan 25, 2022

The tests that failed are not related to do the PR.
Seems to be a problem with issue-863.ts

@pleerock pleerock self-requested a review January 31, 2022 10:00
@AlexMesser AlexMesser merged commit c490319 into typeorm:master Feb 12, 2022
@AlexMesser
Copy link
Collaborator

thank you for contribution!

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.

PostgreSQL - Foreign keys to tables in a different schema get re-created in migration
2 participants