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(postgres): use schema set in sequelize config by default #14634

Merged
merged 12 commits into from Jun 19, 2022
Merged

fix(postgres): use schema set in sequelize config by default #14634

merged 12 commits into from Jun 19, 2022

Conversation

nholmes3
Copy link
Contributor

@nholmes3 nholmes3 commented Jun 13, 2022

Pull Request Checklist

Please make sure to review and check all of these items:

  • Have you added new tests to prevent regressions?
  • Does yarn test or yarn test-DIALECT pass with this change (including linting)?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
  • Did you update the typescript typings accordingly (if applicable)?
  • Does the description below contain a link to an existing issue (Closes #[issue]) or a description of the issue you are solving?
  • Did you follow the commit message conventions explained in CONTRIBUTING.md?

Description Of Change

This is an attempt at fixing a bug where the Postgres Query Generator does not respect a custom schema name if it is provided.

This comment on Issue #248 of sequelize/cli describes the problem in detail.

@WikiRik
Copy link
Member

WikiRik commented Jun 14, 2022

@mike-usa this might be interesting for you

@WikiRik
Copy link
Member

WikiRik commented Jun 14, 2022

Hi @nholmes3, thanks for the PR! Could you add some tests for this? Where you test the normal 'public' schema but also a custom schema

@nholmes3
Copy link
Contributor Author

Hi @nholmes3, thanks for the PR! Could you add some tests for this? Where you test the normal 'public' schema but also a custom schema

Hey @WikiRik I would be happy to try to add some tests. Do you mind pointing me at the file where they would be most appropriate? Thanks

@WikiRik

This comment was marked as outdated.

@ephys
Copy link
Member

ephys commented Jun 14, 2022

This change does not exclusively impact postgres. I think these files would be better places to add the tests to: https://github.com/sequelize/sequelize/tree/main/test/unit/sql.

I would say add at test in:

The test should use a custom sequelize instance which sets a default schema, and ensure the generated SQL uses that schema.

This test also impacts describeTable, so a similar test should be added in https://github.com/sequelize/sequelize/blob/main/test/integration/query-interface/describeTable.test.js

@nholmes3
Copy link
Contributor Author

nholmes3 commented Jun 14, 2022

This change does not exclusively impact postgres. I think these files would be better places to add the tests to: https://github.com/sequelize/sequelize/tree/main/test/unit/sql.

I would say add at test in:

The test should use a custom sequelize instance which sets a default schema, and ensure the generated SQL uses that schema.

This test also impacts describeTable, so a similar test should be added in https://github.com/sequelize/sequelize/blob/main/test/integration/query-interface/describeTable.test.js

@ephys I have added tests to add-column and remove-column, and I have also added a unit test covering describeTableQuery in the postgres unit tests. I am a little bit overwhelmed by how to properly add a test to the describeTable integration tests. Do you mind providing some additional guidance?

@ephys ephys self-requested a review June 15, 2022 18:02
Copy link
Member

@ephys ephys left a comment

Choose a reason for hiding this comment

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

The describeTable integration test can be skipped because we already have an integration test that checks the query that includes schemas is valid, so the unit test you added is sufficient :)

test/unit/sql/add-column.test.js Outdated Show resolved Hide resolved
test/unit/sql/add-column.test.js Outdated Show resolved Hide resolved
test/unit/sql/add-column.test.js Outdated Show resolved Hide resolved
test/unit/sql/add-column.test.js Outdated Show resolved Hide resolved
test/unit/sql/remove-column.test.js Outdated Show resolved Hide resolved
test/unit/dialects/postgres/query-generator.test.js Outdated Show resolved Hide resolved
test/unit/dialects/postgres/query-generator.test.js Outdated Show resolved Hide resolved
test/unit/dialects/postgres/query-generator.test.js Outdated Show resolved Hide resolved
test/unit/dialects/postgres/query-generator.test.js Outdated Show resolved Hide resolved
@ephys ephys changed the title Ensure postgres respects custom schema fix(postgres): use schema set in sequelize config by default Jun 19, 2022
@ephys ephys requested review from ephys and WikiRik June 19, 2022 16:23
Copy link
Member

@ephys ephys left a comment

Choose a reason for hiding this comment

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

This looks good to me.

@WikiRik if it's ok for you too, we can merge

@ephys ephys merged commit 751826a into sequelize:main Jun 19, 2022
@ephys
Copy link
Member

ephys commented Jun 19, 2022

Here we go :)
Thank you for your work on this!

@nholmes3
Copy link
Contributor Author

@WikiRik @ephys Thank you for the help! Do you have any information on when I can expect these changes to be officially released? Thanks!

@WikiRik
Copy link
Member

WikiRik commented Jun 20, 2022

We can make a new alpha release of v7 if you want, but if you want this in v6 we would like to ask you to make a new PR for that.

@nholmes3
Copy link
Contributor Author

We can make a new alpha release of v7 if you want, but if you want this in v6 we would like to ask you to make a new PR for that.

@WikiRik I would prefer to get this in v6. I checked the documentation for contributing and I don't see any explicit instructions for how to create a pull request for a release. Can you please provide additional guidance?

@WikiRik
Copy link
Member

WikiRik commented Jun 20, 2022

Just make a new branch from v6 (instead of main), implement these changes there as well and make a new PR that points towards v6. You should be able to re-use most of your code there

@github-actions
Copy link
Contributor

github-actions bot commented Aug 7, 2022

🎉 This PR is included in version 7.0.0-alpha.15 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants