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

Commit cd1206b1 by Jan Aagaard Meier

Change JSON unit test to use dialect.supports

1 parent 69ab3165
......@@ -45,7 +45,8 @@ AbstractDialect.prototype.supports = {
type: false,
using: true,
},
joinTableDependent: true
joinTableDependent: true,
JSON: false,
};
module.exports = AbstractDialect;
......@@ -33,7 +33,8 @@ PostgresDialect.prototype.supports = _.merge(_.cloneDeep(Abstract.prototype.supp
index: {
concurrently: true,
using: 2,
}
},
JSON: true,
});
PostgresDialect.prototype.Query = Query;
......
......@@ -5,28 +5,29 @@ var Support = require(__dirname + '/../support')
, util = require('util')
, expectsql = Support.expectsql
, current = Support.sequelize
, sql = current.dialect.QueryGenerator;
, sql = current.dialect.QueryGenerator
, current = Support.sequelize;
// Notice: [] will be replaced by dialect specific tick/quote character when there is not dialect specific expectation but only a default expectation
if (Support.getTestDialect() === 'postgres') {
if (current.dialect.supports.JSON) {
suite(Support.getTestDialectTeaser('SQL'), function() {
suite('JSON', function () {
suite('escape', function () {
test('plain string', function () {
expectsql(sql.escape('string', { type: DataTypes.JSON}), {
expectsql(sql.escape('string', { type: new DataTypes.JSON() }), {
default: '\'"string"\''
});
});
test('plain int', function () {
expectsql(sql.escape(123, { type: DataTypes.JSON}), {
expectsql(sql.escape(123, { type: new DataTypes.JSON() }), {
default: "'123'"
});
});
test('nested object', function () {
expectsql(sql.escape({ some: 'nested', more: { nested: true }, answer: 42 }, { type: DataTypes.JSON}), {
expectsql(sql.escape({ some: 'nested', more: { nested: true }, answer: 42 }, { type: new DataTypes.JSON() }), {
default: "'{\"some\":\"nested\",\"more\":{\"nested\":true},\"answer\":42}'"
});
});
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!