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 6b0da508
authored
Sep 18, 2014
by
Jan Aagaard Meier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fingers crossed that the findOrCreate without transaction test is now fixed
1 parent
6343ed2f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
12 deletions
lib/model.js
test/dao-factory/create.test.js
lib/model.js
View file @
6b0da50
...
...
@@ -1770,7 +1770,7 @@ module.exports = (function() {
if
(
include
.
association
.
through
&&
Object
(
include
.
association
.
through
.
model
)
===
include
.
association
.
through
.
model
)
{
if
(
!
include
.
include
)
include
.
include
=
[];
var
through
=
include
.
association
.
through
;
include
.
through
=
Utils
.
_
.
defaults
(
include
.
through
||
{},
{
model
:
through
.
model
,
as
:
Utils
.
singularize
(
through
.
model
.
tableName
),
...
...
@@ -1913,7 +1913,7 @@ module.exports = (function() {
(
elem
.
_isSequelizeMethod
||
elem
instanceof
Model
||
elem
instanceof
Transaction
||
elem
instanceof
Transaction
||
elem
instanceof
Association
)
)
{
...
...
test/dao-factory/create.test.js
View file @
6b0da50
...
...
@@ -168,13 +168,17 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
this
.
User
.
findOrCreate
({
where
:
{
uniqueName
:
'winner'
}},
{
transaction
:
transaction
}),
this
.
User
.
findOrCreate
({
where
:
{
uniqueName
:
'winner'
}},
{
transaction
:
transaction
}),
function
(
first
,
second
)
{
var
firstInstance
=
first
[
0
]
,
firstCreated
=
first
[
1
]
,
secondInstance
=
second
[
0
]
,
secondCreated
=
second
[
1
];
expect
(
first
[
0
]
).
to
.
be
.
ok
;
expect
(
first
[
1
]
).
to
.
be
.
ok
;
expect
(
second
[
0
]
).
to
.
be
.
ok
;
expect
(
second
[
1
]
).
not
.
to
.
be
.
ok
;
expect
(
first
Instance
).
to
.
be
.
ok
;
expect
(
first
Created
).
to
.
be
.
ok
;
expect
(
second
Instance
).
to
.
be
.
ok
;
expect
(
second
Created
).
not
.
to
.
be
.
ok
;
expect
(
first
[
0
].
id
).
to
.
equal
(
second
[
0
]
.
id
);
expect
(
first
Instance
.
id
).
to
.
equal
(
secondInstance
.
id
);
return
transaction
.
commit
();
}
...
...
@@ -188,12 +192,18 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
this
.
User
.
findOrCreate
({
where
:
{
uniqueName
:
'winner'
}}),
this
.
User
.
findOrCreate
({
where
:
{
uniqueName
:
'winner'
}}),
function
(
first
,
second
)
{
expect
(
first
[
0
]).
to
.
be
.
ok
;
expect
(
first
[
1
]).
to
.
be
.
ok
;
expect
(
second
[
0
]).
to
.
be
.
ok
;
expect
(
second
[
1
]).
not
.
to
.
be
.
ok
;
var
firstInstance
=
first
[
0
]
,
firstCreated
=
first
[
1
]
,
secondInstance
=
second
[
0
]
,
secondCreated
=
second
[
1
]
;
expect
(
first
[
0
].
id
).
to
.
equal
(
second
[
0
].
id
);
// Depending on execution order and MAGIC either the first OR the second call should return true
expect
(
firstCreated
?
!
secondCreated
:
secondCreated
).
to
.
be
.
ok
// XOR
expect
(
firstInstance
).
to
.
be
.
ok
;
expect
(
secondInstance
).
to
.
be
.
ok
;
expect
(
firstInstance
.
id
).
to
.
equal
(
secondInstance
.
id
);
}
);
});
...
...
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