Skip to content

Commit 2eca67a

Browse files
committed
Types: Unlock supporting timezone-aware DateTime fields
1 parent 07bba7b commit 2eca67a

File tree

2 files changed

+1
-6
lines changed

2 files changed

+1
-6
lines changed

src/sqlalchemy_cratedb/dialect.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,10 @@ def process(value):
112112

113113
class DateTime(sqltypes.DateTime):
114114

115-
TZ_ERROR_MSG = "Timezone aware datetime objects are not supported"
116-
117115
def bind_processor(self, dialect):
118116
def process(value):
119117
if value is not None:
120118
assert isinstance(value, datetime)
121-
if value.tzinfo is not None:
122-
raise TimezoneUnawareException(DateTime.TZ_ERROR_MSG)
123119
return value.strftime('%Y-%m-%dT%H:%M:%S.%fZ')
124120
return value
125121
return process

tests/datetime_test.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,8 @@ def test_date_can_handle_datetime(self):
8282
]
8383
self.session.query(self.Character).first()
8484

85-
def test_date_cannot_handle_tz_aware_datetime(self):
85+
def test_date_can_handle_tz_aware_datetime(self):
8686
character = self.Character()
8787
character.name = "Athur"
8888
character.timestamp = datetime(2009, 5, 13, 19, 19, 30, tzinfo=CST())
8989
self.session.add(character)
90-
self.assertRaises(DBAPIError, self.session.commit)

0 commit comments

Comments
 (0)