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 83558e4d
authored
May 16, 2015
by
Ruben Bridgewater
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Try to fix sqlite crash while parsing unique constraint errors. Fixes #3546
1 parent
642fbbd2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
8 deletions
changelog.md
lib/dialects/sqlite/query.js
test/integration/dialects/sqlite/dao.test.js
changelog.md
View file @
83558e4
# Next
# Next
-
[
BUG
]
fix showIndexQuery so appropriate indexes are returned when a schema is used
-
[
BUG
]
fix showIndexQuery so appropriate indexes are returned when a schema is used
-
[
BUG
]
Fix addIndexQuery error when the model has a schema
-
[
BUG
]
Fix addIndexQuery error when the model has a schema
-
[
BUG
]
Fix app crash in sqlite while running in special unique constraint errors
[
3730
](
https://github.com/sequelize/sequelize/pull/3730
)
# 2.1.3
# 2.1.3
-
[
BUG
]
Fix regression introduced in 2.1.2: updatedAt not set anymore
[
3667
](
https://github.com/sequelize/sequelize/pull/3667
)
-
[
BUG
]
Fix regression introduced in 2.1.2: updatedAt not set anymore
[
3667
](
https://github.com/sequelize/sequelize/pull/3667
)
...
...
lib/dialects/sqlite/query.js
View file @
83558e4
...
@@ -215,15 +215,17 @@ module.exports = (function() {
...
@@ -215,15 +215,17 @@ module.exports = (function() {
fields
.
forEach
(
function
(
field
)
{
fields
.
forEach
(
function
(
field
)
{
errors
.
push
(
new
sequelizeErrors
.
ValidationErrorItem
(
errors
.
push
(
new
sequelizeErrors
.
ValidationErrorItem
(
field
+
' must be unique'
,
'unique violation'
,
field
,
self
.
callee
[
field
]));
field
+
' must be unique'
,
'unique violation'
,
field
,
self
.
callee
&&
self
.
callee
[
field
]));
});
});
Utils
.
_
.
forOwn
(
this
.
callee
.
__options
.
uniqueKeys
,
function
(
constraint
)
{
if
(
this
.
callee
)
{
if
(
Utils
.
_
.
isEqual
(
constraint
.
fields
,
fields
)
&&
!!
constraint
.
msg
)
{
Utils
.
_
.
forOwn
(
this
.
callee
.
__options
.
uniqueKeys
,
function
(
constraint
)
{
message
=
constraint
.
msg
;
if
(
Utils
.
_
.
isEqual
(
constraint
.
fields
,
fields
)
&&
!!
constraint
.
msg
)
{
return
false
;
message
=
constraint
.
msg
;
}
return
false
;
});
}
});
}
return
new
sequelizeErrors
.
UniqueConstraintError
({
return
new
sequelizeErrors
.
UniqueConstraintError
({
message
:
message
,
message
:
message
,
...
...
test/integration/dialects/sqlite/dao.test.js
View file @
83558e4
...
@@ -33,5 +33,17 @@ if (dialect === 'sqlite') {
...
@@ -33,5 +33,17 @@ if (dialect === 'sqlite') {
});
});
});
});
});
});
describe
(
'regression tests'
,
function
()
{
it
(
'do not crash while parsing unique constraint errors'
,
function
()
{
var
Payments
=
this
.
sequelize
.
define
(
'payments'
,
{});
return
Payments
.
sync
({
force
:
true
}).
then
(
function
()
{
return
(
expect
(
Payments
.
bulkCreate
([{
id
:
1
},
{
id
:
1
}],
{
ignoreDuplicates
:
false
})).
to
.
eventually
.
be
.
rejected
);
});
});
});
});
});
}
}
\ 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