Fix windowing support for non-uppercased SELECT queries

This commit is contained in:
Sandro Santilli 2013-06-06 15:24:57 +02:00
parent 0be9e47930
commit 2459aba2ba
3 changed files with 8 additions and 3 deletions

View File

@ -1,3 +1,7 @@
1.4.1
-----
* Fix windowing support for non-uppercased SELECT queries
1.4.0 1.4.0
----- -----
* Add arraybuffer format * Add arraybuffer format

View File

@ -81,8 +81,8 @@ function sanitize_filename(filename) {
// TODO:drop, fix in the UI (it's not documented in doc/API) // TODO:drop, fix in the UI (it's not documented in doc/API)
// //
function window_sql (sql, limit, offset) { function window_sql (sql, limit, offset) {
// only window select functions // only window select functions (NOTE: "values" will be broken, "with" will be broken)
if (_.isNumber(limit) && _.isNumber(offset) && sql.match(/^\s*SELECT\s/) ) { if (_.isNumber(limit) && _.isNumber(offset) && sql.match(/^\s*SELECT\s/i) ) {
return "SELECT * FROM (" + sql + ") AS cdbq_1 LIMIT " + limit + " OFFSET " + offset; return "SELECT * FROM (" + sql + ") AS cdbq_1 LIMIT " + limit + " OFFSET " + offset;
} }
return sql; return sql;

View File

@ -163,11 +163,12 @@ function(done){
},{ }, function(res) { },{ }, function(res) {
assert.equal(res.statusCode, 200, res.body); assert.equal(res.statusCode, 200, res.body);
assert.equal(res.headers['x-cache-channel'], 'cartodb_test_user_1_db:untitle_table_4'); assert.equal(res.headers['x-cache-channel'], 'cartodb_test_user_1_db:untitle_table_4');
var parsed = JSON.parse(res.body);
assert.equal(parsed.rows.length, 1);
done(); done();
}); });
}); });
test('POST /api/v1/sql with SQL parameter on SELECT only. no database param, just id using headers', function(done){ test('POST /api/v1/sql with SQL parameter on SELECT only. no database param, just id using headers', function(done){
assert.response(app, { assert.response(app, {
url: '/api/v1/sql', url: '/api/v1/sql',