Skip to content

Commit

Permalink
AB#101818 Fix exports for temporal relations defined as plain string
Browse files Browse the repository at this point in the history
  • Loading branch information
jjmurre committed Dec 19, 2023
1 parent dc0d70e commit 6aa0e81
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 2023-12-15 (5.20.1)

* Some old definitions (gebieden.stadsdelen) are using temporal relations
defined as a plain string instead of an objects. The exporter
need to take this into account.

# 2023-12-15 (5.20.0)

* Change export to only use active records for csv and jsonlines,
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = amsterdam-schema-tools
version = 5.20.0
version = 5.20.1
url = https://github.com/amsterdam/schema-tools
license = Mozilla Public 2.0
author = Team Data Diensten, van het Dataplatform onder de Directie Digitale Voorzieningen (Gemeente Amsterdam)
Expand Down
9 changes: 8 additions & 1 deletion src/schematools/exports/csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,14 @@ def geo_modifier(field: DatasetFieldSchema, column):
return gfunc.ST_AsEWKT(column).label(field.db_name)

def id_modifier(field: DatasetFieldSchema, column):
if field.table.is_temporal and field.is_composite_key:
# We need an extra check for old relation definitions
# that are defined as plain strings in the amsterdam schema
# and not as objects.
if field.table.is_temporal and (
field.is_composite_key
or field.related_table is not None
and field.related_table.is_temporal
):
return func.split_part(column, ".", 1).label(field.db_name)
return column

Expand Down

0 comments on commit 6aa0e81

Please sign in to comment.