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 b4ce0086
authored
Oct 01, 2017
by
Gabe Gorelick
Committed by
Sushant
Oct 01, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(model/upsert): doesnt work with Infinity dates (#8397)
1 parent
6b116691
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
0 deletions
lib/model.js
test/integration/model/upsert.test.js
lib/model.js
View file @
b4ce008
...
@@ -2191,6 +2191,7 @@ class Model {
...
@@ -2191,6 +2191,7 @@ class Model {
options
=
_
.
extend
({
options
=
_
.
extend
({
hooks
:
true
hooks
:
true
},
Utils
.
cloneDeep
(
options
||
{}));
},
Utils
.
cloneDeep
(
options
||
{}));
options
.
model
=
this
;
const
createdAtAttr
=
this
.
_timestampAttributes
.
createdAt
;
const
createdAtAttr
=
this
.
_timestampAttributes
.
createdAt
;
const
updatedAtAttr
=
this
.
_timestampAttributes
.
updatedAt
;
const
updatedAtAttr
=
this
.
_timestampAttributes
.
updatedAt
;
...
...
test/integration/model/upsert.test.js
View file @
b4ce008
...
@@ -487,6 +487,44 @@ describe(Support.getTestDialectTeaser('Model'), () => {
...
@@ -487,6 +487,44 @@ describe(Support.getTestDialectTeaser('Model'), () => {
});
});
});
});
}
}
if
(
dialect
.
match
(
/^postgres/
))
{
it
(
'works when deletedAt is Infinity and part of primary key'
,
function
()
{
const
User
=
this
.
sequelize
.
define
(
'User'
,
{
name
:
{
type
:
DataTypes
.
STRING
,
primaryKey
:
true
},
address
:
DataTypes
.
STRING
,
deletedAt
:
{
type
:
DataTypes
.
DATE
,
primaryKey
:
true
,
allowNull
:
false
,
defaultValue
:
Infinity
}
},
{
paranoid
:
true
});
return
User
.
sync
({
force
:
true
}).
then
(()
=>
{
return
Promise
.
all
([
User
.
create
({
name
:
'user1'
}),
User
.
create
({
name
:
'user2'
,
deletedAt
:
Infinity
}),
// this record is soft deleted
User
.
create
({
name
:
'user3'
,
deletedAt
:
-
Infinity
})
]).
then
(()
=>
{
return
User
.
upsert
({
name
:
'user1'
,
address
:
'address'
});
}).
then
(()
=>
{
return
User
.
findAll
({
where
:
{
address
:
null
}
});
}).
then
(
users
=>
{
expect
(
users
).
to
.
have
.
lengthOf
(
2
);
});
});
});
}
});
});
}
}
});
});
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