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 8eb2cf19
authored
Jul 29, 2015
by
Jan Aagaard Meier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug(scope.include) Map fieldnames for include.where coming from scopes. Closes #4210
1 parent
e3b9e02c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
4 deletions
changelog.md
lib/model.js
test/unit/model/include.test.js
changelog.md
View file @
8eb2cf1
# Next
-
[
FIXED
]
Map column names with
`.field`
in scopes with includes.
[
#4210
](
https://github.com/sequelize/sequelize/issues/4210
)
# 3.5.1
# 3.5.1
-
[
FIXED
]
Fix bug with nested includes where a middle include results in a null value which breaks $findSeperate.
-
[
FIXED
]
Fix bug with nested includes where a middle include results in a null value which breaks $findSeperate.
...
...
lib/model.js
View file @
8eb2cf1
...
@@ -529,11 +529,9 @@ validateIncludedElement = function(include, tableNames, options) {
...
@@ -529,11 +529,9 @@ validateIncludedElement = function(include, tableNames, options) {
include
.
attributes
=
Object
.
keys
(
include
.
model
.
tableAttributes
);
include
.
attributes
=
Object
.
keys
(
include
.
model
.
tableAttributes
);
}
}
include
=
Utils
.
mapOptionFieldNames
(
include
,
include
.
model
);
// pseudo include just needed the attribute logic, return
// pseudo include just needed the attribute logic, return
if
(
include
.
_pseudo
)
{
if
(
include
.
_pseudo
)
{
return
include
;
return
Utils
.
mapOptionFieldNames
(
include
,
include
.
model
)
;
}
}
// check if the current Model is actually associated with the passed Model - or it's a pseudo include
// check if the current Model is actually associated with the passed Model - or it's a pseudo include
...
@@ -590,6 +588,8 @@ validateIncludedElement = function(include, tableNames, options) {
...
@@ -590,6 +588,8 @@ validateIncludedElement = function(include, tableNames, options) {
Model
.
$injectScope
(
model
.
$scope
,
include
);
Model
.
$injectScope
(
model
.
$scope
,
include
);
include
=
Utils
.
mapOptionFieldNames
(
include
,
include
.
model
);
if
(
include
.
required
===
undefined
)
{
if
(
include
.
required
===
undefined
)
{
include
.
required
=
!!
include
.
where
;
include
.
required
=
!!
include
.
where
;
}
}
...
...
test/unit/model/include.test.js
View file @
8eb2cf1
...
@@ -70,7 +70,12 @@ describe(Support.getTestDialectTeaser('Model'), function() {
...
@@ -70,7 +70,12 @@ describe(Support.getTestDialectTeaser('Model'), function() {
describe
(
'scope'
,
function
()
{
describe
(
'scope'
,
function
()
{
beforeEach
(
function
()
{
beforeEach
(
function
()
{
this
.
Project
=
this
.
sequelize
.
define
(
'project'
,
{},
{
this
.
Project
=
this
.
sequelize
.
define
(
'project'
,
{
bar
:
{
type
:
Sequelize
.
STRING
,
field
:
'foo'
}
},
{
defaultScope
:
{
defaultScope
:
{
where
:
{
where
:
{
active
:
true
active
:
true
...
@@ -82,6 +87,11 @@ describe(Support.getTestDialectTeaser('Model'), function() {
...
@@ -82,6 +87,11 @@ describe(Support.getTestDialectTeaser('Model'), function() {
that
:
{
that
:
{
where
:
{
that
:
false
},
where
:
{
that
:
false
},
limit
:
12
limit
:
12
},
foobar
:
{
where
:
{
bar
:
42
}
}
}
}
}
});
});
...
@@ -127,6 +137,15 @@ describe(Support.getTestDialectTeaser('Model'), function() {
...
@@ -127,6 +137,15 @@ describe(Support.getTestDialectTeaser('Model'), function() {
expect
(
options
.
include
[
0
]).
to
.
have
.
property
(
'where'
).
which
.
deep
.
equals
({
this
:
true
});
expect
(
options
.
include
[
0
]).
to
.
have
.
property
(
'where'
).
which
.
deep
.
equals
({
this
:
true
});
});
});
it
(
'handles a scope with an aliased column (.field)'
,
function
()
{
var
options
=
Sequelize
.
Model
.
$validateIncludedElements
({
model
:
this
.
User
,
include
:
[{
model
:
this
.
Project
.
scope
(
'foobar'
)
}]
});
expect
(
options
.
include
[
0
]).
to
.
have
.
property
(
'where'
).
which
.
deep
.
equals
({
foo
:
42
});
});
});
});
describe
(
'duplicating'
,
function
()
{
describe
(
'duplicating'
,
function
()
{
...
...
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