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 e6ad737e
authored
Aug 05, 2015
by
Sorin Neacsu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BelongsToMany.injectAttributes: replace model.init call with model.refreshAttributes
1 parent
892619e4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
1 deletions
lib/associations/belongs-to-many.js
test/unit/associations/belongs-to-many.test.js
lib/associations/belongs-to-many.js
View file @
e6ad737
...
@@ -376,7 +376,7 @@ BelongsToMany.prototype.injectAttributes = function() {
...
@@ -376,7 +376,7 @@ BelongsToMany.prototype.injectAttributes = function() {
this
.
paired
.
foreignIdentifierField
=
this
.
through
.
model
.
rawAttributes
[
this
.
paired
.
otherKey
].
field
||
this
.
paired
.
otherKey
;
this
.
paired
.
foreignIdentifierField
=
this
.
through
.
model
.
rawAttributes
[
this
.
paired
.
otherKey
].
field
||
this
.
paired
.
otherKey
;
}
}
this
.
through
.
model
.
init
(
this
.
through
.
model
.
modelManager
);
this
.
through
.
model
.
refreshAttributes
(
);
this
.
toSource
=
new
BelongsTo
(
this
.
through
.
model
,
this
.
source
,
{
this
.
toSource
=
new
BelongsTo
(
this
.
through
.
model
,
this
.
source
,
{
foreignKey
:
this
.
foreignKey
foreignKey
:
this
.
foreignKey
...
...
test/unit/associations/belongs-to-many.test.js
View file @
e6ad737
...
@@ -370,6 +370,28 @@ describe(Support.getTestDialectTeaser('belongsToMany'), function() {
...
@@ -370,6 +370,28 @@ describe(Support.getTestDialectTeaser('belongsToMany'), function() {
});
});
});
});
describe
(
'associations on the join table'
,
function
()
{
beforeEach
(
function
()
{
this
.
User
=
this
.
sequelize
.
define
(
'User'
,
{});
this
.
Project
=
this
.
sequelize
.
define
(
'Project'
,
{});
this
.
UserProjects
=
this
.
sequelize
.
define
(
'UserProjects'
,
{});
this
.
UserProjects
.
belongsTo
(
this
.
User
);
this
.
User
.
belongsToMany
(
this
.
Project
,
{
through
:
this
.
UserProjects
});
this
.
Project
.
belongsToMany
(
this
.
User
,
{
through
:
this
.
UserProjects
});
this
.
UserProjects
.
belongsTo
(
this
.
Project
);
});
it
(
'should work for belongsTo associations defined before belongsToMany'
,
function
()
{
expect
(
this
.
UserProjects
.
Instance
.
prototype
.
getUser
).
to
.
be
.
ok
;
});
it
(
'should work for belongsTo associations defined after belongsToMany'
,
function
()
{
expect
(
this
.
UserProjects
.
Instance
.
prototype
.
getProject
).
to
.
be
.
ok
;
});
});
describe
(
'self-associations'
,
function
()
{
describe
(
'self-associations'
,
function
()
{
it
(
'does not pair multiple self associations with different through arguments'
,
function
()
{
it
(
'does not pair multiple self associations with different through arguments'
,
function
()
{
var
User
=
current
.
define
(
'user'
,
{})
var
User
=
current
.
define
(
'user'
,
{})
...
...
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