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 82cf3572
authored
Apr 15, 2014
by
Mick Hansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(hasMany): make sure the getter called by the setters use the transaction
1 parent
a30588aa
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
4 deletions
lib/associations/has-many.js
lib/associations/has-many.js
View file @
82cf357
...
...
@@ -309,7 +309,9 @@ module.exports = (function() {
// define the returned customEventEmitter, which will emit the success event once everything is done
return
new
Utils
.
CustomEventEmitter
(
function
(
emitter
)
{
instance
[
self
.
accessors
.
get
]()
instance
[
self
.
accessors
.
get
]({
transaction
:
(
defaultAttributes
||
{}).
transaction
})
.
success
(
function
(
oldAssociatedObjects
)
{
var
Class
=
Object
(
self
.
through
)
===
self
.
through
?
HasManyDoubleLinked
:
HasManySingleLinked
new
Class
(
self
,
instance
).
injectSetter
(
emitter
,
oldAssociatedObjects
,
newAssociatedObjects
,
defaultAttributes
)
...
...
@@ -324,7 +326,10 @@ module.exports = (function() {
,
where
=
new
Utils
.
where
(
self
.
target
.
rawAttributes
[
primaryKey
],
newInstance
[
primaryKey
])
return
new
Utils
.
CustomEventEmitter
(
function
(
emitter
)
{
instance
[
self
.
accessors
.
get
]({
where
:
where
})
instance
[
self
.
accessors
.
get
]({
where
:
where
,
transaction
:
(
additionalAttributes
||
{}).
transaction
})
.
proxy
(
emitter
,
{
events
:
[
'error'
,
'sql'
]})
.
success
(
function
(
currentAssociatedObjects
)
{
if
(
currentAssociatedObjects
.
length
===
0
||
Object
(
self
.
through
)
===
self
.
through
)
{
...
...
@@ -337,10 +342,12 @@ module.exports = (function() {
}).
run
()
}
obj
[
this
.
accessors
.
remove
]
=
function
(
oldAssociatedObject
)
{
obj
[
this
.
accessors
.
remove
]
=
function
(
oldAssociatedObject
,
options
)
{
var
instance
=
this
return
new
Utils
.
CustomEventEmitter
(
function
(
emitter
)
{
instance
[
self
.
accessors
.
get
]().
success
(
function
(
currentAssociatedObjects
)
{
instance
[
self
.
accessors
.
get
]({
transaction
:
(
options
||
{}).
transaction
}).
success
(
function
(
currentAssociatedObjects
)
{
var
newAssociations
=
[]
,
oldAssociations
=
[]
...
...
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