From 8a031f56f56c0ea01bcc5f26888021bd0d1039a3 Mon Sep 17 00:00:00 2001 From: Rafa de la Torre Date: Wed, 12 Aug 2015 15:58:30 +0000 Subject: [PATCH] Recover test for cartodb_id not-null constraint --- test/CDB_CartodbfyTableTest.sql | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/CDB_CartodbfyTableTest.sql b/test/CDB_CartodbfyTableTest.sql index 7926d95..eafb79b 100644 --- a/test/CDB_CartodbfyTableTest.sql +++ b/test/CDB_CartodbfyTableTest.sql @@ -102,6 +102,15 @@ BEGIN RAISE EXCEPTION '% gist indices found on the_geom and the_geom_webmercator, expected 2', tmp; END IF; + -- Check null constraint on cartodb_id, created_at, updated_at + SELECT count(*) FROM pg_attribute a, pg_class c WHERE c.oid = tabname::oid + AND a.attrelid = c.oid AND NOT a.attisdropped AND a.attname in + ( 'cartodb_id' ) + AND NOT a.attnotnull INTO strict tmp; + IF tmp > 0 THEN + RAISE EXCEPTION 'cartodb_id is missing not-null constraint'; + END IF; + -- Cleanup sql := 'DELETE FROM ' || tabname::text || ' WHERE cartodb_id = ' || id; EXECUTE sql;