Do not request caching of TRUNCATE queries
This commit is contained in:
parent
cc74244b33
commit
414f4b6c3e
1
NEWS.md
1
NEWS.md
@ -1,6 +1,7 @@
|
||||
1.3.9
|
||||
-----
|
||||
* Do not choke on multiple `skipfields` parameter
|
||||
* Do not request caching of TRUNCATE queries
|
||||
|
||||
1.3.8
|
||||
-----
|
||||
|
@ -63,7 +63,7 @@ app.get('/api/v1/cachestatus', function(req, res) { handleCacheStatus(req, res)
|
||||
//
|
||||
function queryMayWrite(sql) {
|
||||
var mayWrite = false;
|
||||
var pattern = RegExp("(alter|insert|update|delete|create|drop)", "i");
|
||||
var pattern = RegExp("(alter|insert|update|delete|create|drop|truncate)", "i");
|
||||
if ( pattern.test(sql) ) {
|
||||
mayWrite = true;
|
||||
}
|
||||
|
@ -445,6 +445,39 @@ test('multistatement insert, alter, select, begin, commit', function(done){
|
||||
});
|
||||
});
|
||||
|
||||
test('TRUNCATE TABLE with GET and auth', function(done){
|
||||
assert.response(app, {
|
||||
url: "/api/v1/sql?" + querystring.stringify({
|
||||
q: 'TRUNCATE TABLE test_table',
|
||||
api_key: 1234
|
||||
}),
|
||||
headers: {host: 'vizzuality.cartodb.com'},
|
||||
method: 'GET'
|
||||
},{}, function(res) {
|
||||
assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body);
|
||||
assert.equal(res.headers['x-cache-channel'], 'NONE');
|
||||
assert.equal(res.headers['cache-control'], expected_cache_control);
|
||||
var pbody = JSON.parse(res.body);
|
||||
assert.equal(pbody.rows.length, 0);
|
||||
assert.response(app, {
|
||||
url: "/api/v1/sql?" + querystring.stringify({
|
||||
q: 'SELECT count(*) FROM test_table',
|
||||
api_key: 1234
|
||||
}),
|
||||
headers: {host: 'vizzuality.cartodb.com'},
|
||||
method: 'GET'
|
||||
},{}, function(res) {
|
||||
assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body);
|
||||
assert.equal(res.headers['x-cache-channel'], 'cartodb_test_user_1_db:test_table');
|
||||
assert.equal(res.headers['cache-control'], expected_cache_control);
|
||||
var pbody = JSON.parse(res.body);
|
||||
assert.equal(pbody.total_rows, 1);
|
||||
assert.equal(pbody.rows[0]['count'], 0);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test('DROP TABLE with GET and auth', function(done){
|
||||
assert.response(app, {
|
||||
url: "/api/v1/sql?" + querystring.stringify({
|
||||
|
Loading…
Reference in New Issue
Block a user