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

Commit 42c07914 by Martin Zagora

fix #5300: false and 0 are now properly encoded when using JSON/JSONB

1 parent cae4d8da
......@@ -954,7 +954,7 @@ var QueryGenerator = {
escape: function(value, field, options) {
options = options || {};
if (value) {
if (value !== null && value !== undefined) {
if (value._isSequelizeMethod) {
return this.handleSequelizeMethod(value);
} else {
......
......@@ -20,11 +20,23 @@ if (current.dialect.supports.JSON) {
});
test('plain int', function () {
expectsql(sql.escape(0, { type: new DataTypes.JSON() }), {
default: '\'0\''
});
expectsql(sql.escape(123, { type: new DataTypes.JSON() }), {
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 () {
expectsql(sql.escape(null, { type: new DataTypes.JSON() }), {
default: 'NULL'
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!