Skip to content

Commit

Permalink
Types: Accept marshalling datetime.date values on DateTime fields
Browse files Browse the repository at this point in the history
The test suite of `meltano-tap-cratedb`, derived from the corresponding
PostgreSQL adapter, will supply `dt.date` objects. Without this patch,
those will otherwise fail on this routine.
  • Loading branch information
amotl committed Jan 16, 2024
1 parent 2eca67a commit aab448f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/sqlalchemy_cratedb/dialect.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ class DateTime(sqltypes.DateTime):

def bind_processor(self, dialect):
def process(value):
if value is not None:
assert isinstance(value, datetime)
if isinstance(value, (datetime, date)):
return value.strftime('%Y-%m-%dT%H:%M:%S.%fZ')
return value
else:
return value
return process

def result_processor(self, dialect, coltype):
Expand Down

0 comments on commit aab448f

Please sign in to comment.