Permalink
Browse files

fix: "DELETE ... FROM ... LIMIT 0, 1" will have syntax error

  • Loading branch information...
XadillaX committed Oct 21, 2016
1 parent 5c2b30c commit d2d69d312c11d902f0ecfca046546aa02f7e8279
Showing with 10 additions and 3 deletions.
  1. +10 −3 lib/adapters/mysql.js
@@ -602,9 +602,16 @@ class MySQLAdapter extends Adapter {
}

if(options.limit && options.limit.length) {
const limit = this.makeLimit(model, options.limit);
if(limit) {
sql += ` LIMIT ${limit}`;
const limit = options.limit;
if(limit.length=== 1) {
sql += ` LIMIT ${limit[0]}`;
} else if(limit[0] === 0) {
sql += ` LIMIT ${limit[1]}`;
} else {
throw new Error("Invalid limit in delete. Refer to " +
"http://dev.mysql.com/doc/refman/5.7/en/delete.html#idm139816273062400, " +
"https://www.techonthenet.com/mysql/delete_limit.php and " +
"http://stackoverflow.com/questions/7142097/mysql-delete-statement-with-limit#answer-7142118");
}
}

0 comments on commit d2d69d3

Please sign in to comment.