diff --git a/js/model.js b/js/model.js index a74db7158f..be33b54f4a 100644 --- a/js/model.js +++ b/js/model.js @@ -486,7 +486,7 @@ Sao.field.Float = Sao.class_(Sao.field.Number, { set_client: function(record, value) { if (typeof value == 'string') { - value = Number(value); // without new for type conversion + value = Number(value); if (isNaN(value)) { value = this._default; } @@ -507,7 +507,7 @@ Sao.field.Numeric = Sao.class_(Sao.field.Number, { set_client: function(record, value) { if (typeof value == 'string') { - value = new Number(value); // with new to get an instance + value = new Sao.Decimal(value); if (isNaN(value.valueOf())) { value = this._default; } diff --git a/js/rpc.js b/js/rpc.js index 51117102dd..04ca7dad2c 100644 --- a/js/rpc.js +++ b/js/rpc.js @@ -81,7 +81,7 @@ case 'buffer': throw new Error('Buffer support not implemented'); case 'Decimal': - value = new Number(value.decimal); + value = new Sao.Decimal(value.decimal); break; } if (parent) { @@ -125,7 +125,7 @@ if (parent) { parent[index] = value; } - } else if (value instanceof Number) { + } else if (value instanceof Sao.Decimal) { value = { '__class__': 'Decimal', 'decimal': value.valueOf() diff --git a/js/sao.js b/js/sao.js index ca50c919ff..354fb934fb 100644 --- a/js/sao.js +++ b/js/sao.js @@ -32,4 +32,6 @@ var Sao = {}; } return ClassConstructor; }; + + Sao.Decimal = Number; }()); diff --git a/tests/sao.js b/tests/sao.js index 56f0c24b1a..6ee6c14118 100644 --- a/tests/sao.js +++ b/tests/sao.js @@ -25,7 +25,7 @@ }, 'datetime': new Date(2012, 11, 29, 19, 59, 10), 'date': new Date(2012, 11, 29), - 'decimal': new Number(1.1) + 'decimal': new Sao.Decimal(1.1) }; for (var name in tests) { var test = tests[name];