diff --git a/scripts-available/CDB_FederatedServerTables.sql b/scripts-available/CDB_FederatedServerTables.sql index 2dfe519..39b0f2c 100644 --- a/scripts-available/CDB_FederatedServerTables.sql +++ b/scripts-available/CDB_FederatedServerTables.sql @@ -214,9 +214,11 @@ BEGIN RAISE EXCEPTION 'Remote table name cannot be NULL'; END IF; - -- Use geom_column as default for webmercator_column + -- Make do with whatever columns are provided IF webmercator_column IS NULL THEN webmercator_column := geom_column; + ELSIF geom_column IS NULL THEN + geom_column := webmercator_column; END IF; IF local_name IS NULL THEN diff --git a/test/CDB_FederatedServerTables.sql b/test/CDB_FederatedServerTables.sql index cedd6b1..5941553 100644 --- a/test/CDB_FederatedServerTables.sql +++ b/test/CDB_FederatedServerTables.sql @@ -213,14 +213,17 @@ SELECT cartodb.CDB_Federated_Table_Register( geom_column => 'Does not exists' ); -\echo '## Registering a table: NULL geom_column is OK' +\echo '## Registering a table: NULL geom_column is OK: Reuses geom_mercator' SELECT cartodb.CDB_Federated_Table_Register( server => 'loopback', remote_schema => 'remote_schema', remote_table => 'remote_geom', id_column => 'id', - geom_column => NULL::text + geom_column => NULL::text, + webmercator_column => 'geom' ); +SELECT * FROM cartodb.CDB_Federated_Server_List_Remote_Tables(server => 'loopback', remote_schema => 'remote_schema') where remote_table = 'remote_geom'; + SELECT cartodb.CDB_Federated_Table_Unregister( server => 'loopback', remote_schema => 'remote_schema', @@ -237,7 +240,7 @@ SELECT cartodb.CDB_Federated_Table_Register( webmercator_column => 'Does not exists' ); -\echo '## Registering a table: NULL webmercator_column is OK' +\echo '## Registering a table: NULL webmercator_column is OK: Reuses geom' SELECT cartodb.CDB_Federated_Table_Register( server => 'loopback', remote_schema => 'remote_schema', @@ -246,6 +249,7 @@ SELECT cartodb.CDB_Federated_Table_Register( geom_column => 'geom', webmercator_column => NULL::text ); +SELECT * FROM cartodb.CDB_Federated_Server_List_Remote_Tables(server => 'loopback', remote_schema => 'remote_schema') where remote_table = 'remote_geom'; SELECT cartodb.CDB_Federated_Table_Unregister( server => 'loopback', remote_schema => 'remote_schema', diff --git a/test/CDB_FederatedServerTables_expect b/test/CDB_FederatedServerTables_expect index 9fbeabd..df646d8 100644 --- a/test/CDB_FederatedServerTables_expect +++ b/test/CDB_FederatedServerTables_expect @@ -43,13 +43,15 @@ ERROR: non integer id_column "Does not exist" ERROR: non integer id_column "" ## Registering a table: Invalid geom_column fails ERROR: non geometry column "Does not exists" -## Registering a table: NULL geom_column is OK +## Registering a table: NULL geom_column is OK: Reuses geom_mercator +t|remote_geom|cdb_fs_loopback.remote_geom|id|geom|geom|[{"Name" : "another_field", "Type" : "text"}, {"Name" : "geom", "Type" : "GEOMETRY,4326"}, {"Name" : "id", "Type" : "integer"}] ## Registering a table: Invalid webmercator_column fails ERROR: non geometry column "Does not exists" -## Registering a table: NULL webmercator_column is OK +## Registering a table: NULL webmercator_column is OK: Reuses geom +t|remote_geom|cdb_fs_loopback.remote_geom|id|geom|geom|[{"Name" : "another_field", "Type" : "text"}, {"Name" : "geom", "Type" : "GEOMETRY,4326"}, {"Name" : "id", "Type" : "integer"}] ##Registering a table with extra columns show the correct information