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

Commit e8a46cd1 by Philip Patzer

fix limit=0 issue

format

replace double quotes to pass jshint

fix copy past mistake

adjust postgres tests for limit 0 and offset 0

use != null to check if limit and offset option exist

get rid of limitExist and offsetExist var

remove string test for limit and offset option

fix style
1 parent e2a9c78e
......@@ -17,6 +17,7 @@
"nonbsp": true,
"maxdepth": 8,
"quotmark": true, // deprecated
"-W041": false,
/* relaxing options */
"laxbreak":true,
......
......@@ -1754,10 +1754,12 @@ var QueryGenerator = {
*/
addLimitAndOffset: function(options, model) {
var fragment = '';
if (options.offset && !options.limit) {
/*jshint eqeqeq:false*/
if (options.offset != null && options.limit == null) {
fragment += ' LIMIT ' + this.escape(options.offset) + ', ' + 10000000000000;
} else if (options.limit) {
if (options.offset) {
} else if (options.limit != null) {
if (options.offset != null) {
fragment += ' LIMIT ' + this.escape(options.offset) + ', ' + this.escape(options.limit);
} else {
fragment += ' LIMIT ' + this.escape(options.limit);
......
......@@ -417,8 +417,13 @@ var QueryGenerator = {
addLimitAndOffset: function(options) {
var fragment = '';
if (options.limit) fragment += ' LIMIT ' + this.escape(options.limit);
if (options.offset) fragment += ' OFFSET ' + this.escape(options.offset);
/*jshint eqeqeq:false*/
if (options.limit != null) {
fragment += ' LIMIT ' + this.escape(options.limit);
}
if (options.offset != null) {
fragment += ' OFFSET ' + this.escape(options.offset);
}
return fragment;
},
......
......@@ -335,6 +335,16 @@ if (Support.dialectIsMySQL()) {
expectation: 'SELECT * FROM `myTable` LIMIT 2, 10000000000000;',
context: QueryGenerator
}, {
title: 'uses limit 0',
arguments: ['myTable', {limit: 0}],
expectation: 'SELECT * FROM `myTable` LIMIT 0;',
context: QueryGenerator
}, {
title: 'uses offset 0',
arguments: ['myTable', {offset: 0}],
expectation: 'SELECT * FROM `myTable` LIMIT 0, 10000000000000;',
context: QueryGenerator
}, {
title: 'multiple where arguments',
arguments: ['myTable', {where: {boat: 'canoe', weather: 'cold'}}],
expectation: "SELECT * FROM `myTable` WHERE `myTable`.`boat` = 'canoe' AND `myTable`.`weather` = 'cold';",
......
......@@ -291,6 +291,16 @@ if (dialect.match(/^postgres/)) {
expectation: 'SELECT * FROM "myTable" AS "myTable" ORDER BY "myTable"."id" DESC;',
context: QueryGenerator,
needsSequelize: true
},{
title: 'uses limit 0',
arguments: ['myTable', {limit: 0}],
expectation: 'SELECT * FROM "myTable" LIMIT 0;',
context: QueryGenerator
}, {
title: 'uses offset 0',
arguments: ['myTable', {offset: 0}],
expectation: 'SELECT * FROM "myTable" OFFSET 0;',
context: QueryGenerator
}, {
title: 'raw arguments are neither quoted nor escaped',
arguments: ['myTable', {order: [[{raw: 'f1(f2(id))'},'DESC']]}],
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!