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 15f16c40
authored
Aug 18, 2016
by
Jan Aagaard Meier
Committed by
GitHub
Aug 18, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(uniqueConstraintError): Add parent, original and sql properties, similar to …
…other DB errors (#6462)
1 parent
adec7184
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
0 deletions
changelog.md
lib/errors.js
test/integration/error.test.js
changelog.md
View file @
15f16c4
# Next
-
[
FIXED
]
Add
`parent`
,
`original`
and
`sql`
properties to
`UniqueConstraintError`
# 3.24.0
# 3.24.0
-
[
ADDED
]
`restartIdentity`
option for truncate in postgres
[
#5356
](
https://github.com/sequelize/sequelize/issues/5356
)
-
[
ADDED
]
`restartIdentity`
option for truncate in postgres
[
#5356
](
https://github.com/sequelize/sequelize/issues/5356
)
...
...
lib/errors.js
View file @
15f16c4
...
@@ -146,6 +146,9 @@ error.UniqueConstraintError = function (options) {
...
@@ -146,6 +146,9 @@ error.UniqueConstraintError = function (options) {
this
.
message
=
options
.
message
;
this
.
message
=
options
.
message
;
this
.
errors
=
options
.
errors
;
this
.
errors
=
options
.
errors
;
this
.
fields
=
options
.
fields
;
this
.
fields
=
options
.
fields
;
this
.
parent
=
options
.
parent
;
this
.
original
=
options
.
parent
;
this
.
sql
=
options
.
parent
.
sql
;
};
};
util
.
inherits
(
error
.
UniqueConstraintError
,
error
.
ValidationError
);
util
.
inherits
(
error
.
UniqueConstraintError
,
error
.
ValidationError
);
...
...
test/integration/error.test.js
View file @
15f16c4
...
@@ -244,5 +244,25 @@ describe(Support.getTestDialectTeaser('Sequelize Errors'), function () {
...
@@ -244,5 +244,25 @@ describe(Support.getTestDialectTeaser('Sequelize Errors'), function () {
return
expect
(
this
.
sequelize
.
query
(
'INSERT INTO users (name) VALUES (\'jan\')'
)).
to
.
be
.
rejectedWith
(
this
.
sequelize
.
UniqueConstraintError
);
return
expect
(
this
.
sequelize
.
query
(
'INSERT INTO users (name) VALUES (\'jan\')'
)).
to
.
be
.
rejectedWith
(
this
.
sequelize
.
UniqueConstraintError
);
});
});
});
});
it
(
'adds parent and sql properties'
,
function
()
{
var
User
=
this
.
sequelize
.
define
(
'user'
,
{
name
:
{
type
:
Sequelize
.
STRING
,
unique
:
'unique'
,
}
},
{
timestamps
:
false
});
return
this
.
sequelize
.
sync
({
force
:
true
}).
bind
(
this
).
then
(
function
()
{
return
User
.
create
({
name
:
'jan'
});
}).
then
(
function
()
{
return
expect
(
User
.
create
({
name
:
'jan'
})).
to
.
be
.
rejected
;
}).
then
(
function
(
error
)
{
expect
(
error
).
to
.
be
.
instanceOf
(
this
.
sequelize
.
UniqueConstraintError
);
expect
(
error
).
to
.
have
.
property
(
'parent'
);
expect
(
error
).
to
.
have
.
property
(
'original'
);
expect
(
error
).
to
.
have
.
property
(
'sql'
);
});
});
});
});
});
});
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