Allow sql queries to end with a semicolon. Closes #90

This commit is contained in:
Sandro Santilli 2013-04-10 17:21:42 +02:00
parent e7437ba7cd
commit 0ec66c69a7
3 changed files with 21 additions and 0 deletions

View File

@ -1,6 +1,7 @@
1.3.8
-----
* Make using SET or querying system catalogues harder
* Allow sql queries to end with a semicolon (#90)
1.3.7
-----

View File

@ -502,6 +502,9 @@ function toOGR(dbname, user_id, gcol, sql, skipfields, out_format, out_filename,
var columns = [];
// Drop ending semicolon (ogr doens't like it)
sql = sql.replace(/;\s*$/, '');
Step (
function fetchColumns() {

View File

@ -176,4 +176,21 @@ test('GET /api/v1/sql as kml with no rows', function(done){
});
});
// See https://github.com/Vizzuality/CartoDB-SQL-API/issues/90
test('GET /api/v1/sql as kml with ending semicolon', function(done){
assert.response(app, {
url: '/api/v1/sql?' + querystring.stringify({
q: 'SELECT true WHERE false;',
format: 'kml'
}),
headers: {host: 'vizzuality.cartodb.com'},
method: 'GET'
},{ }, function(res){
assert.equal(res.statusCode, 200, res.body);
var body = '<?xml version="1.0" encoding="utf-8" ?>\n<kml xmlns="http://www.opengis.net/kml/2.2">\n<Document><Folder><name>sql_statement</name>\n</Folder></Document></kml>\n';
assert.equal(res.body, body);
done();
});
});
});