From 3cb35e0f46daff112db44b258ca7806b5ed96173 Mon Sep 17 00:00:00 2001 From: Lalit Kapoor Date: Wed, 8 Jan 2014 00:08:57 -0600 Subject: [PATCH 1/7] big integer array support --- lib/types/textParsers.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/types/textParsers.js b/lib/types/textParsers.js index 1266423..7b8163b 100644 --- a/lib/types/textParsers.js +++ b/lib/types/textParsers.js @@ -89,6 +89,18 @@ 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) { @@ -202,7 +214,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 From 8f4644dc3dac22ffddaabb42b65eae94d1e0e921 Mon Sep 17 00:00:00 2001 From: Lalit Kapoor Date: Wed, 8 Jan 2014 00:09:34 -0600 Subject: [PATCH 2/7] parse values in float arrays as floats not strings javascript numbers are 64-bit floating numbers --- lib/types/textParsers.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/types/textParsers.js b/lib/types/textParsers.js index 7b8163b..a051906 100644 --- a/lib/types/textParsers.js +++ b/lib/types/textParsers.js @@ -104,6 +104,9 @@ var parseBigIntegerArray = function(val) { var parseFloatArray = function(val) { if(!val) { return null; } var p = arrayParser.create(val, function(entry) { + if(entry !== null) { + entry = parseFloat(entry); + } return entry; }); From 093949003300fdae77488eb5695f51fd69fdca60 Mon Sep 17 00:00:00 2001 From: Lalit Kapoor Date: Wed, 8 Jan 2014 00:12:31 -0600 Subject: [PATCH 3/7] test array/int2 --- test/unit/client/typed-query-results-tests.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/unit/client/typed-query-results-tests.js b/test/unit/client/typed-query-results-tests.js index 2f2f14f..82a4408 100644 --- a/test/unit/client/typed-query-results-tests.js +++ b/test/unit/client/typed-query-results-tests.js @@ -197,6 +197,14 @@ 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]); + } }, { From 6410a8aca2eec8e91007f6fbaaf88332ea8fb8dc Mon Sep 17 00:00:00 2001 From: Lalit Kapoor Date: Wed, 8 Jan 2014 00:13:16 -0600 Subject: [PATCH 4/7] test array/int4 --- test/unit/client/typed-query-results-tests.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/unit/client/typed-query-results-tests.js b/test/unit/client/typed-query-results-tests.js index 82a4408..06db47c 100644 --- a/test/unit/client/typed-query-results-tests.js +++ b/test/unit/client/typed-query-results-tests.js @@ -205,6 +205,14 @@ test('typed results', function() { 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]); + } }, { From eee21dd088509bb6d528e62aa1252da891029e3c Mon Sep 17 00:00:00 2001 From: Lalit Kapoor Date: Wed, 8 Jan 2014 00:13:52 -0600 Subject: [PATCH 5/7] test array/int8 --- test/unit/client/typed-query-results-tests.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/unit/client/typed-query-results-tests.js b/test/unit/client/typed-query-results-tests.js index 06db47c..aca6c27 100644 --- a/test/unit/client/typed-query-results-tests.js +++ b/test/unit/client/typed-query-results-tests.js @@ -213,6 +213,19 @@ test('typed results', function() { 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' + ]); + } }, { From 9bd88f844912ceed939bfeb57f64c79eebc97257 Mon Sep 17 00:00:00 2001 From: Lalit Kapoor Date: Wed, 8 Jan 2014 00:14:42 -0600 Subject: [PATCH 6/7] test array/float4 --- test/unit/client/typed-query-results-tests.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/unit/client/typed-query-results-tests.js b/test/unit/client/typed-query-results-tests.js index aca6c27..d411121 100644 --- a/test/unit/client/typed-query-results-tests.js +++ b/test/unit/client/typed-query-results-tests.js @@ -226,6 +226,14 @@ test('typed results', function() { '9223372036854775807' ]); } + },{ + name : 'array/float4', + format : 'text', + dataTypeID: 1021, + actual: '{1.2, 3.4}', + expected :function(val){ + assert.deepEqual(val, [1.2, 3.4]); + } }, { From f1c0abab75f7a77efb101cff4b27444c82b5358c Mon Sep 17 00:00:00 2001 From: Lalit Kapoor Date: Wed, 8 Jan 2014 01:00:03 -0600 Subject: [PATCH 7/7] test array/float8 --- test/unit/client/typed-query-results-tests.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/unit/client/typed-query-results-tests.js b/test/unit/client/typed-query-results-tests.js index d411121..abac25d 100644 --- a/test/unit/client/typed-query-results-tests.js +++ b/test/unit/client/typed-query-results-tests.js @@ -234,6 +234,14 @@ test('typed results', function() { 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]); + } }, {