Return an error when "the_geom" is in skipfield for SVG output

Closes #73
This commit is contained in:
Sandro Santilli 2013-01-21 10:06:51 +01:00
parent 19fc0e5854
commit 977ecbeb29
3 changed files with 46 additions and 0 deletions

View File

@ -3,6 +3,7 @@
* Improve mixed-geometry export error message (#78)
* Remove NULL the_geom features from topojson output (#80)
* Fix crash when issuing SQL "COPY" command
* Return an error when "the_geom" is in skipfield for SVG output (#73)
1.3.3 (11/01/13)
-----

View File

@ -373,6 +373,9 @@ function toSVG(rows, gn, callback){
var lines = [];
var points = [];
_.each(rows, function(ele){
if ( ! ele.hasOwnProperty(gn) ) {
throw new Error('column "' + gn + '" does not exist');
}
var g = ele[gn];
if ( ! g ) return; // null or empty
var gdims = ele[gn + '_dimension'];

View File

@ -136,4 +136,46 @@ test('GET /api/v1/sql with SVG format and trimmed decimals', function(done){
});
});
// Test adding "the_geom" to skipfields
// See http://github.com/Vizzuality/CartoDB-SQL-API/issues/73
test('SVG format with "the_geom" in skipfields', function(done){
var query = querystring.stringify({
q: "SELECT 1 as cartodb_id, ST_MakePoint(5000, -54) AS the_geom ",
format: "svg",
skipfields: "the_geom"
});
assert.response(app, {
url: '/api/v1/sql?' + query,
headers: {host: 'vizzuality.cartodb.com'},
method: 'GET'
},{ }, function(res){
assert.equal(res.statusCode, 400, res.statusCode + ': ' + res.body);
assert.deepEqual(JSON.parse(res.body), {
error:['column "the_geom" does not exist']
});
done();
});
});
test('SVG format with missing "the_geom" field', function(done){
var query = querystring.stringify({
q: "SELECT 1 as cartodb_id, ST_MakePoint(5000, -54) AS something_else ",
format: "svg"
});
assert.response(app, {
url: '/api/v1/sql?' + query,
headers: {host: 'vizzuality.cartodb.com'},
method: 'GET'
},{ }, function(res){
assert.equal(res.statusCode, 400, res.statusCode + ': ' + res.body);
assert.deepEqual(JSON.parse(res.body), {
error:['column "the_geom" does not exist']
});
done();
});
});
});