Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
public
/
sequelize
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
不要怂,就是干,撸起袖子干!
Commit e07a7bea
authored
Mar 22, 2019
by
Simon Schick
Committed by
Erik Seliger
Mar 22, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(query-generator): correctly treat projection inversion in include default scope (#10597)
Fixes #10399
1 parent
db16cd56
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
2 deletions
lib/dialects/abstract/query-generator.js
lib/model.js
test/integration/model/scope/find.test.js
lib/dialects/abstract/query-generator.js
View file @
e07a7be
...
@@ -1425,6 +1425,7 @@ class QueryGenerator {
...
@@ -1425,6 +1425,7 @@ class QueryGenerator {
// includeIgnoreAttributes is used by aggregate functions
// includeIgnoreAttributes is used by aggregate functions
if (topLevelInfo.options.includeIgnoreAttributes !== false) {
if (topLevelInfo.options.includeIgnoreAttributes !== false) {
include.model._expandAttributes(include);
const includeAttributes = include.attributes.map(attr => {
const includeAttributes = include.attributes.map(attr => {
let attrAs = attr;
let attrAs = attr;
let verbatim = false;
let verbatim = false;
...
...
lib/model.js
View file @
e07a7be
...
@@ -3082,7 +3082,9 @@ class Model {
...
@@ -3082,7 +3082,9 @@ class Model {
}
}
static
_expandAttributes
(
options
)
{
static
_expandAttributes
(
options
)
{
if
(
_
.
isPlainObject
(
options
.
attributes
))
{
if
(
!
_
.
isPlainObject
(
options
.
attributes
))
{
return
;
}
let
attributes
=
Object
.
keys
(
this
.
rawAttributes
);
let
attributes
=
Object
.
keys
(
this
.
rawAttributes
);
if
(
options
.
attributes
.
exclude
)
{
if
(
options
.
attributes
.
exclude
)
{
...
@@ -3095,7 +3097,6 @@ class Model {
...
@@ -3095,7 +3097,6 @@ class Model {
options
.
attributes
=
attributes
;
options
.
attributes
=
attributes
;
}
}
}
// Inject _scope into options.
// Inject _scope into options.
static
_injectScope
(
options
)
{
static
_injectScope
(
options
)
{
...
...
test/integration/model/scope/find.test.js
View file @
e07a7be
...
@@ -46,6 +46,18 @@ describe(Support.getTestDialectTeaser('Model'), () => {
...
@@ -46,6 +46,18 @@ describe(Support.getTestDialectTeaser('Model'), () => {
}
}
});
});
this
.
DefaultScopeExclude
=
this
.
sequelize
.
define
(
'DefaultScopeExclude'
,
{
name
:
Sequelize
.
STRING
},
{
defaultScope
:
{
attributes
:
{
exclude
:
[
'name'
]
}
}
});
this
.
ScopeMe
.
hasMany
(
this
.
DefaultScopeExclude
);
return
this
.
sequelize
.
sync
({
force
:
true
}).
then
(()
=>
{
return
this
.
sequelize
.
sync
({
force
:
true
}).
then
(()
=>
{
const
records
=
[
const
records
=
[
{
username
:
'tony'
,
email
:
'tony@sequelizejs.com'
,
access_level
:
3
,
other_value
:
7
,
parent_id
:
1
},
{
username
:
'tony'
,
email
:
'tony@sequelizejs.com'
,
access_level
:
3
,
other_value
:
7
,
parent_id
:
1
},
...
@@ -119,5 +131,11 @@ describe(Support.getTestDialectTeaser('Model'), () => {
...
@@ -119,5 +131,11 @@ describe(Support.getTestDialectTeaser('Model'), () => {
expect
(
user
.
username
).
to
.
equal
(
'fake'
);
expect
(
user
.
username
).
to
.
equal
(
'fake'
);
});
});
});
});
it
(
'should work when included with default scope'
,
function
()
{
return
this
.
ScopeMe
.
findOne
({
include
:
[
this
.
DefaultScopeExclude
]
});
});
});
});
});
});
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment