From 7559257d49ea70f1dfe526174c9716b71c82d8d5 Mon Sep 17 00:00:00 2001 From: Carla Iriberri Date: Tue, 1 Mar 2016 17:45:15 +0100 Subject: [PATCH] cartodb_id string tests --- test/CDB_CartodbfyTableTest.sql | 26 ++++++++++++++++---------- test/CDB_CartodbfyTableTest_expect | 12 ++++++++++++ 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/test/CDB_CartodbfyTableTest.sql b/test/CDB_CartodbfyTableTest.sql index 08d1a17..e9ebd82 100644 --- a/test/CDB_CartodbfyTableTest.sql +++ b/test/CDB_CartodbfyTableTest.sql @@ -165,18 +165,24 @@ SELECT 'extent',ST_Extent(ST_SnapToGrid(the_geom,0.2)) FROM t; DROP TABLE t; -- INFO: disabled because cartodbfy does not longer consider text columns for primary ID --- -- table with existing cartodb_id field of type text --- CREATE TABLE t AS SELECT 10::text as cartodb_id; --- SELECT CDB_CartodbfyTableCheck('t', 'text cartodb_id'); --- select cartodb_id/2 FROM t; --- DROP TABLE t; +-- table with existing cartodb_id field of type text +CREATE TABLE t AS SELECT 10::text as cartodb_id; +SELECT CDB_CartodbfyTableCheck('t', 'text cartodb_id'); +select cartodb_id/2 FROM t; +DROP TABLE t; -- INFO: disabled because cartodbfy does not longer consider text columns for primary ID --- -- table with existing cartodb_id field of type text not casting --- CREATE TABLE t AS SELECT 'nan' as cartodb_id; --- SELECT CDB_CartodbfyTableCheck('t', 'uncasting text cartodb_id'); --- select cartodb_id,_cartodb_id0 FROM t; --- DROP TABLE t; +-- table with existing cartodb_id field of type text not casting +CREATE TABLE t AS SELECT 'nan' as cartodb_id; +SELECT CDB_CartodbfyTableCheck('t', 'uncasting text cartodb_id'); +select cartodb_id,cartodb_id_0 FROM t; +DROP TABLE t; + +-- table with empty cartodb_id field of type text +CREATE TABLE t AS SELECT null::text as cartodb_id; +SELECT CDB_CartodbfyTableCheck('t', 'empty text cartodb_id'); +select cartodb_id,cartodb_id_0 FROM t; +DROP TABLE t; -- table with existing cartodb_id field of type int4 not sequenced CREATE TABLE t AS SELECT 1::int4 as cartodb_id; diff --git a/test/CDB_CartodbfyTableTest_expect b/test/CDB_CartodbfyTableTest_expect index 0b7419f..206c1a3 100644 --- a/test/CDB_CartodbfyTableTest_expect +++ b/test/CDB_CartodbfyTableTest_expect @@ -28,6 +28,18 @@ trigger-protected the_geom cartodbfied fine extent|BOX(1 1,2 2) DROP TABLE SELECT 1 +text cartodb_id cartodbfied fine +0 +DROP TABLE +SELECT 1 +uncasting text cartodb_id cartodbfied fine +1|nan +DROP TABLE +SELECT 1 +empty text cartodb_id cartodbfied fine +1| +DROP TABLE +SELECT 1 unsequenced cartodb_id cartodbfied fine 1 DROP TABLE