From ef671825ff0a3176c004d476a6b3f5977502cd38 Mon Sep 17 00:00:00 2001 From: Raymond Feng Date: Fri, 12 Jul 2013 19:10:42 -0700 Subject: [PATCH] Only flatten array/object for relational DBs --- lib/dao.js | 3 +++ lib/datasource.js | 4 ++++ lib/sql.js | 2 ++ 3 files changed, 9 insertions(+) diff --git a/lib/dao.js b/lib/dao.js index 27039309..f5185f03 100644 --- a/lib/dao.js +++ b/lib/dao.js @@ -40,6 +40,9 @@ function DataAccessObject() { DataAccessObject._forDB = function (data) { + if(!this.schema.isRelational()) { + return data; + } var res = {}; Object.keys(data).forEach(function (propName) { if (this.whatTypeName(propName) === 'JSON' || data[propName] instanceof Array) { diff --git a/lib/datasource.js b/lib/datasource.js index 6cc08365..82b14178 100644 --- a/lib/datasource.js +++ b/lib/datasource.js @@ -1271,6 +1271,10 @@ DataSource.prototype.defineOperation = function (name, options, fn) { this._operations[name] = options; } +DataSource.prototype.isRational = function() { + return this.adapter && this.adapter.relational; +} + /** * Define hidden property */ diff --git a/lib/sql.js b/lib/sql.js index 0a351bfa..ffdc611b 100644 --- a/lib/sql.js +++ b/lib/sql.js @@ -6,6 +6,8 @@ module.exports = BaseSQL; function BaseSQL() { } +BaseSQL.prototype.rational = true; + BaseSQL.prototype.query = function () { throw new Error('query method should be declared in adapter'); };