Fix X-Cache-Channel computation with paging parameters. Closes #85.

This commit is contained in:
Sandro Santilli 2013-02-18 16:14:15 +01:00
parent d418db03e4
commit d4b1f580ff
4 changed files with 23 additions and 3 deletions

View File

@ -5,6 +5,7 @@
* Add pid to /cachestatus (#83)
* Check CDB_QueryTable response before saving into cache (#83)
* Use an expiring LRU cache for query tables (#83)
* Fix X-Cache-Channel computation with paging parameters (#85)
1.3.4 (21/01/13)
-----

View File

@ -183,7 +183,7 @@ function handleQuery(req, res) {
tableCacheItem.hits++;
return false;
} else {
pg.query("SELECT CDB_QueryTables($quotesql$" + sql + "$quotesql$)", this);
pg.query("SELECT CDB_QueryTables($quotesql$" + sql + "$quotesql$)", this, true);
}
},
function queryResult(err, result){

View File

@ -54,7 +54,7 @@ var PSQL = function(user_id, db, limit, offset){
}
};
me.query = function(sql, callback){
me.query = function(sql, callback, skip_window){
var that = this;
Step(
@ -67,7 +67,7 @@ var PSQL = function(user_id, db, limit, offset){
},
function(err, client){
if (err) return callback(err, null);
client.query(that.window_sql(sql), this);
client.query(skip_window ? sql : that.window_sql(sql), this);
},
function(err, res){
//if (err) console.log(err);

View File

@ -111,6 +111,25 @@ function(done){
});
});
// Test for https://github.com/Vizzuality/CartoDB-SQL-API/issues/85
test("paging doesn't break x-cache-channel",
function(done){
assert.response(app, {
url: '/api/v1/sql?' + querystring.stringify({
q: 'SELECT cartodb_id*3 FROM untitle_table_4',
api_key: '1234',
rows_per_page: 1,
page: 2
}),
headers: {host: 'vizzuality.cartodb.com'},
method: 'GET'
},{ }, function(res) {
assert.equal(res.statusCode, 200, res.body);
assert.equal(res.headers['x-cache-channel'], 'cartodb_test_user_1_db:untitle_table_4');
done();
});
});
test('POST /api/v1/sql with SQL parameter on SELECT only. no database param, just id using headers', function(done){
assert.response(app, {