Skip to content

Commit 5fa19a0

Browse files
author
Sandro Santilli
committed
Fix parsing of numeric arrays. Closes #88.
Includes testcase, requires using a fork of node-postgresql.
1 parent 133add8 commit 5fa19a0

File tree

4 files changed

+30
-3
lines changed

4 files changed

+30
-3
lines changed

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
1.3.7
22
-----
3+
* Fix parsing of numeric arrays (#88)
34

45
1.3.6 (DD/MM/YY)
56
-----

npm-shrinkwrap.json

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"express": "~2.5.11",
1414
"underscore" : "1.1.x",
1515
"underscore.string": "1.1.5",
16-
"pg": "~0.11.2",
16+
"pg": "git://github.com/CartoDB/node-postgres.git#cdb_production",
17+
"express": "~2.5.11",
1718
"generic-pool": "1.0.x",
1819
"redis": "0.7.1",
1920
"hiredis": "*",

test/acceptance/app.test.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,30 @@ test('GET decent error if SQL is broken', function(done){
669669
});
670670
});
671671

672+
// See https://github.com/Vizzuality/CartoDB-SQL-API/issues/88
673+
test('numeric arrays are rendered as such', function(done){
674+
assert.response(app, {
675+
url: "/api/v1/sql?"
676+
+ querystring.stringify({q:
677+
"SELECT ARRAY[8.7,4.3]::numeric[] as x"
678+
}),
679+
headers: {host: 'vizzuality.localhost.lan:8080' },
680+
method: 'GET'
681+
},{}, function(res) {
682+
assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body);
683+
var out = JSON.parse(res.body);
684+
assert.ok(out.hasOwnProperty('time'));
685+
assert.equal(out.total_rows, 1);
686+
assert.equal(out.rows.length, 1);
687+
assert.ok(out.rows[0].hasOwnProperty('x'));
688+
assert.equal(out.rows[0].x.length, 2);
689+
assert.equal(out.rows[0].x[0], '8.7');
690+
assert.equal(out.rows[0].x[1], '4.3');
691+
assert.equal(res.headers['x-cache-channel'], 'cartodb_test_user_1_db:'); // keep forever
692+
done();
693+
});
694+
});
695+
672696
// GEOJSON tests
673697

674698
test('GET /api/v1/sql with SQL parameter and geojson format, ensuring content-disposition set to geojson', function(done){

0 commit comments

Comments
 (0)