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 fc27da44
authored
Sep 03, 2013
by
Jan Aagaard Meier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slight variable renaming
1 parent
02975518
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
14 deletions
lib/associations/has-many-double-linked.js
lib/associations/has-many.js
lib/associations/has-many-double-linked.js
View file @
fc27da4
...
@@ -33,7 +33,7 @@ module.exports = (function() {
...
@@ -33,7 +33,7 @@ module.exports = (function() {
where
[
connectorDAO
.
tableName
+
"."
+
foreignKey
]
=
{
join
:
self
.
__factory
.
target
.
tableName
+
"."
+
foreignPrimary
}
where
[
connectorDAO
.
tableName
+
"."
+
foreignKey
]
=
{
join
:
self
.
__factory
.
target
.
tableName
+
"."
+
foreignPrimary
}
if
(
association
.
custom
JoinTableModel
)
{
if
(
association
.
has
JoinTableModel
)
{
queryOptions
.
hasJoinTableModel
=
true
queryOptions
.
hasJoinTableModel
=
true
queryOptions
.
joinTableModel
=
connectorDAO
queryOptions
.
joinTableModel
=
connectorDAO
...
@@ -111,7 +111,7 @@ module.exports = (function() {
...
@@ -111,7 +111,7 @@ module.exports = (function() {
if
(
!
newObj
)
{
if
(
!
newObj
)
{
obsoleteAssociations
.
push
(
old
)
obsoleteAssociations
.
push
(
old
)
}
else
if
(
association
.
custom
JoinTableModel
)
{
}
else
if
(
association
.
has
JoinTableModel
)
{
var
changedAssociation
=
{
var
changedAssociation
=
{
where
:
{},
where
:
{},
attributes
:
Utils
.
_
.
defaults
({},
newObj
[
self
.
__factory
.
connectorDAO
.
name
],
defaultAttributes
)
attributes
:
Utils
.
_
.
defaults
({},
newObj
[
self
.
__factory
.
connectorDAO
.
name
],
defaultAttributes
)
...
@@ -142,14 +142,10 @@ module.exports = (function() {
...
@@ -142,14 +142,10 @@ module.exports = (function() {
attributes
[
self
.
__factory
.
identifier
]
=
((
sourceKeys
.
length
===
1
)
?
self
.
instance
[
sourceKeys
[
0
]]
:
self
.
instance
.
id
)
attributes
[
self
.
__factory
.
identifier
]
=
((
sourceKeys
.
length
===
1
)
?
self
.
instance
[
sourceKeys
[
0
]]
:
self
.
instance
.
id
)
attributes
[
foreignIdentifier
]
=
((
targetKeys
.
length
===
1
)
?
unassociatedObject
[
targetKeys
[
0
]]
:
unassociatedObject
.
id
)
attributes
[
foreignIdentifier
]
=
((
targetKeys
.
length
===
1
)
?
unassociatedObject
[
targetKeys
[
0
]]
:
unassociatedObject
.
id
)
if
(
association
.
custom
JoinTableModel
)
{
if
(
association
.
has
JoinTableModel
)
{
attributes
=
Utils
.
_
.
defaults
(
attributes
,
unassociatedObject
[
association
.
connectorDAO
.
name
],
defaultAttributes
)
attributes
=
Utils
.
_
.
defaults
(
attributes
,
unassociatedObject
[
association
.
connectorDAO
.
name
],
defaultAttributes
)
}
}
if
(
association
.
customJoinTableModel
)
{
attributes
=
Utils
.
_
.
defaults
(
attributes
,
unassociatedObject
[
association
.
connectorDAO
.
name
],
defaultAttributes
)
}
return
attributes
return
attributes
})
})
...
@@ -180,13 +176,13 @@ module.exports = (function() {
...
@@ -180,13 +176,13 @@ module.exports = (function() {
attributes
[
this
.
__factory
.
identifier
]
=
((
sourceKeys
.
length
===
1
)
?
this
.
instance
[
sourceKeys
[
0
]]
:
this
.
instance
.
id
)
attributes
[
this
.
__factory
.
identifier
]
=
((
sourceKeys
.
length
===
1
)
?
this
.
instance
[
sourceKeys
[
0
]]
:
this
.
instance
.
id
)
attributes
[
foreignIdentifier
]
=
((
targetKeys
.
length
===
1
)
?
newAssociation
[
targetKeys
[
0
]]
:
newAssociation
.
id
)
attributes
[
foreignIdentifier
]
=
((
targetKeys
.
length
===
1
)
?
newAssociation
[
targetKeys
[
0
]]
:
newAssociation
.
id
)
if
(
exists
)
{
// implies
custom
JoinTableModel === true
if
(
exists
)
{
// implies
has
JoinTableModel === true
var
where
=
attributes
var
where
=
attributes
attributes
=
Utils
.
_
.
defaults
({},
newAssociation
[
association
.
connectorDAO
.
name
],
additionalAttributes
)
attributes
=
Utils
.
_
.
defaults
({},
newAssociation
[
association
.
connectorDAO
.
name
],
additionalAttributes
)
association
.
connectorDAO
.
update
(
attributes
,
where
).
proxy
(
emitterProxy
)
association
.
connectorDAO
.
update
(
attributes
,
where
).
proxy
(
emitterProxy
)
}
else
{
}
else
{
if
(
association
.
custom
JoinTableModel
===
true
)
{
if
(
association
.
has
JoinTableModel
===
true
)
{
attributes
=
Utils
.
_
.
defaults
(
attributes
,
newAssociation
[
association
.
connectorDAO
.
name
],
additionalAttributes
)
attributes
=
Utils
.
_
.
defaults
(
attributes
,
newAssociation
[
association
.
connectorDAO
.
name
],
additionalAttributes
)
}
}
...
...
lib/associations/has-many.js
View file @
fc27da4
...
@@ -13,10 +13,10 @@ module.exports = (function() {
...
@@ -13,10 +13,10 @@ module.exports = (function() {
this
.
options
=
options
this
.
options
=
options
this
.
useJunctionTable
=
this
.
options
.
useJunctionTable
===
undefined
?
true
:
this
.
options
.
useJunctionTable
this
.
useJunctionTable
=
this
.
options
.
useJunctionTable
===
undefined
?
true
:
this
.
options
.
useJunctionTable
this
.
isSelfAssociation
=
(
this
.
source
.
tableName
===
this
.
target
.
tableName
)
this
.
isSelfAssociation
=
(
this
.
source
.
tableName
===
this
.
target
.
tableName
)
this
.
custom
JoinTableModel
=
!!
this
.
options
.
joinTableModel
this
.
has
JoinTableModel
=
!!
this
.
options
.
joinTableModel
var
combinedTableName
;
var
combinedTableName
;
if
(
this
.
custom
JoinTableModel
)
{
if
(
this
.
has
JoinTableModel
)
{
combinedTableName
=
this
.
options
.
joinTableModel
.
tableName
combinedTableName
=
this
.
options
.
joinTableModel
.
tableName
}
else
if
(
this
.
options
.
joinTableName
)
{
}
else
if
(
this
.
options
.
joinTableName
)
{
combinedTableName
=
this
.
options
.
joinTableName
combinedTableName
=
this
.
options
.
joinTableName
...
@@ -68,7 +68,7 @@ module.exports = (function() {
...
@@ -68,7 +68,7 @@ module.exports = (function() {
combinedTableAttributes
[
this
.
identifier
]
=
{
type
:
sourceKeyType
,
primaryKey
:
true
}
combinedTableAttributes
[
this
.
identifier
]
=
{
type
:
sourceKeyType
,
primaryKey
:
true
}
combinedTableAttributes
[
this
.
foreignIdentifier
]
=
{
type
:
targetKeyType
,
primaryKey
:
true
}
combinedTableAttributes
[
this
.
foreignIdentifier
]
=
{
type
:
targetKeyType
,
primaryKey
:
true
}
if
(
this
.
custom
JoinTableModel
===
true
)
{
if
(
this
.
has
JoinTableModel
===
true
)
{
this
.
connectorDAO
=
this
.
options
.
joinTableModel
this
.
connectorDAO
=
this
.
options
.
joinTableModel
this
.
connectorDAO
.
rawAttributes
=
Utils
.
_
.
merge
(
this
.
connectorDAO
.
rawAttributes
,
combinedTableAttributes
)
this
.
connectorDAO
.
rawAttributes
=
Utils
.
_
.
merge
(
this
.
connectorDAO
.
rawAttributes
,
combinedTableAttributes
)
...
@@ -187,7 +187,7 @@ module.exports = (function() {
...
@@ -187,7 +187,7 @@ module.exports = (function() {
instance
[
self
.
accessors
.
get
]({
where
:
where
})
instance
[
self
.
accessors
.
get
]({
where
:
where
})
.
error
(
function
(
err
){
emitter
.
emit
(
'error'
,
err
)})
.
error
(
function
(
err
){
emitter
.
emit
(
'error'
,
err
)})
.
success
(
function
(
currentAssociatedObjects
)
{
.
success
(
function
(
currentAssociatedObjects
)
{
if
(
currentAssociatedObjects
.
length
===
0
||
self
.
custom
JoinTableModel
===
true
)
{
if
(
currentAssociatedObjects
.
length
===
0
||
self
.
has
JoinTableModel
===
true
)
{
var
Class
=
self
.
connectorDAO
?
HasManyMultiLinked
:
HasManySingleLinked
var
Class
=
self
.
connectorDAO
?
HasManyMultiLinked
:
HasManySingleLinked
new
Class
(
self
,
instance
).
injectAdder
(
emitter
,
newAssociatedObject
,
additionalAttributes
,
!!
currentAssociatedObjects
.
length
)
new
Class
(
self
,
instance
).
injectAdder
(
emitter
,
newAssociatedObject
,
additionalAttributes
,
!!
currentAssociatedObjects
.
length
)
}
else
{
}
else
{
...
...
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