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 c92ae383
authored
Jun 15, 2014
by
Jan Aagaard Meier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix instance.set for virtual attributes
1 parent
156c98ce
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
2 deletions
Makefile
lib/instance.js
test/model/attributes.test.js
Makefile
View file @
c92ae38
...
@@ -22,6 +22,9 @@ test:
...
@@ -22,6 +22,9 @@ test:
fi
fi
endif
endif
test-only
:
./node_modules/mocha/bin/mocha --globals setImmediate,clearImmediate --check-leaks --colors -t 10000 --reporter
$(REPORTER)
$(TESTS)
;
\
jshint
:
jshint
:
./node_modules/.bin/jshint lib
./node_modules/.bin/jshint lib
...
...
lib/instance.js
View file @
c92ae38
...
@@ -241,7 +241,7 @@ module.exports = (function() {
...
@@ -241,7 +241,7 @@ module.exports = (function() {
// Loop and call set
// Loop and call set
if
(
this
.
options
.
attributes
)
{
if
(
this
.
options
.
attributes
)
{
keys
=
this
.
options
.
attributes
;
keys
=
this
.
options
.
attributes
.
concat
(
this
.
Model
.
_virtualAttributes
)
;
if
(
this
.
options
&&
this
.
options
.
includeNames
)
{
if
(
this
.
options
&&
this
.
options
.
includeNames
)
{
keys
=
keys
.
concat
(
this
.
options
.
includeNames
);
keys
=
keys
.
concat
(
this
.
options
.
includeNames
);
...
...
test/model/attributes.test.js
View file @
c92ae38
...
@@ -324,7 +324,7 @@ describe(Support.getTestDialectTeaser("Model"), function () {
...
@@ -324,7 +324,7 @@ describe(Support.getTestDialectTeaser("Model"), function () {
return
this
.
sequelize
.
sync
({
force
:
true
});
return
this
.
sequelize
.
sync
({
force
:
true
});
});
});
it
(
'should be ignored in dataValues get'
,
function
()
{
it
(
'should
not
be ignored in dataValues get'
,
function
()
{
var
user
=
this
.
User
.
build
({
var
user
=
this
.
User
.
build
({
field1
:
'field1_value'
,
field1
:
'field1_value'
,
field2
:
'field2_value'
field2
:
'field2_value'
...
@@ -356,6 +356,23 @@ describe(Support.getTestDialectTeaser("Model"), function () {
...
@@ -356,6 +356,23 @@ describe(Support.getTestDialectTeaser("Model"), function () {
]);
]);
});
});
it
(
"should allow me to store selected values"
,
function
()
{
var
Post
=
this
.
sequelize
.
define
(
'Post'
,
{
text
:
Sequelize
.
TEXT
,
someBoolean
:
{
type
:
Sequelize
.
VIRTUAL
}
});
return
this
.
sequelize
.
sync
({
force
:
true
}).
then
(
function
()
{
return
Post
.
bulkCreate
([{
text
:
'text1'
},{
text
:
'text2'
}]);
}).
then
(
function
()
{
return
Post
.
find
({
attributes
:
[
'id'
,
'text'
,
Sequelize
.
literal
(
'EXISTS(SELECT 1) AS "someBoolean"'
)]
});
}).
then
(
function
(
post
)
{
expect
(
post
.
get
()).
to
.
deep
.
equal
({
id
:
1
,
text
:
"text1"
,
someBoolean
:
1
});
});
});
it
(
'should be ignored in create and updateAttributes'
,
function
()
{
it
(
'should be ignored in create and updateAttributes'
,
function
()
{
return
this
.
User
.
create
({
return
this
.
User
.
create
({
field1
:
'something'
field1
:
'something'
...
...
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