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 ca2714e7
authored
Feb 13, 2015
by
Mick Hansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
deadlocking testcases for #3070
1 parent
3fd1f1f3
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
86 additions
and
2 deletions
lib/model.js
test/integration/model/create.test.js
lib/model.js
View file @
ca2714e
...
...
@@ -1125,12 +1125,13 @@ module.exports = (function() {
,
whereFields
,
defaultFields
;
queryOptions
=
queryOptions
?
Utils
.
_
.
clone
(
queryOptions
)
:
{};
if
(
!
options
||
!
options
.
where
)
{
throw
new
Error
(
'Missing where attribute in the options parameter passed to findOrCreate. Please note that the API has changed, and is now options (an object with where and defaults keys), queryOptions (transaction etc.)'
);
}
queryOptions
=
queryOptions
?
Utils
.
_
.
clone
(
queryOptions
)
:
{};
if
(
options
.
logging
)
queryOptions
.
logging
=
options
.
logging
;
whereFields
=
Object
.
keys
(
options
.
where
);
if
(
options
.
defaults
)
defaultFields
=
Object
.
keys
(
options
.
defaults
);
...
...
test/integration/model/create.test.js
View file @
ca2714e
...
...
@@ -108,6 +108,89 @@ describe(Support.getTestDialectTeaser('Model'), function() {
});
});
if
(
current
.
dialect
.
name
!==
'sequelize'
)
{
it
(
'should not deadlock with no existing entries and no outer transaction'
,
function
()
{
var
User
=
this
.
sequelize
.
define
(
'User'
,
{
email
:
{
type
:
DataTypes
.
STRING
,
unique
:
'company_user_email'
},
companyId
:
{
type
:
DataTypes
.
INTEGER
,
unique
:
'company_user_email'
}
});
return
User
.
sync
({
force
:
true
}).
then
(
function
()
{
return
Promise
.
map
(
_
.
range
(
50
),
function
(
i
)
{
return
User
.
findOrCreate
({
where
:
{
email
:
'unique.email.'
+
i
+
'@sequelizejs.com'
,
companyId
:
Math
.
floor
(
Math
.
random
()
*
5
)
}
});
});
});
});
it
(
'should not deadlock with existing entries and no outer transaction'
,
function
()
{
var
User
=
this
.
sequelize
.
define
(
'User'
,
{
email
:
{
type
:
DataTypes
.
STRING
,
unique
:
'company_user_email'
},
companyId
:
{
type
:
DataTypes
.
INTEGER
,
unique
:
'company_user_email'
}
});
return
User
.
sync
({
force
:
true
}).
then
(
function
()
{
return
Promise
.
map
(
_
.
range
(
50
),
function
(
i
)
{
return
User
.
findOrCreate
({
where
:
{
email
:
'unique.email.'
+
i
+
'@sequelizejs.com'
,
companyId
:
2
}
});
}).
then
(
function
()
{
return
Promise
.
map
(
_
.
range
(
50
),
function
(
i
)
{
return
User
.
findOrCreate
({
where
:
{
email
:
'unique.email.'
+
i
+
'@sequelizejs.com'
,
companyId
:
2
}
});
});
});
});
});
it
(
'should not deadlock with concurrency duplicate entries and no outer transaction'
,
function
()
{
var
User
=
this
.
sequelize
.
define
(
'User'
,
{
email
:
{
type
:
DataTypes
.
STRING
,
unique
:
'company_user_email'
},
companyId
:
{
type
:
DataTypes
.
INTEGER
,
unique
:
'company_user_email'
}
});
return
User
.
sync
({
force
:
true
}).
then
(
function
()
{
return
Promise
.
map
(
_
.
range
(
50
),
function
(
i
)
{
return
User
.
findOrCreate
({
where
:
{
email
:
'unique.email.1@sequelizejs.com'
,
companyId
:
2
}
});
});
});
});
}
it
(
'should support special characters in defaults'
,
function
()
{
var
User
=
this
.
sequelize
.
define
(
'user'
,
{
objectId
:
{
...
...
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