Fix TypeError when reading timestamps via the driver's time_zone option#287
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
time_zone optionTypeError when reading timestamps via the driver's time_zone option
Excellent, thank you! |
The CrateDB driver (
crate-python) can return timezone-awaredatetimeobjects when itstime_zoneargument is configured. But using that option through the SQLAlchemy dialect crashed:Root cause
Reading a
TIMESTAMPinvolves two layers. Normally the driver passes the raw epoch-millis value through and the dialect'sDateTime.result_processorconverts it to adatetime. Whentime_zoneis set, the driver converts the value to adatetimefirst — so the dialect's processor received an already-converteddatetime, tried to convert it (TypeError, caught), then fell through tostrptime(value, ...)(TypeError, uncaught) → crash.The processor assumed it was always first in line to do the conversion.
Fix
Make
DateTime.result_processoridempotent: if the value is already adatetime(the driver converted it), pass it through unchanged.Closes #92 (was actually already done)