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 314d21ea
authored
Oct 19, 2014
by
Mick Hansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(associations): regression in hasMany pairing introduced with through scopes, fixes #2316
1 parent
e63af574
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
8 deletions
lib/associations/has-many.js
test/associations/has-many.test.js
lib/associations/has-many.js
View file @
314d21e
...
...
@@ -106,10 +106,10 @@ module.exports = (function() {
}
// If through is not default, determine pairing by through value (model/string)
else
{
paired
=
self
.
options
.
through
===
association
.
options
.
through
||
self
.
options
.
through
===
(
association
.
options
.
through
&&
association
.
options
.
through
.
model
)
||
(
self
.
options
.
through
&&
self
.
options
.
through
.
model
)
===
(
association
.
options
.
through
&&
association
.
options
.
through
.
model
)
||
(
self
.
options
.
through
&&
self
.
options
.
through
.
model
)
===
association
.
options
.
through
;
paired
=
(
self
.
options
.
through
===
association
.
options
.
through
)
||
(
self
.
options
.
through
===
association
.
options
.
through
.
model
)
||
(
self
.
options
.
through
.
model
&&
association
.
options
.
through
.
model
&&
(
self
.
options
.
through
.
model
===
association
.
options
.
through
.
model
)
)
||
(
self
.
options
.
through
.
model
===
association
.
options
.
through
)
;
}
// If paired, set properties identifying both associations as double linked, and allow them to each eachtoerh
if
(
paired
)
{
...
...
@@ -294,7 +294,6 @@ module.exports = (function() {
if
(
this
.
targetAssociation
.
foreignIdentifier
)
{
this
.
targetAssociation
.
foreignIdentifierField
=
this
.
through
.
model
.
rawAttributes
[
this
.
targetAssociation
.
foreignIdentifier
].
field
||
this
.
targetAssociation
.
foreignIdentifier
;
}
this
.
through
.
model
.
init
(
this
.
through
.
model
.
daoFactoryManager
);
}
else
{
var
newAttributes
=
{};
...
...
test/associations/has-many.test.js
View file @
314d21e
...
...
@@ -2089,16 +2089,20 @@ describe(Support.getTestDialectTeaser("HasMany"), function() {
describe
(
'project has owners and users and owners and users have projects'
,
function
()
{
beforeEach
(
function
()
{
this
.
Project
.
hasMany
(
this
.
User
,
{
as
:
'owners'
,
through
:
'projectOwners'
});
this
.
Project
.
hasMany
(
this
.
User
,
{
as
:
'users'
,
through
:
'projectUsers'
});
this
.
User
.
hasMany
(
this
.
Project
,
{
as
:
'owne
r
s'
,
through
:
'projectOwners'
});
this
.
User
.
hasMany
(
this
.
User
,
{
as
:
'user
s'
,
through
:
'projectUsers'
});
this
.
User
.
hasMany
(
this
.
Project
,
{
as
:
'owne
dProject
s'
,
through
:
'projectOwners'
});
this
.
User
.
hasMany
(
this
.
Project
,
{
as
:
'memberProject
s'
,
through
:
'projectUsers'
});
return
this
.
sequelize
.
sync
({
force
:
true
});
});
it
(
'correctly pairs associations'
,
function
()
{
expect
(
this
.
Project
.
associations
.
owners
.
targetAssociation
).
to
.
equal
(
this
.
User
.
associations
.
ownedProjects
);
expect
(
this
.
Project
.
associations
.
users
.
targetAssociation
).
to
.
equal
(
this
.
User
.
associations
.
memberProjects
);
});
it
(
'correctly sets user and owner'
,
function
()
{
var
self
=
this
;
...
...
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