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

Including models without predefined schema fails if it's a separate query #1691

Open
1 of 2 tasks
Mustachipleb opened this issue Jul 27, 2023 · 0 comments
Open
1 of 2 tasks

Comments

@Mustachipleb
Copy link

Mustachipleb commented Jul 27, 2023

Issue

Versions

  • sequelize: 6.32.1
  • sequelize-typescript: 2.1.5
  • typescript: 4.7.4
  • tedious: 11.8.0

Issue type

  • bug report
  • feature request

Actual behavior

It is impossible to include a model on a specific schema to a query on another model if the query is marked as separate.

Expected behavior

It is possible to include a model from a specific schema to a query on another model if the query is marked as separate.

Steps to reproduce

const schemaIWantToUse = 'dbo';
const result = await MyModel.findAll({
    include: [
        {
            model: MyOtherModel.schema(schemaIWantToUse),
            separate: true
        }
    ]
});

Query model X and include model Y on any schema (eg dbo) and mark it as separate. The query will fail, because the resulting SQL will have (roughly, without sequelize sugar) this structure:

SELECT * FROM [MyTable]
JOIN [MyOtherTable] ON [MyTable].[myOtherTableId] = [MyOtherTable].[id]

SequelizeDatabaseError: Invalid object name 'myOtherTable'.

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

No branches or pull requests

1 participant