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 ad1c1537
authored
Jun 26, 2020
by
Shahar Hadas
Committed by
GitHub
Jun 26, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(mssql): bulkUpdate returning values (#12410)
1 parent
26fcbce2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
2 deletions
lib/dialects/mssql/query.js
test/integration/model/update.test.js
types/lib/model.d.ts
lib/dialects/mssql/query.js
View file @
ad1c153
...
@@ -210,7 +210,11 @@ class Query extends AbstractQuery {
...
@@ -210,7 +210,11 @@ class Query extends AbstractQuery {
return
data
[
0
];
return
data
[
0
];
}
}
if
(
this
.
isBulkUpdateQuery
())
{
if
(
this
.
isBulkUpdateQuery
())
{
return
data
.
length
;
if
(
this
.
options
.
returning
)
{
return
this
.
handleSelectQuery
(
data
);
}
return
rowCount
;
}
}
if
(
this
.
isBulkDeleteQuery
())
{
if
(
this
.
isBulkDeleteQuery
())
{
return
data
[
0
]
&&
data
[
0
].
AFFECTEDROWS
;
return
data
[
0
]
&&
data
[
0
].
AFFECTEDROWS
;
...
...
test/integration/model/update.test.js
View file @
ad1c153
...
@@ -139,6 +139,25 @@ describe(Support.getTestDialectTeaser('Model'), () => {
...
@@ -139,6 +139,25 @@ describe(Support.getTestDialectTeaser('Model'), () => {
});
});
}
}
if
(
_
.
get
(
current
.
dialect
.
supports
,
'returnValues.output'
))
{
it
(
'should output the updated record'
,
function
()
{
return
this
.
Account
.
create
({
ownerId
:
2
}).
then
(
account
=>
{
return
this
.
Account
.
update
({
name
:
'FooBar'
},
{
where
:
{
id
:
account
.
get
(
'id'
)
},
returning
:
true
}).
then
(([,
accounts
])
=>
{
const
firstAcc
=
accounts
[
0
];
expect
(
firstAcc
.
name
).
to
.
be
.
equal
(
'FooBar'
);
return
firstAcc
.
reload
();
}).
then
(
accountReloaded
=>
{
expect
(
accountReloaded
.
ownerId
,
'Reloaded as output update only return primary key and changed fields'
).
to
.
be
.
equal
(
2
);
});
});
});
}
if
(
current
.
dialect
.
supports
[
'LIMIT ON UPDATE'
])
{
if
(
current
.
dialect
.
supports
[
'LIMIT ON UPDATE'
])
{
it
(
'should only update one row'
,
function
()
{
it
(
'should only update one row'
,
function
()
{
return
this
.
Account
.
create
({
return
this
.
Account
.
create
({
...
...
types/lib/model.d.ts
View file @
ad1c153
...
@@ -2043,7 +2043,7 @@ export abstract class Model<T = any, T2 = any> extends Hooks {
...
@@ -2043,7 +2043,7 @@ export abstract class Model<T = any, T2 = any> extends Hooks {
/**
/**
* Update multiple instances that match the where options. The promise returns an array with one or two
* Update multiple instances that match the where options. The promise returns an array with one or two
* elements. The first element is always the number of affected rows, while the second element is the actual
* elements. The first element is always the number of affected rows, while the second element is the actual
* affected rows (only supported in postgres with `options.returning` true.)
* affected rows (only supported in postgres
and mssql
with `options.returning` true.)
*/
*/
public
static
update
<
M
extends
Model
>
(
public
static
update
<
M
extends
Model
>
(
this
:
{
new
():
M
}
&
typeof
Model
,
this
:
{
new
():
M
}
&
typeof
Model
,
...
...
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