From a51218e77b9b95023b546a857278025301551355 Mon Sep 17 00:00:00 2001 From: miyaji Date: Fri, 8 Nov 2013 22:35:52 +0900 Subject: [PATCH] fixed: DML if object value is null, JSON.stringify return string 'null' --- lib/Drivers/DML/mysql.js | 4 +++- lib/Drivers/DML/postgres.js | 4 +++- lib/Drivers/DML/sqlite.js | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/Drivers/DML/mysql.js b/lib/Drivers/DML/mysql.js index d73b5d08..bc3d8c03 100755 --- a/lib/Drivers/DML/mysql.js +++ b/lib/Drivers/DML/mysql.js @@ -267,7 +267,9 @@ Driver.prototype.propertyToValue = function (value, property) { value = (value) ? 1 : 0; break; case "object": - value = JSON.stringify(value); + if (value !== null) { + value = JSON.stringify(value); + } break; case "point": return function() { return 'POINT(' + value.x + ', ' + value.y + ')'; }; diff --git a/lib/Drivers/DML/postgres.js b/lib/Drivers/DML/postgres.js index b2470b69..5dc5ca2b 100644 --- a/lib/Drivers/DML/postgres.js +++ b/lib/Drivers/DML/postgres.js @@ -302,7 +302,9 @@ Driver.prototype.propertyToValue = function (value, property) { switch (property.type) { case "object": - value = JSON.stringify(value); + if (value !== null) { + value = JSON.stringify(value); + } break; case "date": if (this.config.timezone && this.config.timezone != 'local') { diff --git a/lib/Drivers/DML/sqlite.js b/lib/Drivers/DML/sqlite.js index 023ffecf..d124bcd7 100644 --- a/lib/Drivers/DML/sqlite.js +++ b/lib/Drivers/DML/sqlite.js @@ -273,7 +273,9 @@ Driver.prototype.propertyToValue = function (value, property) { value = (value) ? 1 : 0; break; case "object": - value = JSON.stringify(value); + if (value !== null) { + value = JSON.stringify(value); + } break; case "date": if (this.config.query && this.config.query.strdates) {