From 0ebd12a0eb74aa9f3ec63d5938beb917bbcc8507 Mon Sep 17 00:00:00 2001 From: Rafa de la Torre Date: Tue, 15 Sep 2015 17:18:00 +0200 Subject: [PATCH] Avoid double-escaping of reloid::text #141 --- scripts-available/CDB_CartodbfyTable.sql | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts-available/CDB_CartodbfyTable.sql b/scripts-available/CDB_CartodbfyTable.sql index 3b1611a..08c8065 100644 --- a/scripts-available/CDB_CartodbfyTable.sql +++ b/scripts-available/CDB_CartodbfyTable.sql @@ -932,17 +932,17 @@ BEGIN -- If geom is the wrong name, just rename it. IF gc.has_geom AND gc.has_geom_name != const.geomcol THEN - sql := Format('ALTER TABLE %I DROP COLUMN IF EXISTS %I', reloid::text, const.geomcol); + sql := Format('ALTER TABLE %s DROP COLUMN IF EXISTS %I', reloid::text, const.geomcol); PERFORM _CDB_SQL(sql,'_CDB_Rewrite_Table'); - sql := Format('ALTER TABLE %I RENAME COLUMN %I TO %I', reloid::text, gc.has_geom_name, const.geomcol); + sql := Format('ALTER TABLE %s RENAME COLUMN %I TO %I', reloid::text, gc.has_geom_name, const.geomcol); PERFORM _CDB_SQL(sql,'_CDB_Rewrite_Table'); END IF; -- If mercgeom is the wrong name, just rename it. IF gc.has_mercgeom AND gc.has_mercgeom_name != const.mercgeomcol THEN - sql := Format('ALTER TABLE %I DROP COLUMN IF EXISTS %I', reloid::text, const.mercgeomcol); + sql := Format('ALTER TABLE %s DROP COLUMN IF EXISTS %I', reloid::text, const.mercgeomcol); PERFORM _CDB_SQL(sql,'_CDB_Rewrite_Table'); - sql := Format('ALTER TABLE %s RENAME COLUMN %s TO %s', reloid::text, gc.has_mercgeom_name, const.mercgeomcol); + sql := Format('ALTER TABLE %s RENAME COLUMN %I TO %I', reloid::text, gc.has_mercgeom_name, const.mercgeomcol); PERFORM _CDB_SQL(sql,'_CDB_Rewrite_Table'); END IF;