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 d4104d3b
authored
Apr 26, 2011
by
Sascha Depold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test for boolean defaults
1 parent
669af862
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
3 deletions
lib/sequelize/model-definition.js
test/Model/build.js
lib/sequelize/model-definition.js
View file @
d4104d3
...
@@ -109,8 +109,8 @@ ModelDefinition.prototype.build = function(values) {
...
@@ -109,8 +109,8 @@ ModelDefinition.prototype.build = function(values) {
if
(
typeof
instance
[
name
]
==
'undefined'
)
{
if
(
typeof
instance
[
name
]
==
'undefined'
)
{
var
value
=
null
var
value
=
null
if
(
self
.
rawAttributes
.
hasOwnProperty
(
name
))
if
(
self
.
rawAttributes
.
hasOwnProperty
(
name
)
&&
self
.
rawAttributes
[
name
].
hasOwnProperty
(
'defaultValue'
)
)
value
=
self
.
rawAttributes
[
name
].
defaultValue
||
null
value
=
self
.
rawAttributes
[
name
].
defaultValue
instance
[
name
]
=
value
instance
[
name
]
=
value
instance
.
addAttribute
(
name
,
value
)
instance
.
addAttribute
(
name
,
value
)
...
...
test/Model/build.js
View file @
d4104d3
...
@@ -28,11 +28,13 @@ module.exports = {
...
@@ -28,11 +28,13 @@ module.exports = {
title
:
{
dataType
:
Sequelize
.
STRING
,
defaultValue
:
'a task!'
},
title
:
{
dataType
:
Sequelize
.
STRING
,
defaultValue
:
'a task!'
},
foo
:
{
dataType
:
Sequelize
.
INTEGER
,
defaultValue
:
2
},
foo
:
{
dataType
:
Sequelize
.
INTEGER
,
defaultValue
:
2
},
bar
:
{
dataType
:
Sequelize
.
DATE
},
bar
:
{
dataType
:
Sequelize
.
DATE
},
foobar
:
{
dataType
:
Sequelize
.
TEXT
,
defaultValue
:
'asd'
}
foobar
:
{
dataType
:
Sequelize
.
TEXT
,
defaultValue
:
'asd'
},
flag
:
{
dataType
:
Sequelize
.
BOOLEAN
,
defaultValue
:
false
}
})
})
assert
.
eql
(
Task
.
build
().
title
,
'a task!'
)
assert
.
eql
(
Task
.
build
().
title
,
'a task!'
)
assert
.
eql
(
Task
.
build
().
foo
,
2
)
assert
.
eql
(
Task
.
build
().
foo
,
2
)
assert
.
eql
(
Task
.
build
().
bar
,
null
)
assert
.
eql
(
Task
.
build
().
bar
,
null
)
assert
.
eql
(
Task
.
build
().
foobar
,
'asd'
)
assert
.
eql
(
Task
.
build
().
foobar
,
'asd'
)
assert
.
eql
(
Task
.
build
().
flag
,
false
)
}
}
}
}
\ No newline at end of file
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