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 cb6a51cb
authored
Sep 09, 2014
by
Mick Hansen
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:sequelize/sequelize
2 parents
c749746e
8a3013c5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
2 deletions
lib/instance.js
test/dao.test.js
lib/instance.js
View file @
cb6a51c
...
@@ -184,8 +184,10 @@ module.exports = (function() {
...
@@ -184,8 +184,10 @@ module.exports = (function() {
return
this
.
dataValues
[
key
].
map
(
function
(
instance
)
{
return
this
.
dataValues
[
key
].
map
(
function
(
instance
)
{
return
instance
.
get
({
plain
:
options
.
plain
});
return
instance
.
get
({
plain
:
options
.
plain
});
});
});
}
else
{
}
else
if
(
this
.
dataValues
[
key
]
instanceof
Instance
)
{
return
this
.
dataValues
[
key
].
get
({
plain
:
options
.
plain
});
return
this
.
dataValues
[
key
].
get
({
plain
:
options
.
plain
});
}
else
{
return
this
.
dataValues
[
key
];
}
}
}
}
return
this
.
dataValues
[
key
];
return
this
.
dataValues
[
key
];
...
@@ -210,8 +212,10 @@ module.exports = (function() {
...
@@ -210,8 +212,10 @@ module.exports = (function() {
values
[
_key
]
=
this
.
dataValues
[
_key
].
map
(
function
(
instance
)
{
values
[
_key
]
=
this
.
dataValues
[
_key
].
map
(
function
(
instance
)
{
return
instance
.
get
({
plain
:
options
.
plain
});
return
instance
.
get
({
plain
:
options
.
plain
});
});
});
}
else
{
}
else
if
(
this
.
dataValues
[
_key
]
instanceof
Instance
)
{
values
[
_key
]
=
this
.
dataValues
[
_key
].
get
({
plain
:
options
.
plain
});
values
[
_key
]
=
this
.
dataValues
[
_key
].
get
({
plain
:
options
.
plain
});
}
else
{
values
[
_key
]
=
this
.
dataValues
[
_key
];
}
}
}
else
{
}
else
{
values
[
_key
]
=
this
.
dataValues
[
_key
];
values
[
_key
]
=
this
.
dataValues
[
_key
];
...
...
test/dao.test.js
View file @
cb6a51c
...
@@ -1200,6 +1200,55 @@ describe(Support.getTestDialectTeaser("DAO"), function () {
...
@@ -1200,6 +1200,55 @@ describe(Support.getTestDialectTeaser("DAO"), function () {
})
})
})
})
it
(
"dont return instance that isn't defined"
,
function
(
done
)
{
var
self
=
this
;
self
.
Project
.
create
({
lovelyUserId
:
null
})
.
then
(
function
(
project
)
{
return
self
.
Project
.
find
({
where
:
{
id
:
project
.
id
,
},
include
:
[
{
model
:
self
.
User
,
as
:
'LovelyUser'
}
]
})
})
.
then
(
function
(
project
)
{
var
json
=
project
.
toJSON
();
expect
(
json
.
LovelyUser
).
to
.
be
.
equal
(
null
)
})
.
done
(
done
)
.
catch
(
done
);
});
it
(
"dont return instances that aren't defined"
,
function
(
done
)
{
var
self
=
this
;
self
.
User
.
create
({
username
:
'cuss'
})
.
then
(
function
(
user
)
{
return
self
.
User
.
find
({
where
:
{
id
:
user
.
id
,
},
include
:
[
{
model
:
self
.
Project
,
as
:
'Projects'
}
]
})
})
.
then
(
function
(
user
)
{
var
json
=
user
.
toJSON
();
expect
(
user
.
Projects
).
to
.
be
.
instanceof
(
Array
)
expect
(
user
.
Projects
).
to
.
be
.
length
(
0
)
})
.
done
(
done
)
.
catch
(
done
);
});
it
(
'returns an object containing all values'
,
function
(
done
)
{
it
(
'returns an object containing all values'
,
function
(
done
)
{
var
user
=
this
.
User
.
build
({
username
:
'test.user'
,
age
:
99
,
isAdmin
:
true
})
var
user
=
this
.
User
.
build
({
username
:
'test.user'
,
age
:
99
,
isAdmin
:
true
})
expect
(
user
.
toJSON
()).
to
.
deep
.
equal
({
username
:
'test.user'
,
age
:
99
,
isAdmin
:
true
,
id
:
null
})
expect
(
user
.
toJSON
()).
to
.
deep
.
equal
({
username
:
'test.user'
,
age
:
99
,
isAdmin
:
true
,
id
:
null
})
...
...
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