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 9a9f2c18
authored
Aug 20, 2014
by
Jan Aagaard Meier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix a belongsTo + hasMany relation incorrectly being identified as n:m. Closes #2159
1 parent
fe9fdc94
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
5 deletions
lib/associations/has-many.js
lib/associations/has-many.js
View file @
9a9f2c1
...
...
@@ -69,7 +69,7 @@ module.exports = (function() {
*/
else
if
(
this
.
through
)
{
_
.
each
(
this
.
target
.
associations
,
function
(
association
,
accessor
)
{
if
(
self
.
source
===
association
.
target
)
{
if
(
self
.
source
===
association
.
target
&&
association
.
associationType
===
'HasMany'
)
{
var
paired
=
false
// If through is default, we determine pairing by the accesor value (i.e. DAOFactory's using as won't pair, but regular ones will)
...
...
@@ -116,9 +116,9 @@ module.exports = (function() {
if
(
this
.
as
)
{
this
.
isAliased
=
true
}
else
{
this
.
as
=
(
this
.
options
.
freezeAssociations
?
this
.
target
.
tableName
:
Utils
.
pluralize
(
this
.
target
.
tableName
,
this
.
target
.
options
.
language
));
this
.
as
=
(
this
.
options
.
freezeAssociations
?
this
.
target
.
tableName
:
Utils
.
pluralize
(
this
.
target
.
tableName
,
this
.
target
.
options
.
language
));
}
this
.
accessors
=
{
get
:
Utils
.
_
.
camelize
(
'get_'
+
this
.
as
),
set
:
Utils
.
_
.
camelize
(
'set_'
+
this
.
as
),
...
...
@@ -172,11 +172,11 @@ module.exports = (function() {
var
sourceKeyType
=
((
!
this
.
source
.
hasPrimaryKeys
||
sourceKeys
.
length
!==
1
)
?
DataTypes
.
INTEGER
:
this
.
source
.
rawAttributes
[
sourceKeys
[
0
]].
type
)
var
targetKeys
=
Object
.
keys
(
this
.
target
.
primaryKeys
);
var
targetKeyType
=
((
!
this
.
target
.
hasPrimaryKeys
||
targetKeys
.
length
!==
1
)
?
DataTypes
.
INTEGER
:
this
.
target
.
rawAttributes
[
targetKeys
[
0
]].
type
)
if
(
primaryKeyDeleted
)
{
combinedTableAttributes
[
this
.
identifier
]
=
{
type
:
sourceKeyType
,
primaryKey
:
true
}
combinedTableAttributes
[
this
.
foreignIdentifier
]
=
{
type
:
targetKeyType
,
primaryKey
:
true
}
}
else
{
}
else
{
var
uniqueKey
=
[
this
.
through
.
tableName
,
this
.
identifier
,
this
.
foreignIdentifier
,
'unique'
].
join
(
'_'
)
combinedTableAttributes
[
this
.
identifier
]
=
{
type
:
sourceKeyType
,
unique
:
uniqueKey
}
combinedTableAttributes
[
this
.
foreignIdentifier
]
=
{
type
:
targetKeyType
,
unique
:
uniqueKey
}
...
...
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