Skip to content

Commit

Permalink
Fix incorrect geom types (#175)
Browse files Browse the repository at this point in the history
  • Loading branch information
margrietpalm authored Jan 23, 2025
1 parent fcc6590 commit 3913032
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Changelog of threedi-schema
0.230.3 (unreleased)
--------------------

- Nothing changed yet.
- Fix invalid setting of geometry types for lateral_2d and boundary_condition_2d


0.230.2 (2025-01-23)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,16 +189,16 @@ def rename_columns(table_name: str, columns: List[Tuple[str, str]]):
if entry['name'] in ["geom", "id"]:
entry_string += f" NOT NULL"
new_columns_list_sql_formatted.append(entry_string)

temp_name = f'_temp_225_{uuid.uuid4().hex}'
create_table_query = f"""CREATE TABLE {temp_name} ({', '.join(new_columns_list_sql_formatted)});"""
op.execute(sa.text(create_table_query))
op.execute(sa.text(f"INSERT INTO {temp_name} ({','.join(new_columns_list)}) SELECT {','.join(old_columns_list)} from {table_name};"))
drop_geo_table(op, table_name)
op.execute(sa.text(f"ALTER TABLE {temp_name} RENAME TO {table_name};"))

for entry in new_columns:
if entry["name"] == "geom":
op.execute(sa.text(f"""SELECT RecoverGeometryColumn('{table_name}', '{GEOMETRY_TYPES[table_name]}', 4326, '{entry["type"]}', 'XY')"""))
if table_name is not GEOMETRY_TYPES:
op.execute(sa.text(f"""SELECT RecoverGeometryColumn('{table_name}', 'geom', 4326, '{GEOMETRY_TYPES[table_name]}', 'XY')"""))



Expand Down

0 comments on commit 3913032

Please sign in to comment.