Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use DS exception safe API functions #243

Merged
merged 2 commits into from
Dec 19, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/node/nodes/georeference-admin-region.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ GeoreferenceAdminRegion.prototype.getFunctionParam = function (name) {
var queryTemplate = Node.template([
'SELECT',
' {{=it.columns}},',
' cdb_dataservices_client.cdb_geocode_admin1_polygon(' +
' cdb_dataservices_client._cdb_geocode_admin1_polygon_exception_safe(' +
' {{=it.geocoder_params}}',
' ) AS the_geom',
'FROM ({{=it.source}}) AS _camshaft_georeference_admin_region_analysis'
Expand Down
2 changes: 1 addition & 1 deletion lib/node/nodes/georeference-city.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ GeoreferenceCity.prototype.getFunctionParam = function (name) {
var queryTemplate = Node.template([
'SELECT',
' {{=it.columns}},',
' cdb_dataservices_client.cdb_geocode_namedplace_point(' +
' cdb_dataservices_client._cdb_geocode_namedplace_point_exception_safe(' +
' {{=it.geocoder_params}}',
' ) AS the_geom',
'FROM ({{=it.source}}) AS _camshaft_georeference_city_analysis'
Expand Down
2 changes: 1 addition & 1 deletion lib/node/nodes/georeference-country.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ GeoreferenceCountry.prototype.sql = function() {
var queryTemplate = Node.template([
'SELECT',
' {{=it.columns}},',
' cdb_dataservices_client.cdb_geocode_admin0_polygon({{=it.country}}) AS the_geom',
' cdb_dataservices_client._cdb_geocode_admin0_polygon_exception_safe({{=it.country}}) AS the_geom',
'FROM ({{=it.source}}) AS _camshaft_georeference_country_analysis'
].join('\n'));

Expand Down
2 changes: 1 addition & 1 deletion lib/node/nodes/georeference-ip-address.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ GeoreferenceIpAddress.prototype.sql = function() {
var queryTemplate = Node.template([
'SELECT',
' {{=it.columns}},',
' cdb_dataservices_client.cdb_geocode_ipaddress_point(' +
' cdb_dataservices_client._cdb_geocode_ipaddress_point_exception_safe(' +
' {{=it.ip_address}}',
' ) AS the_geom',
'FROM ({{=it.source}}) AS _camshaft_georeference_ip_address_analysis'
Expand Down
8 changes: 4 additions & 4 deletions lib/node/nodes/georeference-postal-code.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ GeoreferencePostalCode.prototype.getFunctionParam = function (name) {
function getGecoderFunction(geometryType) {
switch (geometryType){
case Node.GEOMETRY.POLYGON:
return 'cdb_geocode_postalcode_polygon';
return '_cdb_geocode_postalcode_polygon_exception_safe';
case Node.GEOMETRY.POINT:
return 'cdb_geocode_postalcode_point';
return '_cdb_geocode_postalcode_point_exception_safe';
default:
return 'cdb_geocode_postalcode_point';
return '_cdb_geocode_postalcode_point_exception_safe';
}
}

Expand All @@ -82,7 +82,7 @@ var queryTemplate = Node.template([
GeoreferencePostalCode.prototype.checkLimits = function(context, callback) {
var defaultLimit;
var limitName;
if (getGecoderFunction(this.output_geometry_type) === 'cdb_geocode_postalcode_polygon') {
if (getGecoderFunction(this.output_geometry_type) === '_cdb_geocode_postalcode_polygon_exception_safe') {
defaultLimit = 10000;
limitName = 'maximumNumberOfRowsPolygon';
}
Expand Down
2 changes: 1 addition & 1 deletion lib/node/nodes/georeference-street-address.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ GeoreferenceStreetAddress.prototype.getFunctionParam = function (name) {
var queryTemplate = Node.template([
'SELECT',
' {{=it.columns}},',
' cdb_dataservices_client.cdb_geocode_street_point(' +
' cdb_dataservices_client._cdb_geocode_street_point_exception_safe(' +
' {{=it.params}}',
' ) AS the_geom',
'FROM ({{=it.source}}) AS _camshaft_georeference_street_address_analysis'
Expand Down
2 changes: 1 addition & 1 deletion lib/node/nodes/routing-sequential.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ var routingSequentialQueryTemplate = Node.template([
' (route).the_geom',
'FROM (',
' SELECT',
' cdb_dataservices_client.cdb_route_with_waypoints(',
' cdb_dataservices_client._cdb_route_with_waypoints_exception_safe(',
' array_agg({{=it.column_target}}),',
' \'{{=it.mode}}\',',
' ARRAY[\'mode_type={{=it.mode_type}}\']::text[],',
Expand Down
2 changes: 1 addition & 1 deletion lib/node/nodes/routing-to-layer-all-to-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ var routingToLayerQueryTemplate = Node.template([
' {{=it.final_columns}}',
'FROM (',
' SELECT',
' cdb_dataservices_client.cdb_route_point_to_point(',
' cdb_dataservices_client._cdb_route_point_to_point_exception_safe(',
' _cdb_analysis_source.the_geom,',
' _cdb_analysis_target.the_geom,',
' \'{{=it.mode}}\',',
Expand Down
2 changes: 1 addition & 1 deletion lib/node/nodes/routing-to-single-point.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var routingToSinglePointQueryTemplate = Node.template([
' {{=it.columns}}',
'FROM (',
' SELECT',
' cdb_dataservices_client.cdb_route_point_to_point(',
' cdb_dataservices_client._cdb_route_point_to_point_exception_safe(',
' the_geom,',
' ST_SetSRID(',
' ST_MakePoint(',
Expand Down
2 changes: 1 addition & 1 deletion lib/node/nodes/sql/trade-area-dissolved.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ _cdb_analysis_source_points AS (
),
_cdb_analysis_isochrones AS (
SELECT
cdb_dataservices_client.cdb_isochrone(
cdb_dataservices_client._cdb_isochrone_exception_safe(
_cdb_analysis_source_points.the_geom,
'{{=it.kind}}'::text,
ARRAY[{{=it.isolines}}]::integer[]
Expand Down
2 changes: 1 addition & 1 deletion lib/node/nodes/sql/trade-area.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ _cdb_analysis_source_points AS (
),
_cdb_analysis_isochrones AS (
SELECT
cdb_dataservices_client.cdb_isochrone(
cdb_dataservices_client._cdb_isochrone_exception_safe(
_cdb_analysis_source_points.the_geom,
'{{=it.kind}}',
ARRAY[{{=it.isolines}}]::integer[]
Expand Down
18 changes: 9 additions & 9 deletions test/fixtures/cdb_dataservices_client/cdb_geocoder.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---- cdb_geocode_namedplace_point(city_name text, admin1_name text, country_name text)
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_geocode_namedplace_point(city_name text, admin1_name text, country_name text)
---- _cdb_geocode_namedplace_point_exception_safe(city_name text, admin1_name text, country_name text)
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_geocode_namedplace_point_exception_safe(city_name text, admin1_name text, country_name text)
RETURNS Geometry AS $$
DECLARE
ret Geometry;
Expand All @@ -12,8 +12,8 @@ RETURNS Geometry AS $$
END
$$ LANGUAGE plpgsql;

---- cdb_geocode_admin1_polygon(admin1_name text, country_name text)
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_geocode_admin1_polygon(admin1_name text, country_name text)
---- _cdb_geocode_admin1_polygon_exception_safe(admin1_name text, country_name text)
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_geocode_admin1_polygon_exception_safe(admin1_name text, country_name text)
RETURNS Geometry AS $$
DECLARE
ret Geometry;
Expand All @@ -37,8 +37,8 @@ RETURNS Geometry AS $$
END
$$ LANGUAGE plpgsql;

---- cdb_geocode_postalcode_polygon(postal_code text, country_name text)
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_geocode_postalcode_polygon(postal_code text, country_name text)
---- _cdb_geocode_postalcode_polygon_exception_safe(postal_code text, country_name text)
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_geocode_postalcode_polygon_exception_safe(postal_code text, country_name text)
RETURNS Geometry AS $$
DECLARE
ret Geometry;
Expand All @@ -62,8 +62,8 @@ RETURNS Geometry AS $$
END
$$ LANGUAGE plpgsql;

---- cdb_geocode_ipaddress_point(ip text)
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_geocode_ipaddress_point(ip text)
---- _cdb_geocode_ipaddress_point_exception_safe(ip text)
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_geocode_ipaddress_point_exception_safe(ip text)
RETURNS Geometry AS $$
DECLARE
i INTEGER := 0;
Expand Down Expand Up @@ -101,7 +101,7 @@ RETURNS Geometry AS $$
END
$$ LANGUAGE plpgsql;

CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_geocode_street_point(searchtext TEXT, city TEXT DEFAULT NULL, state_province TEXT DEFAULT NULL, country TEXT DEFAULT NULL)
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_geocode_street_point_exception_safe(searchtext TEXT, city TEXT DEFAULT NULL, state_province TEXT DEFAULT NULL, country TEXT DEFAULT NULL)
RETURNS Geometry AS $$
DECLARE
ret Geometry;
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/cdb_dataservices_client/cdb_isochrone.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_isochrone(center GEOMETRY, kind TEXT, range INTEGER[], OUT center geometry, OUT data_range integer, OUT the_geom geometry)
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_isochrone_exception_safe(center GEOMETRY, kind TEXT, range INTEGER[], OUT center geometry, OUT data_range integer, OUT the_geom geometry)
AS $$
SELECT
$1 center,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_route_point_to_point(origin GEOMETRY, destination GEOMETRY, mode TEXT, options TEXT[], units TEXT, OUT duration integer, OUT length real, OUT the_geom geometry)
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_route_point_to_point_exception_safe(origin GEOMETRY, destination GEOMETRY, mode TEXT, options TEXT[], units TEXT, OUT duration integer, OUT length real, OUT the_geom geometry)
AS $$
SELECT
trunc(random() * 1000)::integer duration,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_route_with_waypoints(
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_route_with_waypoints_exception_safe(
waypoints geometry(Point, 4326)[],
mode TEXT,
options text[] DEFAULT ARRAY[]::text[],
Expand Down