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

Commit 48e3b6b9 by Steffen Persch

better check if 'IS NOT' or '!=' should be used

1 parent b3186857
......@@ -299,7 +299,7 @@ var Utils = module.exports = {
case 'eq':
return '='
case 'ne':
return val ? '!=' : 'IS NOT'
return val === null ? 'IS NOT' : '!='
case 'between':
case '..':
return 'BETWEEN'
......@@ -451,7 +451,7 @@ var Utils = module.exports = {
for (var key in hash) {
if (key instanceof Utils.literal) {
_hash[key] = hash[key]
_hash[key] = hash[key]
} else if (key.indexOf('.') === -1) {
_hash[tableName + '.' + key] = hash[key]
} else {
......
......@@ -273,6 +273,16 @@ if (Support.dialectIsMySQL()) {
arguments: ['myTable', {where: { field: new Buffer("Sequelize")}}],
expectation: "SELECT * FROM `myTable` WHERE `myTable`.`field`=X'53657175656c697a65';",
context: QueryGenerator
}, {
title: 'use != if ne !== null',
arguments: ['myTable', {where: {field: {ne: 0}}}],
expectation: "SELECT * FROM `myTable` WHERE `myTable`.`field` != 0;",
context: QueryGenerator
}, {
title: 'use IS NOT if ne === null',
arguments: ['myTable', {where: {field: {ne: null}}}],
expectation: "SELECT * FROM `myTable` WHERE `myTable`.`field` IS NOT NULL;",
context: QueryGenerator
}
],
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!