[CONPY-107] Negative time value not handled Created: 2020-08-15  Updated: 2020-08-16  Resolved: 2020-08-16

Status: Closed
Project: MariaDB Connector/Python
Component/s: Generic
Affects Version/s: 1.0.0
Fix Version/s: 1.0.1

Type: Bug Priority: Major
Reporter: Georg Richter Assignee: Georg Richter
Resolution: Fixed Votes: 0
Labels: sqlalchemy

Issue Links:
Blocks
blocks CONPY-77 Add mariadb dialect to sqlalchemy Closed

 Description   

While MariaDB allows negative time values, they can't be stored in Python's datetime.time object and will be returned as a positive time value.

>>> import mariadb
>>> conn=mariadb.connect(db="testp")
>>> cur=conn.cursor()
>>> cur.execute("create temporary table t1 (a time)")
>>> cur.execute("insert into t1 values ('-23:00')")
>>> cur.execute("select a from t1")
>>> cur.fetchone()
(datetime.time(23, 0),)
>>> cur.execute("select cast(a as char) from t1")
>>> cur.fetchone()
('-23:00:00',)

Instead of storing time values in datetime.time, they should be stored in datetime.timedelta.



 Comments   
Comment by Georg Richter [ 2020-08-16 ]

Fixed rev. 92eaf17fd5a77d138d931620ca220aab7fc09502

Generated at Thu Feb 08 03:30:18 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.