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 95901aba
authored
Sep 24, 2017
by
Gabe Gorelick
Committed by
Sushant
Sep 24, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(model/increment): properly map fields for attributes in `by` options (#8363)
1 parent
c22f8214
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
2 deletions
lib/model.js
test/integration/model.test.js
lib/model.js
View file @
95901ab
...
...
@@ -2882,9 +2882,11 @@ class Model {
increment
:
true
});
const
where
=
_
.
extend
({},
options
.
where
);
Utils
.
mapOptionFieldNames
(
options
,
this
);
const
where
=
_
.
extend
({},
options
.
where
);
let
values
=
{};
if
(
Utils
.
_
.
isString
(
fields
))
{
values
[
fields
]
=
options
.
by
;
}
else
if
(
Utils
.
_
.
isArray
(
fields
))
{
...
...
test/integration/model.test.js
View file @
95901ab
...
...
@@ -2742,7 +2742,8 @@ describe(Support.getTestDialectTeaser('Model'), () => {
this
.
User
=
this
.
sequelize
.
define
(
'User'
,
{
id
:
{
type
:
DataTypes
.
INTEGER
,
primaryKey
:
true
},
aNumber
:
{
type
:
DataTypes
.
INTEGER
},
bNumber
:
{
type
:
DataTypes
.
INTEGER
}
bNumber
:
{
type
:
DataTypes
.
INTEGER
},
cNumber
:
{
type
:
DataTypes
.
INTEGER
,
field
:
'c_number'
}
});
const
self
=
this
;
...
...
@@ -2759,6 +2760,11 @@ describe(Support.getTestDialectTeaser('Model'), () => {
id
:
3
,
aNumber
:
0
,
bNumber
:
0
},
{
id
:
4
,
aNumber
:
0
,
bNumber
:
0
,
cNumber
:
0
}]);
});
});
...
...
@@ -2774,6 +2780,15 @@ describe(Support.getTestDialectTeaser('Model'), () => {
});
});
it
(
'uses correct column names for where conditions'
,
function
()
{
const
self
=
this
;
return
this
.
User
.
increment
([
'aNumber'
],
{
by
:
2
,
where
:
{
cNumber
:
0
}}).
then
(()
=>
{
return
self
.
User
.
findById
(
4
).
then
(
user4
=>
{
expect
(
user4
.
aNumber
).
to
.
be
.
equal
(
2
);
});
});
});
it
(
'should still work right with other concurrent increments'
,
function
()
{
const
self
=
this
;
return
this
.
User
.
findAll
().
then
(
aUsers
=>
{
...
...
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