Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions lib/datatypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ datatypes = {
// Sure, Arrays are technically Objects, but we're treating Array as a
// separate datatype. Remember, instanceof Array fails across window
// boundaries, so let's also make sure the Object isn't Array-ish
if (typeof val != 'object' || _isArray(val)) {
if (typeof val != 'object'/* || _isArray(val)*/) { // by der_On: allow saving of arrays as the datatype array only saves arrays of numbers or strings correctly, but not arrays of objects
return {
err: i18n.getText('model.validatesObject', {name: name}, locale)
, val: null
Expand All @@ -203,8 +203,17 @@ datatypes = {
, serialize: function (input, options) {
var val
, opts = options || {};
if (typeof input.toString == 'function') {

// Arrays will be converted to JSON
if (_isArray(input)) {
val = JSON.stringify(input);
} else if (typeof input.toString == 'function') {
val = input.toString();

// if this happens the object had no usefull toString() method and we should make JSON out of it
if (val == "[object Object]") {
val = JSON.stringify(input);
}
}
else {
val = JSON.stringify(input);
Expand Down
3 changes: 2 additions & 1 deletion lib/generators/sql.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

var model = require('../index')
, utils = require('utilities')
, generator
Expand All @@ -13,6 +12,8 @@ datatypeMap = {
, 'date': 'date'
, 'datetime': 'timestamp'
, 'time': 'time'
, 'object': 'text'
, 'array': 'text'
};

generator = new (function () {
Expand Down