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 71e3b59f
authored
Sep 28, 2018
by
Benji Koltai
Committed by
Sushant
Sep 28, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(model): check for own property when overriding association mixins (#9952) (#9953)
1 parent
214c791b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
1 deletions
lib/associations/helpers.js
test/unit/associations/has-many.test.js
lib/associations/helpers.js
View file @
71e3b59
...
@@ -57,7 +57,7 @@ function mixinMethods(association, obj, methods, aliases) {
...
@@ -57,7 +57,7 @@ function mixinMethods(association, obj, methods, aliases) {
for
(
const
method
of
methods
)
{
for
(
const
method
of
methods
)
{
// don't override custom methods
// don't override custom methods
if
(
!
obj
[
association
.
accessors
[
method
]]
)
{
if
(
!
obj
.
hasOwnProperty
(
association
.
accessors
[
method
])
)
{
const
realMethod
=
aliases
[
method
]
||
method
;
const
realMethod
=
aliases
[
method
]
||
method
;
obj
[
association
.
accessors
[
method
]]
=
function
()
{
obj
[
association
.
accessors
[
method
]]
=
function
()
{
...
...
test/unit/associations/has-many.test.js
View file @
71e3b59
...
@@ -124,6 +124,16 @@ describe(Support.getTestDialectTeaser('hasMany'), () => {
...
@@ -124,6 +124,16 @@ describe(Support.getTestDialectTeaser('hasMany'), () => {
expect
(
user
[
method
]()).
to
.
be
.
a
(
'function'
);
expect
(
user
[
method
]()).
to
.
be
.
a
(
'function'
);
});
});
});
});
it
(
'should not override attributes'
,
()
=>
{
const
Project
=
current
.
define
(
'Project'
,
{
hasTasks
:
DataTypes
.
BOOLEAN
});
Project
.
hasMany
(
Task
);
const
company
=
Project
.
build
();
expect
(
company
.
hasTasks
).
not
.
to
.
be
.
a
(
'function'
);
});
});
});
describe
(
'get'
,
()
=>
{
describe
(
'get'
,
()
=>
{
...
...
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