Skip to content

Conversation

@SimonSchick
Copy link
Contributor

Pull Request check-list

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

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

Description of change

See title
fixes #10506

@sushantdhiman can you clarify if you can specify BOTH the query type AND model?
It seems that when model is specified it implicitly uses SELECT but what if type is specified?

@sushantdhiman
Copy link
Contributor

sequelize/lib/sequelize.js

Lines 482 to 488 in 45648dd

if (!options.type) {
if (options.model || options.nest || options.plain) {
options.type = QueryTypes.SELECT;
} else {
options.type = QueryTypes.RAW;
}
}

Both type and model can be specified, when there is no type we use options.model to set it to SELECT type.

@sushantdhiman
Copy link
Contributor

Let me know if this is ready

@SimonSchick
Copy link
Contributor Author

@sushantdhiman what exactly is the return type if, for example model and type: INSERT is specified?

@sushantdhiman
Copy link
Contributor

type: INSERT, as model won't modify type if it's already set

@SimonSchick
Copy link
Contributor Author

So does setting model have any effect for any type except SELECT? Sorry the code is really hard to understand..

@sushantdhiman
Copy link
Contributor

Setting model has no effect on type, if type is already set

@SimonSchick
Copy link
Contributor Author

So, in typings we should probably not support setting both at the same time then as it's pointless and probably an error.

In this case this PR is complete.

@sushantdhiman sushantdhiman merged commit 0b5aa71 into sequelize:master Mar 8, 2019
@SimonSchick SimonSchick deleted the fix/types-query-model branch March 8, 2019 09:39
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.

sequelize.query typings are not allowing model property in typings (v5)

2 participants