Merge pull request #501 from lalitkapoor/GH-452

improve support for int arrays and float arrays
This commit is contained in:
Brian C 2014-02-26 06:15:35 -06:00
commit ff8fb616f6
2 changed files with 61 additions and 1 deletions

View File

@ -89,9 +89,24 @@ var parseIntegerArray = function(val) {
return p.parse();
};
var parseBigIntegerArray = function(val) {
if(!val) { return null; }
var p = arrayParser.create(val, function(entry){
if(entry !== null) {
entry = parseBigInteger(entry).trim();
}
return entry;
});
return p.parse();
};
var parseFloatArray = function(val) {
if(!val) { return null; }
var p = arrayParser.create(val, function(entry) {
if(entry !== null) {
entry = parseFloat(entry);
}
return entry;
});
@ -202,7 +217,7 @@ var init = function(register) {
register(1184, parseDate); // timestamp
register(1005, parseIntegerArray); // _int2
register(1007, parseIntegerArray); // _int4
register(1016, parseIntegerArray); // _int8
register(1016, parseBigIntegerArray); // _int8
register(1021, parseFloatArray); // _float4
register(1022, parseFloatArray); // _float8
register(1231, parseFloatArray); // _numeric

View File

@ -197,6 +197,51 @@ test('typed results', function() {
expected :function(val){
assert.deepEqual(val, [1.2,3.4]);
}
},{
name : 'array/int2',
format : 'text',
dataTypeID: 1005,
actual: '{-32768, -32767, 32766, 32767}',
expected :function(val){
assert.deepEqual(val, [-32768, -32767, 32766, 32767]);
}
},{
name : 'array/int4',
format : 'text',
dataTypeID: 1007,
actual: '{-2147483648, -2147483647, 2147483646, 2147483647}',
expected :function(val){
assert.deepEqual(val, [-2147483648, -2147483647, 2147483646, 2147483647]);
}
},{
name : 'array/int8',
format : 'text',
dataTypeID: 1016,
actual: '{-9223372036854775808, -9223372036854775807, 9223372036854775806, 9223372036854775807}',
expected :function(val){
assert.deepEqual(val, [
'-9223372036854775808',
'-9223372036854775807',
'9223372036854775806',
'9223372036854775807'
]);
}
},{
name : 'array/float4',
format : 'text',
dataTypeID: 1021,
actual: '{1.2, 3.4}',
expected :function(val){
assert.deepEqual(val, [1.2, 3.4]);
}
},{
name : 'array/float8',
format : 'text',
dataTypeID: 1022,
actual: '{-12345678.1234567, 12345678.12345678}',
expected :function(val){
assert.deepEqual(val, [-12345678.1234567, 12345678.12345678]);
}
},
{