diff --git a/NEWS.md b/NEWS.md index 9eeb06e3..041491ef 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,7 +4,14 @@ Released 2016-mm-dd -Adds support for sql wrap in all layers +Announcements: + - Upgrades turbo-carto to [0.10.0](https://github.com/CartoDB/turbo-carto/releases/tag/0.10.0) + +New features: + - Adds support for sql wrap in all layers + +Bug fixes: + - Fail on turbo-carto invalid quantification methods ## 2.43.1 diff --git a/lib/cartodb/utils/style/postgres-datasource.js b/lib/cartodb/utils/style/postgres-datasource.js index 5db35607..447c9143 100644 --- a/lib/cartodb/utils/style/postgres-datasource.js +++ b/lib/cartodb/utils/style/postgres-datasource.js @@ -38,7 +38,12 @@ PostgresDatasource.prototype.getName = function () { }; PostgresDatasource.prototype.getRamp = function (column, buckets, method, callback) { - var methodName = methods.hasOwnProperty(method) ? method : 'quantiles'; + if (method && !methodTemplates.hasOwnProperty(method)) { + return callback(new Error( + 'Invalid method "' + method + '", valid methods: [' + Object.keys(methodTemplates).join(',') + ']' + )); + } + var methodName = method || 'quantiles'; var template = methodTemplates[methodName]; var query = template({ _column: column, _sql: this.query, _buckets: buckets }); diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 04f931c5..512abfc7 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -33,9 +33,9 @@ "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz" }, "statuses": { - "version": "1.2.1", + "version": "1.3.0", "from": "statuses@>=1.0.0 <2.0.0", - "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.2.1.tgz" + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.3.0.tgz" } } }, @@ -79,9 +79,9 @@ } }, "type-is": { - "version": "1.6.12", - "from": "type-is@>=1.6.6 <1.7.0", - "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.12.tgz", + "version": "1.6.13", + "from": "type-is@>=1.6.10 <1.7.0", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.13.tgz", "dependencies": { "media-typer": { "version": "0.3.0", @@ -90,7 +90,7 @@ }, "mime-types": { "version": "2.1.11", - "from": "mime-types@>=2.1.10 <2.2.0", + "from": "mime-types@>=2.1.2 <2.2.0", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.11.tgz", "dependencies": { "mime-db": { @@ -762,9 +762,9 @@ "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.10.2.tgz" }, "type-is": { - "version": "1.6.12", + "version": "1.6.13", "from": "type-is@>=1.6.6 <1.7.0", - "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.12.tgz", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.13.tgz", "dependencies": { "media-typer": { "version": "0.3.0", @@ -988,7 +988,7 @@ }, "mime-types": { "version": "2.1.11", - "from": "mime-types@>=2.1.10 <2.2.0", + "from": "mime-types@>=2.1.2 <2.2.0", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.11.tgz", "dependencies": { "mime-db": { @@ -1215,9 +1215,9 @@ "from": "step-profiler@>=0.3.0 <0.4.0" }, "turbo-carto": { - "version": "0.9.2", - "from": "turbo-carto@0.9.2", - "resolved": "https://registry.npmjs.org/turbo-carto/-/turbo-carto-0.9.2.tgz", + "version": "0.10.0", + "from": "turbo-carto@0.10.0", + "resolved": "https://registry.npmjs.org/turbo-carto/-/turbo-carto-0.10.0.tgz", "dependencies": { "colorbrewer": { "version": "1.0.0", @@ -2954,16 +2954,16 @@ "from": "asn1@>=0.2.3 <0.3.0", "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz" }, - "async": { - "version": "1.5.2", - "from": "async@>=1.5.2 <2.0.0", - "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz" - }, "assert-plus": { "version": "0.2.0", "from": "assert-plus@>=0.2.0 <0.3.0", "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.2.0.tgz" }, + "async": { + "version": "1.5.2", + "from": "async@>=1.5.2 <2.0.0", + "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz" + }, "aws-sign2": { "version": "0.6.0", "from": "aws-sign2@>=0.6.0 <0.7.0", @@ -3199,16 +3199,16 @@ "from": "jsbn@>=0.1.0 <0.2.0", "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.0.tgz" }, - "json-schema": { - "version": "0.2.2", - "from": "json-schema@0.2.2", - "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.2.tgz" - }, "json-stringify-safe": { "version": "5.0.1", "from": "json-stringify-safe@>=5.0.1 <5.1.0", "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz" }, + "json-schema": { + "version": "0.2.2", + "from": "json-schema@0.2.2", + "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.2.tgz" + }, "jsonpointer": { "version": "2.0.0", "from": "jsonpointer@2.0.0", @@ -3299,16 +3299,16 @@ "from": "oauth-sign@>=0.8.1 <0.9.0", "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz" }, - "once": { - "version": "1.3.3", - "from": "once@>=1.3.0 <2.0.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.3.3.tgz" - }, "path-is-absolute": { "version": "1.0.0", "from": "path-is-absolute@>=1.0.0 <2.0.0", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.0.tgz" }, + "once": { + "version": "1.3.3", + "from": "once@>=1.3.0 <2.0.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.3.3.tgz" + }, "pinkie": { "version": "2.0.4", "from": "pinkie@>=2.0.0 <3.0.0", @@ -3339,16 +3339,16 @@ "from": "request@>=2.0.0 <3.0.0", "resolved": "https://registry.npmjs.org/request/-/request-2.72.0.tgz" }, - "rimraf": { - "version": "2.5.2", - "from": "rimraf@>=2.5.0 <2.6.0", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.5.2.tgz" - }, "semver": { "version": "5.1.0", "from": "semver@>=5.1.0 <5.2.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.1.0.tgz" }, + "rimraf": { + "version": "2.5.2", + "from": "rimraf@>=2.5.0 <2.6.0", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.5.2.tgz" + }, "sntp": { "version": "1.0.9", "from": "sntp@>=1.0.0 <2.0.0", diff --git a/package.json b/package.json index c426011b..57f219c5 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "request": "~2.62.0", "step": "~0.0.6", "step-profiler": "~0.3.0", - "turbo-carto": "0.9.2", + "turbo-carto": "0.10.0", "underscore": "~1.6.0", "windshaft": "1.19.0" }, diff --git a/test/acceptance/turbo-cartocss/anonymous-maps.js b/test/acceptance/turbo-cartocss/anonymous-maps.js index 82801815..c0fcbda4 100644 --- a/test/acceptance/turbo-cartocss/anonymous-maps.js +++ b/test/acceptance/turbo-cartocss/anonymous-maps.js @@ -53,6 +53,20 @@ describe('turbo-carto for anonymous maps', function() { var fixturePath = 'test_turbo_carto_greens_13_4011_3088.png'; this.testClient.getTile(13, 4011, 3088, imageCompareFn(fixturePath, done)); }); + + it('should work for different char case in quantification names', function(done) { + this.testClient = new TestClient( + makeMapconfig('#layer { marker-fill: ramp([price], colorbrewer(Greens, 3), jeNkS); }') + ); + this.testClient.getLayergroup(function(err, layergroup) { + assert.ok(!err, err); + + assert.ok(layergroup.hasOwnProperty('layergroupid')); + assert.ok(!layergroup.hasOwnProperty('errors')); + + done(); + }); + }); }); describe('parsing ramp function with colorbrewer for reds and mapnik renderer', function () { diff --git a/test/acceptance/turbo-cartocss/error-cases.js b/test/acceptance/turbo-cartocss/error-cases.js index f43a3636..3967738b 100644 --- a/test/acceptance/turbo-cartocss/error-cases.js +++ b/test/acceptance/turbo-cartocss/error-cases.js @@ -78,6 +78,21 @@ describe('turbo-carto error cases', function() { }); }); + it('should return invalid method from datasource', function(done) { + this.testClient = new TestClient(makeMapconfig(null, 'ramp([wadus_column], (red, green, blue), wadusmethod)')); + this.testClient.getLayergroup(ERROR_RESPONSE, function(err, layergroup) { + assert.ok(!err, err); + + assert.ok(layergroup.hasOwnProperty('errors')); + assert.equal(layergroup.errors.length, 1); + assert.ok(layergroup.errors[0].match(/^turbo-carto/)); + assert.ok(layergroup.errors[0].match(/unable\sto\scompute\sramp/i)); + assert.ok(layergroup.errors[0].match(/invalid\smethod\s\"wadusmethod\"/i)); + + done(); + }); + }); + it('should fail by falling back to normal carto parser', function(done) { this.testClient = new TestClient(makeMapconfig('ramp([price], (8,24,96), (8,24,96));//(red, green, blue))')); this.testClient.getLayergroup(ERROR_RESPONSE, function(err, layergroup) {