Skip to content

Commit d0910d9

Browse files
Merge pull request #28 from geoCML/boolean-ignore-rasters
Support boolean data types + ignore raster layers
2 parents 8dbf3a7 + 2184f2b commit d0910d9

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

src/db_connector.py

+10
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,19 @@ def get_tables(self) -> list[str]:
1717
self.cursor.execute("""SELECT schema_name FROM information_schema.schemata WHERE schema_name != 'pg_catalog' AND schema_name != 'information_schema';""")
1818
schemata = self.cursor.fetchall()
1919

20+
try:
21+
self.cursor.execute("""SELECT * FROM raster_columns;""")
22+
has_rasters = True
23+
except:
24+
has_rasters = False
25+
2026
for schema in schemata:
2127
self.cursor.execute(f"""SELECT table_name FROM information_schema.tables WHERE table_schema = '{schema[0]}'""")
2228
for table in self.cursor.fetchall():
29+
if has_rasters:
30+
self.cursor.execute(f"""SELECT * FROM raster_columns WHERE r_table_name = '{table[0]}' AND r_table_schema = '{schema[0]}';""")
31+
if self.cursor.fetchone():
32+
continue
2333
tables.append(f"{schema[0]}.{table[0]}")
2434

2535
return tables

src/tabor_field_type.py

+14-2
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@ class TaborFieldType(object):
22
postgres_integer_types = ("smallint", "integer", "bigint", "int2", "int4", "int8")
33
postgres_numerical_types = ("double precision", "float", "numeric")
44
postgres_text_types = ("character varying", "name", "text")
5+
postgres_binary_types = ("boolean")
6+
postgres_collection_types = ("TEXT ARRAY", "text array") # TODO: https://github.com/geoCML/tabor/issues/27
7+
postgres_generic_types = ("USER-DEFINED", "user-defined") # TODO: https://github.com/geoCML/tabor/issues/26
58

69
def __init__(self, type: str):
7-
self.valid_types = ("text", "int", "numeric")
10+
self.valid_types = ("text", "int", "numeric", "boolean", "text array", "user-defined")
811
if type != "":
912
self.set_type(type)
1013

1114

12-
def convert_postgres_type_to_tabor_field_type(self, type):
15+
def convert_postgres_type_to_tabor_field_type(self, type: str) -> str:
1316
if type in self.postgres_integer_types:
1417
return "int"
1518

@@ -19,6 +22,15 @@ def convert_postgres_type_to_tabor_field_type(self, type):
1922
if type in self.postgres_numerical_types:
2023
return "numeric"
2124

25+
if type in self.postgres_binary_types:
26+
return "boolean"
27+
28+
if type in self.postgres_collection_types:
29+
return type.lower()
30+
31+
if type in self.postgres_generic_types:
32+
return "user-defined"
33+
2234
return type
2335

2436

0 commit comments

Comments
 (0)