Skip to content

Postgres: Schema does not default to current schema for references when model is set only on parent model #11276

Closed

Description

@vanthome

What are you doing?

I need to switch schemas dynamically for multi tenancy in an application and when I change the schema for a model, I would like sequalize to default to that schema also for references and indexes. This is not the case yet and I would consider this a bug as it's the only sensible default behaviour.
The main point where this happens is when I call sync({ schema: 'archive' }) on a model,

What do you expect to happen?

Sequalize to default to the schema of the model I'm using.

What is actually happening?

If I sync a model into a schema for example (I have used sync({ schema: 'archive' }) on the models before), for references the current schema is not applied but no schema prefix at all.

Environment

Dialect:

  • mysql
  • postgres
  • sqlite
  • mssql
  • any
    Dialect library version: XXX
    Database version: XXX
    Sequelize version: XXX
    Node Version: XXX
    OS: XXX
    If TypeScript related: TypeScript version: XXX
    Tested with latest release:
  • No
  • Yes, specify that version:

Activity

  1. added
    dialect: postgres
    status: wip
    type: bug
    on Aug 3, 2019
  2. sushantdhiman commented on Aug 31, 2019

    @sushantdhiman
    Contributor

    🎉 This issue has been resolved in version 5.18.0 🎉

    The release is available on:

    Your semantic-release bot 📦🚀

  3. vanthome commented on Aug 31, 2019

    @vanthome
    ContributorAuthor

    thx!

  4. removed
    status: wip
    on Aug 31, 2019
  5. vanthome commented on Sep 11, 2019

    @vanthome
    ContributorAuthor

    @sushantdhiman

    v5.18.2 Regression partially reverts previous fix #11274 for me. This seems not to be covered by the test I have introduced. The problem is that schemas are not attached for implicit joins now.
    What shall we do? Should I propose a new test for this? Or can we revert to my solution?

  6. sushantdhiman commented on Sep 12, 2019

    @sushantdhiman
    Contributor

    New PR with tests will do

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    dialect: postgresreleasedtype: bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions