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 73d7a65f
authored
Apr 15, 2019
by
Sebastian Keller
Committed by
Sushant
Apr 15, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(mssql): subquery handling for order (#10769)
1 parent
98cb17c1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
91 additions
and
3 deletions
lib/dialects/mssql/query-generator.js
test/integration/dialects/mssql/regressions.test.js
lib/dialects/mssql/query-generator.js
View file @
73d7a65
...
@@ -882,11 +882,14 @@ const QueryGenerator = {
...
@@ -882,11 +882,14 @@ const QueryGenerator = {
return
''
;
return
''
;
}
}
let
fragment
=
''
;
const
offset
=
options
.
offset
||
0
;
const
offset
=
options
.
offset
||
0
,
const
isSubQuery
=
options
.
subQuery
===
undefined
isSubQuery
=
options
.
hasIncludeWhere
||
options
.
hasIncludeRequired
||
options
.
hasMultiAssociation
;
?
options
.
hasIncludeWhere
||
options
.
hasIncludeRequired
||
options
.
hasMultiAssociation
:
options
.
subQuery
;
let
fragment
=
''
;
let
orders
=
{};
let
orders
=
{};
if
(
options
.
order
)
{
if
(
options
.
order
)
{
orders
=
this
.
getQueryOrders
(
options
,
model
,
isSubQuery
);
orders
=
this
.
getQueryOrders
(
options
,
model
,
isSubQuery
);
}
}
...
...
test/integration/dialects/mssql/regressions.test.js
0 → 100644
View file @
73d7a65
'use strict'
;
const
chai
=
require
(
'chai'
),
expect
=
chai
.
expect
,
Support
=
require
(
__dirname
+
'/../../support'
),
Sequelize
=
Support
.
Sequelize
,
Op
=
Sequelize
.
Op
,
dialect
=
Support
.
getTestDialect
();
if
(
dialect
.
match
(
/^mssql/
))
{
describe
(
'[MSSQL Specific] Regressions'
,
()
=>
{
it
(
'does not duplicate columns in ORDER BY statement, #9008'
,
function
()
{
const
LoginLog
=
this
.
sequelize
.
define
(
'LoginLog'
,
{
ID
:
{
field
:
'id'
,
type
:
Sequelize
.
INTEGER
,
primaryKey
:
true
,
autoIncrement
:
true
},
UserID
:
{
field
:
'userid'
,
type
:
Sequelize
.
UUID
,
allowNull
:
false
}
});
const
User
=
this
.
sequelize
.
define
(
'User'
,
{
UserID
:
{
field
:
'userid'
,
type
:
Sequelize
.
UUID
,
defaultValue
:
Sequelize
.
UUIDV4
,
primaryKey
:
true
},
UserName
:
{
field
:
'username'
,
type
:
Sequelize
.
STRING
(
50
),
allowNull
:
false
}
});
LoginLog
.
belongsTo
(
User
,
{
foreignKey
:
'UserID'
});
User
.
hasMany
(
LoginLog
,
{
foreignKey
:
'UserID'
});
return
this
.
sequelize
.
sync
({
force
:
true
})
.
then
(()
=>
User
.
bulkCreate
([
{
UserName
:
'Vayom'
},
{
UserName
:
'Shaktimaan'
},
{
UserName
:
'Nikita'
},
{
UserName
:
'Aryamaan'
}
],
{
returning
:
true
}))
.
spread
((
vyom
,
shakti
,
nikita
,
arya
)
=>
{
return
Sequelize
.
Promise
.
all
([
vyom
.
createLoginLog
(),
shakti
.
createLoginLog
(),
nikita
.
createLoginLog
(),
arya
.
createLoginLog
()
]);
}).
then
(()
=>
{
return
LoginLog
.
findAll
({
include
:
[
{
model
:
User
,
where
:
{
UserName
:
{
[
Op
.
like
]:
'%maan%'
}
}
}
],
order
:
[[
User
,
'UserName'
,
'DESC'
]],
offset
:
0
,
limit
:
10
});
}).
then
(
logs
=>
{
expect
(
logs
).
to
.
have
.
length
(
2
);
expect
(
logs
[
0
].
User
.
get
(
'UserName'
)).
to
.
equal
(
'Shaktimaan'
);
expect
(
logs
[
1
].
User
.
get
(
'UserName'
)).
to
.
equal
(
'Aryamaan'
);
});
});
});
}
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