Nicer error message when missing sql from layer options

Fixes #446
This commit is contained in:
Raul Ochoa 2016-05-11 18:24:47 +02:00
parent bbadd46766
commit 3e4f71d873
3 changed files with 44 additions and 1 deletions

View File

@ -4,6 +4,9 @@
Released 2016-mm-dd
Bug fixes:
- Nicer error message when missing sql from layer options #446
## 2.41.0

View File

@ -13,7 +13,7 @@ var affectedTableRegexCache = {
};
function prepareSql(sql) {
return sql
return sql && sql
.replace(affectedTableRegexCache.bbox, 'ST_MakeEnvelope(0,0,0,0)')
.replace(affectedTableRegexCache.scale_denominator, '0')
.replace(affectedTableRegexCache.pixel_width, '1')

View File

@ -0,0 +1,40 @@
require('../support/test_helper');
var assert = require('../support/assert');
var TestClient = require('../support/test-client');
describe('regressions', function() {
var ERROR_RESPONSE = {
status: 400,
headers: {
'Content-Type': 'application/json; charset=utf-8'
}
};
it('should expose a nice error when missing sql option', function(done) {
var mapConfig = {
version: '1.5.0',
layers: [
{
"type": "cartodb",
"options": {
"cartocss": '#polygons { polygon-fill: red; }',
"cartocss_version": "2.3.0"
}
}
]
};
var testClient = new TestClient(mapConfig, 1234);
testClient.getLayergroup(ERROR_RESPONSE, function(err, layergroupResult) {
assert.ok(!err, err);
assert.equal(layergroupResult.errors.length, 1);
assert.equal(layergroupResult.errors[0], 'Missing sql for layer 0 options');
testClient.drain(done);
});
});
});