不要怂,就是干,撸起袖子干!

Commit 1b8c3898 by Simon Schick Committed by GitHub

fix(querying): prevent `having` clause from cascading (#10859)

1 parent dc418750
Showing with 4 additions and 1 deletions
......@@ -29,6 +29,9 @@ const validQueryKeywords = new Set(['where', 'attributes', 'paranoid', 'include'
'scope', 'group', 'through', 'defaults', 'distinct', 'primary', 'exception', 'type', 'hooks', 'force',
'name']);
// List of attributes that should not be implicitly passed into subqueries/includes.
const nonCascadingOptions = ['include', 'attributes', 'originalAttributes', 'order', 'where', 'limit', 'offset', 'plain', 'group', 'having'];
/**
* A Model represents a table in the database. Instances of this class represent a database row.
*
......@@ -1829,7 +1832,7 @@ class Model {
return include.association.get(results, Object.assign(
{},
_.omit(options, ['include', 'attributes', 'originalAttributes', 'order', 'where', 'limit', 'offset', 'plain', 'group']),
_.omit(options, nonCascadingOptions),
_.omit(include, ['parent', 'association', 'as', 'originalAttributes'])
)).then(map => {
for (const result of results) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!