diff --git a/scripts-available/CDB_CartodbfyTable.sql b/scripts-available/CDB_CartodbfyTable.sql index 849238e..172c372 100644 --- a/scripts-available/CDB_CartodbfyTable.sql +++ b/scripts-available/CDB_CartodbfyTable.sql @@ -166,7 +166,7 @@ BEGIN AS seq INTO rec2; -- Reset sequence name - sql := Format('ALTER SEQUENCE %s RESTART WITH %d', rec2.seq::text, rec.max + 1); + sql := Format('ALTER SEQUENCE %s RESTART WITH %', rec2.seq::text, rec.max + 1); RAISE DEBUG 'Running %', sql; EXECUTE sql; diff --git a/test/CDB_CartodbfyTableTest.sql b/test/CDB_CartodbfyTableTest.sql index fc6bd8a..280e8c5 100644 --- a/test/CDB_CartodbfyTableTest.sql +++ b/test/CDB_CartodbfyTableTest.sql @@ -319,6 +319,13 @@ SELECT CDB_CartodbfyTableCheck('test', 'Table with non unique and null cartodb_i SELECT cartodb_id, cartodb_id_0 from test; DROP TABLE test; +-- _CDB_create_cartodb_id_column with cartodb_id already present +CREATE TABLE test (cartodb_id integer); + +SELECT _CDB_Create_Cartodb_ID_Column('test'::regclass); +SELECT column_name FROM information_schema.columns WHERE table_name = 'test' AND column_name = '_cartodb_id0'; + +DROP TABLE test; -- TODO: table with existing custom-triggered the_geom diff --git a/test/CDB_CartodbfyTableTest_expect b/test/CDB_CartodbfyTableTest_expect index 6103dc8..0e866e9 100644 --- a/test/CDB_CartodbfyTableTest_expect +++ b/test/CDB_CartodbfyTableTest_expect @@ -102,5 +102,9 @@ Table with non unique and null cartodb_id #148 cartodbfied fine 3| 4|2 DROP TABLE +CREATE TABLE + +_cartodb_id0 +DROP TABLE DROP FUNCTION DROP FUNCTION