不要怂,就是干,撸起袖子干!

You need to sign in or sign up before continuing.
Commit 00bd62c7 by Acker Dawn Apple Committed by Mick Hansen

fixes msssql only error when no order by but has offset or limit present (#6181)

* fixes msssql only error when no order by but has offset or limit present

* added a test for my fix

* removed unneeded if & used proper quoteTable method for mssql only fix
1 parent 9cc1e144
...@@ -685,7 +685,7 @@ var QueryGenerator = { ...@@ -685,7 +685,7 @@ var QueryGenerator = {
if (options.limit || options.offset) { if (options.limit || options.offset) {
if (!options.order || (options.include && !orders.subQueryOrder.length)) { if (!options.order || (options.include && !orders.subQueryOrder.length)) {
fragment += (options.order && !isSubQuery) ? ', ' : ' ORDER BY '; fragment += (options.order && !isSubQuery) ? ', ' : ' ORDER BY ';
fragment += this.quoteIdentifier(model.primaryKeyField); fragment += this.quoteTable(model.name) + '.' + this.quoteIdentifier(model.primaryKeyField);
} }
if (options.offset || options.limit) { if (options.offset || options.limit) {
......
...@@ -26,6 +26,14 @@ suite(Support.getTestDialectTeaser('SQL'), function() { ...@@ -26,6 +26,14 @@ suite(Support.getTestDialectTeaser('SQL'), function() {
}; };
testsql({ testsql({
limit: 10,//when no order by present, one is automagically prepended, test it's existence
model:{primaryKeyField:'id', name:'tableRef'}
}, {
default: ' LIMIT 10',
mssql: ' ORDER BY [tableRef].[id] OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY'
});
testsql({
limit: 10, limit: 10,
order: [ order: [
['email', 'DESC'] // for MSSQL ['email', 'DESC'] // for MSSQL
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!