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 e329f903
authored
Mar 10, 2014
by
Thanasis Polychronakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix DAO-create tests with new validation expectations
1 parent
31c340bd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
19 deletions
lib/dao-validator.js
test/dao-factory/create.test.js
lib/dao-validator.js
View file @
e329f90
...
...
@@ -361,7 +361,7 @@ DaoValidator.prototype._validateSchema = function(rawAttribute,
var
error
=
new
sequelizeError
.
ValidationError
(
field
+
' cannot be null'
)
error
.
path
=
field
error
.
value
=
value
error
.
type
=
'notNull Violation'
error
.
type
=
error
.
message
=
'notNull Violation'
if
(
!
this
.
errors
.
hasOwnProperty
(
field
))
{
this
.
errors
[
field
]
=
[];
}
...
...
test/dao-factory/create.test.js
View file @
e329f90
...
...
@@ -376,32 +376,42 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
UserNull
.
create
({
username
:
'foo2'
,
smth
:
null
}).
error
(
function
(
err
)
{
expect
(
err
).
to
.
exist
expect
(
err
.
smth
[
0
].
path
).
to
.
equal
(
'smth'
);
if
(
Support
.
dialectIsMySQL
())
{
// We need to allow two different errors for MySQL, see:
// http://dev.mysql.com/doc/refman/5.0/en/server-sql-mode.html#sqlmode_strict_trans_tables
expect
(
err
.
message
).
to
.
match
(
/
(
Column 'smth' cannot be null|Field 'smth' doesn't have a default value
)
/
)
expect
(
err
.
smth
[
0
].
message
).
to
.
match
(
/notNull Violation
/
)
}
else
if
(
dialect
===
"sqlite"
)
{
expect
(
err
.
message
).
to
.
match
(
/.*SQLITE_CONSTRAINT.*
/
)
expect
(
err
.
smth
[
0
].
message
).
to
.
match
(
/notNull Violation
/
)
}
else
{
expect
(
err
.
message
).
to
.
match
(
/.*column "smth" violates not-null.*
/
)
expect
(
err
.
smth
[
0
].
message
).
to
.
match
(
/notNull Violation
/
)
}
done
()
})
})
})
it
(
"raises an error if created object breaks definition contraints"
,
function
(
done
)
{
var
UserNull
=
this
.
sequelize
.
define
(
'UserWithNonNullSmth'
,
{
username
:
{
type
:
Sequelize
.
STRING
,
unique
:
true
},
smth
:
{
type
:
Sequelize
.
STRING
,
allowNull
:
false
}
})
UserNull
.
create
({
username
:
'foo'
,
smth
:
'foo'
}).
success
(
function
()
{
UserNull
.
create
({
username
:
'foo'
,
smth
:
'bar'
}).
error
(
function
(
err
)
{
expect
(
err
).
to
.
exist
if
(
dialect
===
"sqlite"
)
{
expect
(
err
.
message
).
to
.
match
(
/.*SQLITE_CONSTRAINT.*/
)
}
else
if
(
Support
.
dialectIsMySQL
())
{
expect
(
err
.
message
).
to
.
match
(
/Duplicate entry 'foo' for key 'username'/
)
}
else
{
expect
(
err
.
message
).
to
.
match
(
/.*duplicate key value violates unique constraint.*/
)
}
this
.
sequelize
.
options
.
omitNull
=
false
done
()
})
UserNull
.
sync
({
force
:
true
}).
success
(
function
()
{
UserNull
.
create
({
username
:
'foo'
,
smth
:
'foo'
}).
success
(
function
()
{
UserNull
.
create
({
username
:
'foo'
,
smth
:
'bar'
}).
error
(
function
(
err
)
{
expect
(
err
).
to
.
exist
if
(
dialect
===
"sqlite"
)
{
expect
(
err
.
message
).
to
.
match
(
/.*SQLITE_CONSTRAINT.*/
)
}
else
if
(
Support
.
dialectIsMySQL
())
{
expect
(
err
.
message
).
to
.
match
(
/Duplicate entry 'foo' for key 'username'/
)
}
else
{
expect
(
err
.
message
).
to
.
match
(
/.*duplicate key value violates unique constraint.*/
)
}
done
()
})
})
})
...
...
@@ -940,7 +950,7 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
})
})
it
.
only
(
'emits an error when validate is set to true'
,
function
(
done
)
{
it
(
'emits an error when validate is set to true'
,
function
(
done
)
{
var
Tasks
=
this
.
sequelize
.
define
(
'Task'
,
{
name
:
{
type
:
Sequelize
.
STRING
,
...
...
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