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 1a16b915
authored
Jun 26, 2021
by
roikoren755
Committed by
GitHub
Jun 26, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(utils): clone attributes before mutating them (#13226)
1 parent
39299a63
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
0 deletions
lib/utils.js
test/integration/associations/scope.test.js
lib/utils.js
View file @
1a16b91
...
@@ -186,6 +186,7 @@ exports.mapOptionFieldNames = mapOptionFieldNames;
...
@@ -186,6 +186,7 @@ exports.mapOptionFieldNames = mapOptionFieldNames;
function
mapWhereFieldNames
(
attributes
,
Model
)
{
function
mapWhereFieldNames
(
attributes
,
Model
)
{
if
(
attributes
)
{
if
(
attributes
)
{
attributes
=
cloneDeep
(
attributes
);
getComplexKeys
(
attributes
).
forEach
(
attribute
=>
{
getComplexKeys
(
attributes
).
forEach
(
attribute
=>
{
const
rawAttribute
=
Model
.
rawAttributes
[
attribute
];
const
rawAttribute
=
Model
.
rawAttributes
[
attribute
];
...
...
test/integration/associations/scope.test.js
View file @
1a16b91
...
@@ -19,6 +19,7 @@ describe(Support.getTestDialectTeaser('associations'), () => {
...
@@ -19,6 +19,7 @@ describe(Support.getTestDialectTeaser('associations'), () => {
commentable
:
Sequelize
.
STRING
,
commentable
:
Sequelize
.
STRING
,
commentable_id
:
Sequelize
.
INTEGER
,
commentable_id
:
Sequelize
.
INTEGER
,
isMain
:
{
isMain
:
{
field
:
'is_main'
,
type
:
Sequelize
.
BOOLEAN
,
type
:
Sequelize
.
BOOLEAN
,
defaultValue
:
false
defaultValue
:
false
}
}
...
@@ -298,6 +299,11 @@ describe(Support.getTestDialectTeaser('associations'), () => {
...
@@ -298,6 +299,11 @@ describe(Support.getTestDialectTeaser('associations'), () => {
expect
(
comment
.
type
).
to
.
match
(
/blue|green/
);
expect
(
comment
.
type
).
to
.
match
(
/blue|green/
);
}
}
});
});
it
(
'should not mutate scope when running SELECT query (#12868)'
,
async
function
()
{
await
this
.
sequelize
.
sync
({
force
:
true
});
await
this
.
Post
.
findOne
({
where
:
{},
include
:
[{
association
:
this
.
Post
.
associations
.
mainComment
,
attributes
:
[
'id'
],
required
:
true
,
where
:
{}
}]
});
expect
(
this
.
Post
.
associations
.
mainComment
.
scope
.
isMain
).
to
.
equal
(
true
);
});
});
});
if
(
Support
.
getTestDialect
()
!==
'sqlite'
)
{
if
(
Support
.
getTestDialect
()
!==
'sqlite'
)
{
...
...
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