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 88a8a941
authored
Aug 12, 2015
by
Jan Aagaard Meier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug(scopes) Fix defaultScope being inherited from parent to through model. Closes #4300
1 parent
b17f57ac
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
1 deletions
lib/associations/mixin.js
test/unit/associations/belongs-to-many.test.js
lib/associations/mixin.js
View file @
88a8a94
...
@@ -292,7 +292,7 @@ Mixin.belongsToMany = function(targetModel, options) { // testhint options:none
...
@@ -292,7 +292,7 @@ Mixin.belongsToMany = function(targetModel, options) { // testhint options:none
options
.
hooks
=
options
.
hooks
===
undefined
?
false
:
Boolean
(
options
.
hooks
);
options
.
hooks
=
options
.
hooks
===
undefined
?
false
:
Boolean
(
options
.
hooks
);
options
.
useHooks
=
options
.
hooks
;
options
.
useHooks
=
options
.
hooks
;
options
.
timestamps
=
options
.
timestamps
===
undefined
?
this
.
sequelize
.
options
.
timestamps
:
options
.
timestamps
;
options
.
timestamps
=
options
.
timestamps
===
undefined
?
this
.
sequelize
.
options
.
timestamps
:
options
.
timestamps
;
options
=
_
.
extend
(
options
,
_
.
omit
(
sourceModel
.
options
,
[
'hooks'
,
'timestamps'
]));
options
=
_
.
extend
(
options
,
_
.
omit
(
sourceModel
.
options
,
[
'hooks'
,
'timestamps'
,
'scopes'
,
'defaultScope'
]));
// the id is in the foreign table or in a connecting table
// the id is in the foreign table or in a connecting table
var
association
=
new
BelongsToMany
(
sourceModel
,
targetModel
,
options
);
var
association
=
new
BelongsToMany
(
sourceModel
,
targetModel
,
options
);
...
...
test/unit/associations/belongs-to-many.test.js
View file @
88a8a94
...
@@ -14,6 +14,32 @@ var chai = require('chai')
...
@@ -14,6 +14,32 @@ var chai = require('chai')
,
Promise
=
current
.
Promise
;
,
Promise
=
current
.
Promise
;
describe
(
Support
.
getTestDialectTeaser
(
'belongsToMany'
),
function
()
{
describe
(
Support
.
getTestDialectTeaser
(
'belongsToMany'
),
function
()
{
it
(
'should not inherit scopes from parent to join table'
,
function
()
{
var
A
=
current
.
define
(
'a'
)
,
B
=
current
.
define
(
'b'
,
{},
{
defaultScope
:
{
where
:
{
foo
:
'bar'
}
},
scopes
:
{
baz
:
{
where
:
{
fooz
:
'zab'
}
}
}
})
,
AB
;
B
.
belongsToMany
(
A
,
{
through
:
'AB'
});
AB
=
current
.
model
(
'AB'
);
expect
(
AB
.
options
.
defaultScope
).
not
.
to
.
be
.
ok
;
expect
(
AB
.
options
.
scopes
).
to
.
have
.
length
(
0
);
});
describe
(
'timestamps'
,
function
()
{
describe
(
'timestamps'
,
function
()
{
it
(
'follows the global timestamps true option'
,
function
()
{
it
(
'follows the global timestamps true option'
,
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