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 aa2d6093
authored
Jul 01, 2012
by
sdepold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed removal of unused reference attribute
1 parent
3389cc74
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
3 deletions
lib/associations/has-many.js
spec/associations/has-many.spec.js
lib/associations/has-many.js
View file @
aa2d609
...
@@ -10,12 +10,13 @@ module.exports = (function() {
...
@@ -10,12 +10,13 @@ module.exports = (function() {
this
.
target
=
targetDAO
this
.
target
=
targetDAO
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
.
associationAccessor
=
this
.
combinedName
=
this
.
options
.
joinTableName
||
Utils
.
combineTableNames
(
var
combinedTableName
=
Utils
.
combineTableNames
(
this
.
source
.
tableName
,
this
.
source
.
tableName
,
this
.
isSelfAssociation
?
(
this
.
options
.
as
||
this
.
target
.
tableName
)
:
this
.
target
.
tableName
this
.
isSelfAssociation
?
(
this
.
options
.
as
||
this
.
target
.
tableName
)
:
this
.
target
.
tableName
)
)
this
.
associationAccessor
=
this
.
combinedName
=
(
this
.
options
.
joinTableName
||
combinedTableName
)
var
as
=
(
this
.
options
.
as
||
Utils
.
pluralize
(
this
.
target
.
tableName
))
var
as
=
(
this
.
options
.
as
||
Utils
.
pluralize
(
this
.
target
.
tableName
))
...
@@ -43,7 +44,7 @@ module.exports = (function() {
...
@@ -43,7 +44,7 @@ module.exports = (function() {
this
.
foreignIdentifier
=
Utils
.
_
.
underscoredIf
((
this
.
options
.
as
||
this
.
target
.
tableName
)
+
'Id'
,
this
.
options
.
underscored
)
this
.
foreignIdentifier
=
Utils
.
_
.
underscoredIf
((
this
.
options
.
as
||
this
.
target
.
tableName
)
+
'Id'
,
this
.
options
.
underscored
)
}
else
{
}
else
{
this
.
foreignIdentifier
=
this
.
target
.
associations
[
this
.
associationAccessor
].
identifier
this
.
foreignIdentifier
=
this
.
target
.
associations
[
this
.
associationAccessor
].
identifier
delete
this
.
source
.
a
ttributes
[
this
.
foreignIdentifier
]
delete
this
.
source
.
rawA
ttributes
[
this
.
foreignIdentifier
]
}
}
// define a new model, which connects the models
// define a new model, which connects the models
...
...
spec/associations/has-many.spec.js
View file @
aa2d609
...
@@ -122,5 +122,18 @@ describe('Associations', function() {
...
@@ -122,5 +122,18 @@ describe('Associations', function() {
})
})
})
})
})
})
describe
(
'many to many'
,
function
()
{
it
(
"removes the reference id, which was added in the first place"
,
function
()
{
var
User
=
sequelize
.
define
(
'User'
,
{
username
:
Sequelize
.
STRING
})
,
Task
=
sequelize
.
define
(
'Task'
,
{
title
:
Sequelize
.
STRING
})
User
.
hasMany
(
Task
)
expect
(
Task
.
attributes
.
UserId
).
toBeDefined
()
Task
.
hasMany
(
User
)
expect
(
Task
.
attributes
.
UserId
).
not
.
toBeDefined
()
})
})
})
})
})
})
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