Skip to content

Commit a03cd9a

Browse files
pjonssonomad
authored andcommitted
index: fail when no SRID is found
Casting None to integer is not going to make the database happy, so fail when we detect the problem instead.
1 parent 5737151 commit a03cd9a

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

cubedash/index/postgis/_schema.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,8 @@ def init_elements(conn: Connection, grouping_epsg_code: int):
350350

351351
# If they specified an epsg code, make sure the existing schema uses it.
352352
srid = conn.execute(select(FOOTPRINT_SRID_EXPRESSION)).scalar()
353+
if srid is None:
354+
raise RuntimeError("No SRID found in database")
353355
crs_used_by_schema = get_srid_name(conn, srid)
354356
# hopefully default epsg wouldn't case an issue?
355357
if crs_used_by_schema != f"EPSG:{grouping_epsg_code}":

cubedash/index/postgres/_schema.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,8 @@ def init_elements(conn: Connection, grouping_epsg_code: int):
466466

467467
# If they specified an epsg code, make sure the existing schema uses it.
468468
srid = conn.execute(select(FOOTPRINT_SRID_EXPRESSION)).scalar()
469+
if srid is None:
470+
raise RuntimeError("No SRID found in database")
469471
crs_used_by_schema = get_srid_name(conn, srid)
470472
# hopefully default epsg wouldn't case an issue?
471473
if crs_used_by_schema != f"EPSG:{grouping_epsg_code}":

0 commit comments

Comments
 (0)