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 4f95f176
authored
Dec 08, 2016
by
daleoooo
Committed by
Jan Aagaard Meier
Dec 08, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed: 6310 (#6963)
1 parent
86c567de
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
4 deletions
lib/dialects/mysql/connection-manager.js
test/integration/model/upsert.test.js
lib/dialects/mysql/connection-manager.js
View file @
4f95f17
...
@@ -57,6 +57,7 @@ ConnectionManager.prototype.connect = function(config) {
...
@@ -57,6 +57,7 @@ ConnectionManager.prototype.connect = function(config) {
host
:
config
.
host
,
host
:
config
.
host
,
port
:
config
.
port
,
port
:
config
.
port
,
user
:
config
.
username
,
user
:
config
.
username
,
flags
:
'-FOUND_ROWS'
,
password
:
config
.
password
,
password
:
config
.
password
,
database
:
config
.
database
,
database
:
config
.
database
,
timezone
:
self
.
sequelize
.
options
.
timezone
,
timezone
:
self
.
sequelize
.
options
.
timezone
,
...
...
test/integration/model/upsert.test.js
View file @
4f95f17
...
@@ -331,6 +331,28 @@ describe(Support.getTestDialectTeaser('Model'), function() {
...
@@ -331,6 +331,28 @@ describe(Support.getTestDialectTeaser('Model'), function() {
});
});
});
});
it
(
'does not update when setting current values'
,
function
()
{
return
this
.
User
.
create
({
id
:
42
,
username
:
'john'
}).
bind
(
this
).
then
(
function
()
{
return
this
.
User
.
findById
(
42
);
}).
then
(
function
(
user
)
{
return
this
.
User
.
upsert
({
id
:
user
.
id
,
username
:
user
.
username
});
}).
then
(
function
(
created
)
{
if
(
dialect
===
'sqlite'
)
{
expect
(
created
).
to
.
be
.
undefined
;
}
else
{
// After set node-mysql flags = '-FOUND_ROWS' in connection of mysql,
// result from upsert should be false when upsert a row to its current value
// https://dev.mysql.com/doc/refman/5.7/en/insert-on-duplicate.html
expect
(
created
).
to
.
equal
(
false
);
}
});
});
it
(
'Works when two separate uniqueKeys are passed'
,
function
()
{
it
(
'Works when two separate uniqueKeys are passed'
,
function
()
{
var
User
=
this
.
sequelize
.
define
(
'User'
,
{
var
User
=
this
.
sequelize
.
define
(
'User'
,
{
username
:
{
username
:
{
...
@@ -352,18 +374,18 @@ describe(Support.getTestDialectTeaser('Model'), function() {
...
@@ -352,18 +374,18 @@ describe(Support.getTestDialectTeaser('Model'), function() {
if
(
dialect
===
'sqlite'
)
{
if
(
dialect
===
'sqlite'
)
{
expect
(
created
).
to
.
be
.
undefined
;
expect
(
created
).
to
.
be
.
undefined
;
}
else
{
}
else
{
expect
(
created
).
to
.
be
.
ok
;
expect
(
created
).
to
.
be
.
ok
;
}
}
clock
.
tick
(
1000
);
clock
.
tick
(
1000
);
return
User
.
upsert
({
username
:
'user1'
,
email
:
'user1@domain.ext'
,
city
:
'New City'
});
return
User
.
upsert
({
username
:
'user1'
,
email
:
'user1@domain.ext'
,
city
:
'New City'
});
}).
then
(
function
(
created
)
{
}).
then
(
function
(
created
)
{
if
(
dialect
===
'sqlite'
)
{
if
(
dialect
===
'sqlite'
)
{
expect
(
created
).
to
.
be
.
undefined
;
expect
(
created
).
to
.
be
.
undefined
;
}
else
{
}
else
{
expect
(
created
).
not
.
to
.
be
.
ok
;
expect
(
created
).
not
.
to
.
be
.
ok
;
}
}
clock
.
tick
(
1000
);
clock
.
tick
(
1000
);
return
User
.
findOne
({
where
:
{
username
:
'user1'
,
email
:
'user1@domain.ext'
}});
return
User
.
findOne
({
where
:
{
username
:
'user1'
,
email
:
'user1@domain.ext'
}});
})
})
.
then
(
function
(
user
)
{
.
then
(
function
(
user
)
{
expect
(
user
.
createdAt
).
to
.
be
.
ok
;
expect
(
user
.
createdAt
).
to
.
be
.
ok
;
...
...
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