From aab448f2cd2d84c12b2111ce125457490740577f Mon Sep 17 00:00:00 2001 From: Andreas Motl Date: Tue, 16 Jan 2024 02:22:11 +0100 Subject: [PATCH] Types: Accept marshalling `datetime.date` values on `DateTime` fields 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. --- src/sqlalchemy_cratedb/dialect.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sqlalchemy_cratedb/dialect.py b/src/sqlalchemy_cratedb/dialect.py index 79ea3a3..1e7aefd 100644 --- a/src/sqlalchemy_cratedb/dialect.py +++ b/src/sqlalchemy_cratedb/dialect.py @@ -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):