From cce63f0eaeec8be4d0b416e1d492adf5ae124ab2 Mon Sep 17 00:00:00 2001 From: Guido Fioravantti Date: Fri, 6 Nov 2015 16:26:03 +0100 Subject: [PATCH] Adds ::integer cast for USING 155 --- scripts-available/CDB_CartodbfyTable.sql | 2 +- test/CDB_CartodbfyTableTest_expect | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts-available/CDB_CartodbfyTable.sql b/scripts-available/CDB_CartodbfyTable.sql index 44127c7..4d44c22 100644 --- a/scripts-available/CDB_CartodbfyTable.sql +++ b/scripts-available/CDB_CartodbfyTable.sql @@ -152,7 +152,7 @@ BEGIN -- Copy existing values to new field -- NOTE: using ALTER is a workaround to a PostgreSQL bug and is also known to be faster for tables with many rows -- See http://www.postgresql.org/message-id/20140530143150.GA11051@localhost - sql := Format('ALTER TABLE %s ALTER cartodb_id TYPE int USING %I', reloid::text, new_name); + sql := Format('ALTER TABLE %s ALTER cartodb_id TYPE int USING %I::integer', reloid::text, new_name); RAISE DEBUG 'Running %', sql; EXECUTE sql; diff --git a/test/CDB_CartodbfyTableTest_expect b/test/CDB_CartodbfyTableTest_expect index 5c464ad..a3057fb 100644 --- a/test/CDB_CartodbfyTableTest_expect +++ b/test/CDB_CartodbfyTableTest_expect @@ -113,7 +113,6 @@ CREATE TABLE NOTICE: Column cartodb_id already exists NOTICE: Existing cartodb_id field is of invalid type text (need int2, int4 or int8), renaming NOTICE: Trying to recover data from _cartodb_id0 column -NOTICE: Could not initialize cartodb_id with existing values: result of USING clause for column "cartodb_id" cannot be cast automatically to type integer (42804) _cartodb_id0 DROP TABLE