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 b72e3bb2
authored
Aug 21, 2019
by
bparan
Committed by
Sushant
Aug 21, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(query-generator): handle virtual column on associations with scopes (#11327)
1 parent
801aa365
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
1 deletions
lib/dialects/abstract/query-generator.js
test/integration/model/scope/find.test.js
lib/dialects/abstract/query-generator.js
View file @
b72e3bb
...
...
@@ -1455,7 +1455,7 @@ class QueryGenerator {
// includeIgnoreAttributes is used by aggregate functions
if (topLevelInfo.options.includeIgnoreAttributes !== false) {
include.model._expandAttributes(include);
Utils.map
OptionFieldName
s(include, include.model);
Utils.map
FinderOption
s(include, include.model);
const includeAttributes = include.attributes.map(attr => {
let attrAs = attr;
...
...
test/integration/model/scope/find.test.js
View file @
b72e3bb
...
...
@@ -142,4 +142,40 @@ describe(Support.getTestDialectTeaser('Model'), () => {
});
});
});
describe
(
'scope in associations'
,
()
=>
{
it
(
'should work when association with a virtual column queried with default scope'
,
function
()
{
const
Game
=
this
.
sequelize
.
define
(
'Game'
,
{
name
:
Sequelize
.
TEXT
});
const
User
=
this
.
sequelize
.
define
(
'User'
,
{
login
:
Sequelize
.
TEXT
,
session
:
{
type
:
Sequelize
.
VIRTUAL
,
get
()
{
return
'New'
;
}
}
},
{
defaultScope
:
{
attributes
:
{
exclude
:
[
'login'
]
}
}
});
Game
.
hasMany
(
User
);
return
this
.
sequelize
.
sync
({
force
:
true
}).
then
(()
=>
{
return
Game
.
findAll
({
include
:
[{
model
:
User
}]
});
}).
then
(
games
=>
{
expect
(
games
).
to
.
have
.
lengthOf
(
0
);
});
});
});
});
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