@@ -504,7 +504,7 @@ BEGIN
|
|||||||
IF rec.atttypid IN (20,21,23) THEN
|
IF rec.atttypid IN (20,21,23) THEN
|
||||||
|
|
||||||
-- And it's a unique primary key! Done!
|
-- And it's a unique primary key! Done!
|
||||||
IF rec.indisprimary AND rec.indisunique AND rec.attnotnull THEN
|
IF (rec.indisprimary OR rec.indisunique) AND rec.attnotnull THEN
|
||||||
RAISE DEBUG 'CDB(_CDB_Has_Usable_Primary_ID): %', Format('found good ''%s''', const.pkey);
|
RAISE DEBUG 'CDB(_CDB_Has_Usable_Primary_ID): %', Format('found good ''%s''', const.pkey);
|
||||||
RETURN true;
|
RETURN true;
|
||||||
|
|
||||||
@@ -1069,7 +1069,7 @@ BEGIN
|
|||||||
-- by selecting their names into an array and
|
-- by selecting their names into an array and
|
||||||
-- joining the array with a comma
|
-- joining the array with a comma
|
||||||
SELECT
|
SELECT
|
||||||
',' || array_to_string(array_agg(a.attname),',') AS column_name_sql,
|
',' || array_to_string(array_agg(Format('%I',a.attname)),',') AS column_name_sql,
|
||||||
Count(*) AS count
|
Count(*) AS count
|
||||||
INTO rec
|
INTO rec
|
||||||
FROM pg_class c
|
FROM pg_class c
|
||||||
|
|||||||
@@ -319,6 +319,30 @@ SELECT CDB_CartodbfyTableCheck('test', 'Table with non unique and null cartodb_i
|
|||||||
SELECT cartodb_id, cartodb_id_0 from test;
|
SELECT cartodb_id, cartodb_id_0 from test;
|
||||||
DROP TABLE test;
|
DROP TABLE test;
|
||||||
|
|
||||||
|
CREATE TABLE test (
|
||||||
|
cartodb_id integer
|
||||||
|
);
|
||||||
|
CREATE UNIQUE INDEX "test_cartodb_id_key" ON test (cartodb_id);
|
||||||
|
CREATE UNIQUE INDEX "test_cartodb_id_pkey" ON test (cartodb_id);
|
||||||
|
ALTER TABLE test ADD CONSTRAINT "test_pkey" PRIMARY KEY USING INDEX test_cartodb_id_pkey;
|
||||||
|
INSERT INTO test VALUES
|
||||||
|
(1),
|
||||||
|
(2),
|
||||||
|
(3);
|
||||||
|
SELECT CDB_CartodbfyTableCheck('test', 'Table with primary key and unique index on it #174');
|
||||||
|
SELECT cartodb_id from test;
|
||||||
|
DROP TABLE test;
|
||||||
|
|
||||||
|
CREATE TABLE test (
|
||||||
|
name varchar,
|
||||||
|
"first.value" integer,
|
||||||
|
"second.value" integer
|
||||||
|
);
|
||||||
|
INSERT INTO test VALUES ('one', 1, 2), ('two', 3, 4);
|
||||||
|
SELECT CDB_CartodbfyTableCheck('test', 'Table with dots in name columns (cartodb #6114)');
|
||||||
|
SELECT name, "first.value" from test;
|
||||||
|
DROP TABLE test;
|
||||||
|
|
||||||
SET client_min_messages TO notice;
|
SET client_min_messages TO notice;
|
||||||
-- _CDB_create_cartodb_id_column with cartodb_id integer already present
|
-- _CDB_create_cartodb_id_column with cartodb_id integer already present
|
||||||
CREATE TABLE test (cartodb_id integer);
|
CREATE TABLE test (cartodb_id integer);
|
||||||
|
|||||||
@@ -102,6 +102,22 @@ Table with non unique and null cartodb_id #148 cartodbfied fine
|
|||||||
3|
|
3|
|
||||||
4|2
|
4|2
|
||||||
DROP TABLE
|
DROP TABLE
|
||||||
|
CREATE TABLE
|
||||||
|
CREATE INDEX
|
||||||
|
CREATE INDEX
|
||||||
|
ALTER TABLE
|
||||||
|
INSERT 0 3
|
||||||
|
Table with primary key and unique index on it #174 cartodbfied fine
|
||||||
|
1
|
||||||
|
2
|
||||||
|
3
|
||||||
|
DROP TABLE
|
||||||
|
CREATE TABLE
|
||||||
|
INSERT 0 2
|
||||||
|
Table with dots in name columns (cartodb #6114) cartodbfied fine
|
||||||
|
one|1
|
||||||
|
two|3
|
||||||
|
DROP TABLE
|
||||||
SET
|
SET
|
||||||
CREATE TABLE
|
CREATE TABLE
|
||||||
NOTICE: Column cartodb_id already exists
|
NOTICE: Column cartodb_id already exists
|
||||||
|
|||||||
Reference in New Issue
Block a user