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 95f7fb5c
authored
Jun 08, 2020
by
Over Martinez
Committed by
GitHub
Jun 08, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(mssql): empty order array generates invalid FETCH statement (#12261)
1 parent
ed2d7a90
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
2 deletions
lib/dialects/mssql/query-generator.js
test/unit/sql/offset-limit.test.js
lib/dialects/mssql/query-generator.js
View file @
95f7fb5
...
...
@@ -913,9 +913,9 @@ class MSSQLQueryGenerator extends AbstractQueryGenerator {
}
if
(
options
.
limit
||
options
.
offset
)
{
if
(
!
options
.
order
||
options
.
include
&&
!
orders
.
subQueryOrder
.
length
)
{
if
(
!
options
.
order
||
!
options
.
order
.
length
||
options
.
include
&&
!
orders
.
subQueryOrder
.
length
)
{
const
tablePkFragment
=
`
${
this
.
quoteTable
(
options
.
tableAs
||
model
.
name
)}
.
${
this
.
quoteIdentifier
(
model
.
primaryKeyField
)}
`
;
if
(
!
options
.
order
)
{
if
(
!
options
.
order
||
!
options
.
order
.
length
)
{
fragment
+=
` ORDER BY
${
tablePkFragment
}
`
;
}
else
{
const
orderFieldNames
=
_
.
map
(
options
.
order
,
order
=>
order
[
0
]);
...
...
test/unit/sql/offset-limit.test.js
View file @
95f7fb5
...
...
@@ -79,5 +79,14 @@ describe(Support.getTestDialectTeaser('SQL'), () => {
mysql
:
" LIMIT '\\';DELETE FROM user', 10"
,
mssql
:
" OFFSET N''';DELETE FROM user' ROWS FETCH NEXT 10 ROWS ONLY"
});
testsql
({
limit
:
10
,
order
:
[],
// When the order is an empty array, one is automagically prepended
model
:
{
primaryKeyField
:
'id'
,
name
:
'tableRef'
}
},
{
default
:
' LIMIT 10'
,
mssql
:
' ORDER BY [tableRef].[id] OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY'
});
});
});
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