Skip to content

Commit 94a7cd2

Browse files
Merge pull request balderdashy#100 from npfitz/master
Fixed malformed SQL query issue
2 parents b470088 + 226c3ab commit 94a7cd2

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

lib/sql.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
/**
32
* Module Dependencies
43
*/
@@ -317,11 +316,11 @@ var sql = module.exports = {
317316
}
318317
}
319318

320-
if (hop(options, 'limit')) {
319+
if (hop(options, 'limit') && options.limit !== null) {
321320
queryPart += 'LIMIT ' + options.limit + ' ';
322321
}
323322

324-
if (hop(options, 'skip')) {
323+
if (hop(options, 'skip') && options.skip !== null) {
325324
// Some MySQL hackery here. For details, see:
326325
// http://stackoverflow.com/questions/255517/mysql-offset-infinite-rows
327326
if (!options.limit) {
@@ -416,15 +415,15 @@ var sql = module.exports = {
416415
queryPart = queryPart.slice(0, -2) + ' ';
417416
}
418417

419-
if (hop(options, 'limit')) {
418+
if (hop(options, 'limit') && options.limit !== null) {
420419
queryPart += 'LIMIT ' + options.limit + ' ';
421420
} else {
422421
// Some MySQL hackery here. For details, see:
423422
// http://stackoverflow.com/questions/255517/mysql-offset-infinite-rows
424423
queryPart += 'LIMIT 18446744073709551610 ';
425424
}
426425

427-
if (hop(options, 'skip')) {
426+
if (hop(options, 'skip') && options.skip !== null) {
428427
queryPart += 'OFFSET ' + options.skip + ' ';
429428
}
430429

0 commit comments

Comments
 (0)