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

Commit 0ddfbc5d by Mick Hansen

Merge pull request #5331 from zaggino/master

Properly escape number 0 in query generator
2 parents cae4d8da 42c07914
...@@ -954,7 +954,7 @@ var QueryGenerator = { ...@@ -954,7 +954,7 @@ var QueryGenerator = {
escape: function(value, field, options) { escape: function(value, field, options) {
options = options || {}; options = options || {};
if (value) { if (value !== null && value !== undefined) {
if (value._isSequelizeMethod) { if (value._isSequelizeMethod) {
return this.handleSequelizeMethod(value); return this.handleSequelizeMethod(value);
} else { } else {
......
...@@ -20,11 +20,23 @@ if (current.dialect.supports.JSON) { ...@@ -20,11 +20,23 @@ if (current.dialect.supports.JSON) {
}); });
test('plain int', function () { test('plain int', function () {
expectsql(sql.escape(0, { type: new DataTypes.JSON() }), {
default: '\'0\''
});
expectsql(sql.escape(123, { type: new DataTypes.JSON() }), { expectsql(sql.escape(123, { type: new DataTypes.JSON() }), {
default: '\'123\'' default: '\'123\''
}); });
}); });
test('boolean', function () {
expectsql(sql.escape(true, { type: new DataTypes.JSON() }), {
default: '\'true\''
});
expectsql(sql.escape(false, { type: new DataTypes.JSON() }), {
default: '\'false\''
});
});
test('NULL', function () { test('NULL', function () {
expectsql(sql.escape(null, { type: new DataTypes.JSON() }), { expectsql(sql.escape(null, { type: new DataTypes.JSON() }), {
default: 'NULL' default: 'NULL'
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!