Skip to content

Commit

Permalink
Commented some non-intutive code.
Browse files Browse the repository at this point in the history
  • Loading branch information
SpacemanPaul committed Sep 20, 2024
1 parent da9ecd3 commit 45d5998
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion datacube/drivers/postgis/_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ def value_to_alchemy(self, value: DateFieldLike) -> DateFieldLike:
return tz_as_utc(datetime.fromisoformat(value))
elif isinstance(value, (ColumnElement, str)):
# SQLAlchemy expression or string are parsed in pg as dates.
# return cast(value, TIMESTAMP(timezone=True))
# NB: Do not cast here - casting here breaks expected behaviour in other timezones
return value
else:
raise ValueError("Value not readable as date: %r" % value)
Expand Down Expand Up @@ -465,6 +465,7 @@ class DateRangeDocField(RangeDocField):

def value_to_alchemy(self, value):
low, high = value
# Is OK to cast, because we are wrapping it in timezone-aware datatype.
if isinstance(low, (ColumnElement, str)):
low = cast(low, TIMESTAMP(timezone=True))
if isinstance(high, (ColumnElement, str)):
Expand Down

0 comments on commit 45d5998

Please sign in to comment.