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 2c6e526c
authored
Sep 03, 2015
by
Mick Hansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix virtual dependency inclusion for includes
1 parent
19536f13
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
1 deletions
lib/model.js
lib/utils.js
test/unit/utils.test.js
lib/model.js
View file @
2c6e526
...
...
@@ -516,6 +516,9 @@ Model.$validateIncludedElements = validateIncludedElements;
validateIncludedElement
=
function
(
include
,
tableNames
,
options
)
{
tableNames
[
include
.
model
.
getTableName
()]
=
true
;
// Need to make sure virtuals are mapped before setting originalAttributes
include
=
Utils
.
mapFinderOptions
(
include
,
include
.
model
);
if
(
include
.
attributes
&&
!
options
.
raw
)
{
include
.
originalAttributes
=
include
.
attributes
.
slice
(
0
);
...
...
lib/utils.js
View file @
2c6e526
...
...
@@ -78,7 +78,7 @@ var Utils = module.exports = {
/* Expand and normalize finder options */
mapFinderOptions
:
function
(
options
,
Model
)
{
if
(
Model
.
_hasVirtualAttributes
)
{
if
(
Model
.
_hasVirtualAttributes
&&
options
.
attributes
)
{
options
.
attributes
.
forEach
(
function
(
attribute
)
{
if
(
Model
.
_isVirtualAttribute
(
attribute
)
&&
Model
.
rawAttributes
[
attribute
].
type
.
fields
)
{
options
.
attributes
=
options
.
attributes
.
concat
(
Model
.
rawAttributes
[
attribute
].
type
.
fields
);
...
...
test/unit/utils.test.js
View file @
2c6e526
...
...
@@ -52,6 +52,34 @@ suite(Support.getTestDialectTeaser('Utils'), function() {
]
]);
});
test
(
'multiple calls'
,
function
()
{
var
Model
=
this
.
sequelize
.
define
(
'User'
,
{
createdAt
:
{
type
:
DataTypes
.
DATE
,
field
:
'created_at'
},
active
:
{
type
:
new
DataTypes
.
VIRTUAL
(
DataTypes
.
BOOLEAN
,
[
'createdAt'
])
}
});
expect
(
Utils
.
mapFinderOptions
(
Utils
.
mapFinderOptions
({
attributes
:
[
'active'
]
},
Model
),
Model
).
attributes
).
to
.
eql
([
[
'created_at'
,
'createdAt'
]
]);
});
});
suite
(
'mapOptionFieldNames'
,
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