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 2fbf399c
authored
Nov 05, 2016
by
Sushant
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: increment/decrement dont map updatedAt field
1 parent
c88bc257
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
11 deletions
changelog.md
lib/model.js
test/integration/model/attributes/field.test.js
changelog.md
View file @
2fbf399
# Future
# Future
-
[
FIXED
]
`restore`
now uses
`field`
from
`deletedAt`
-
[
FIXED
]
`restore`
now uses
`field`
from
`deletedAt`
-
[
FIXED
]
MSSQL bulkInsertQuery when options and attributes are not passed
-
[
FIXED
]
MSSQL bulkInsertQuery when options and attributes are not passed
-
[
FIXED
]
`DATEONLY`
now returns
`YYYY-MM-DD`
date string
[
#4858
]
(
https://github.com/sequelize/sequelize/issues/4858
)
-
[
FIXED
]
`DATEONLY`
now returns
`YYYY-MM-DD`
date string
[
#4858
]
(
https://github.com/sequelize/sequelize/issues/4858
)
-
[
FIXED
]
Issues with
`createFunction`
and
`dropFunction`
(PostgresSQL)
-
[
FIXED
]
Issues with
`createFunction`
and
`dropFunction`
(PostgresSQL)
...
@@ -8,6 +8,7 @@
...
@@ -8,6 +8,7 @@
-
[
FIXED
]
GroupedLimit when foreignKey has a field alias
-
[
FIXED
]
GroupedLimit when foreignKey has a field alias
-
[
FIXED
]
groupedLimit.through.where support
-
[
FIXED
]
groupedLimit.through.where support
-
[
ADDED
]
`option.silent`
for increment and decrement
[
#6795
](
https://github.com/sequelize/sequelize/pull/6795
)
-
[
ADDED
]
`option.silent`
for increment and decrement
[
#6795
](
https://github.com/sequelize/sequelize/pull/6795
)
-
[
FIXED
]
`Increment`
/
`Decrement`
properly maps to timestamp fields
[
#6296
](
https://github.com/sequelize/sequelize/issues/6296
)
## BC breaks:
## BC breaks:
-
`DATEONLY`
now returns string in
`YYYY-MM-DD`
format rather than
`Date`
type
-
`DATEONLY`
now returns string in
`YYYY-MM-DD`
format rather than
`Date`
type
...
...
lib/model.js
View file @
2fbf399
...
@@ -3660,6 +3660,7 @@ class Model {
...
@@ -3660,6 +3660,7 @@ class Model {
increment
(
fields
,
options
)
{
increment
(
fields
,
options
)
{
const
identifier
=
this
.
where
();
const
identifier
=
this
.
where
();
const
updatedAtAttr
=
this
.
constructor
.
_timestampAttributes
.
updatedAt
;
const
updatedAtAttr
=
this
.
constructor
.
_timestampAttributes
.
updatedAt
;
const
updatedAtAttribute
=
this
.
constructor
.
rawAttributes
[
updatedAtAttr
];
options
=
_
.
defaults
({},
options
,
{
options
=
_
.
defaults
({},
options
,
{
by
:
1
,
by
:
1
,
...
@@ -3681,7 +3682,7 @@ class Model {
...
@@ -3681,7 +3682,7 @@ class Model {
}
}
if
(
!
options
.
silent
&&
updatedAtAttr
&&
!
values
[
updatedAtAttr
])
{
if
(
!
options
.
silent
&&
updatedAtAttr
&&
!
values
[
updatedAtAttr
])
{
options
.
attributes
[
updatedAtAttr
]
=
this
.
constructor
.
_getDefaultTimestamp
(
updatedAtAttr
)
||
Utils
.
now
(
this
.
sequelize
.
options
.
dialect
);
options
.
attributes
[
updatedAtAttr
ibute
.
field
||
updatedAtAttr
]
=
this
.
constructor
.
_getDefaultTimestamp
(
updatedAtAttr
)
||
Utils
.
now
(
this
.
sequelize
.
options
.
dialect
);
}
}
for
(
const
attr
of
Object
.
keys
(
values
))
{
for
(
const
attr
of
Object
.
keys
(
values
))
{
...
...
test/integration/model/attributes/field.test.js
View file @
2fbf399
...
@@ -73,17 +73,14 @@ describe(Support.getTestDialectTeaser('Model'), function() {
...
@@ -73,17 +73,14 @@ describe(Support.getTestDialectTeaser('Model'), function() {
autoIncrement
:
true
,
autoIncrement
:
true
,
field
:
'commentId'
field
:
'commentId'
},
},
text
:
{
text
:
{
type
:
DataTypes
.
STRING
,
field
:
'comment_text'
},
type
:
DataTypes
.
STRING
,
notes
:
{
type
:
DataTypes
.
STRING
,
field
:
'notes'
},
field
:
'comment_text'
likes
:
{
type
:
DataTypes
.
INTEGER
,
field
:
'like_count'
},
},
createdAt
:
{
type
:
DataTypes
.
DATE
,
field
:
'created_at'
,
allowNull
:
false
},
notes
:
{
updatedAt
:
{
type
:
DataTypes
.
DATE
,
field
:
'updated_at'
,
allowNull
:
false
}
type
:
DataTypes
.
STRING
,
field
:
'notes'
}
},
{
},
{
tableName
:
'comments'
,
tableName
:
'comments'
,
timestamps
:
fals
e
timestamps
:
tru
e
});
});
this
.
User
.
hasMany
(
this
.
Task
,
{
this
.
User
.
hasMany
(
this
.
Task
,
{
...
@@ -145,6 +142,16 @@ describe(Support.getTestDialectTeaser('Model'), function() {
...
@@ -145,6 +142,16 @@ describe(Support.getTestDialectTeaser('Model'), function() {
},
},
notes
:
{
notes
:
{
type
:
DataTypes
.
STRING
type
:
DataTypes
.
STRING
},
like_count
:
{
type
:
DataTypes
.
INTEGER
},
created_at
:
{
type
:
DataTypes
.
DATE
,
allowNull
:
false
},
updated_at
:
{
type
:
DataTypes
.
DATE
}
}
})
})
]);
]);
...
@@ -231,6 +238,35 @@ describe(Support.getTestDialectTeaser('Model'), function() {
...
@@ -231,6 +238,35 @@ describe(Support.getTestDialectTeaser('Model'), function() {
});
});
});
});
it
(
'increment should work'
,
function
()
{
return
this
.
Comment
.
destroy
({
truncate
:
true
})
.
then
(()
=>
this
.
Comment
.
create
({
note
:
'oh boy, here I go again'
,
likes
:
23
}))
.
then
((
comment
)
=>
comment
.
increment
(
'likes'
))
.
then
((
comment
)
=>
comment
.
reload
())
.
then
((
comment
)
=>
{
expect
(
comment
.
likes
).
to
.
be
.
equal
(
24
);
});
});
it
(
'decrement should work'
,
function
()
{
return
this
.
Comment
.
destroy
({
truncate
:
true
})
.
then
(()
=>
this
.
Comment
.
create
({
note
:
'oh boy, here I go again'
,
likes
:
23
}))
.
then
((
comment
)
=>
comment
.
decrement
(
'likes'
))
.
then
((
comment
)
=>
comment
.
reload
())
.
then
((
comment
)
=>
{
expect
(
comment
.
likes
).
to
.
be
.
equal
(
22
);
});
});
it
(
'sum should work'
,
function
()
{
return
this
.
Comment
.
destroy
({
truncate
:
true
})
.
then
(()
=>
this
.
Comment
.
create
({
note
:
'oh boy, here I go again'
,
likes
:
23
}))
.
then
(()
=>
this
.
Comment
.
sum
(
'likes'
))
.
then
((
likes
)
=>
{
expect
(
likes
).
to
.
be
.
equal
(
23
);
});
});
it
(
'should create, fetch and update with alternative field names from a simple model'
,
function
()
{
it
(
'should create, fetch and update with alternative field names from a simple model'
,
function
()
{
var
self
=
this
;
var
self
=
this
;
...
...
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