fix: use timedelta instead of time to cast TIME column in B compatibility mode(#IAIE7I)
In mysql compatibility mode, we should convert the TIME column to a python datetime.timedelta type, just like the behavior of PyMySQL and mysql-connector-python. See also: - PyMySQL:95635f587b/pymysql/converters.py (L344)
- mysql-connector-python:59817f3de4/mysql-connector-python/lib/mysql/connector/conversion.py (L593)
This commit is contained in:
@ -57,6 +57,16 @@ curs_get_cast(cursorObject *self, PyObject *oid)
|
||||
if (cast) { return cast; }
|
||||
|
||||
/* global lookup */
|
||||
if (self->conn->sql_compatibility == SQL_COMPATIBILITY_B) {
|
||||
/*
|
||||
In mysql compatibility mode, we should convert the TIME column to a python datetime.timedelta type,
|
||||
just like the behavior of PyMySQL and mysql-connector-python.
|
||||
*/
|
||||
if (PyLong_Check(oid)) {
|
||||
long value = convert_time_oid_to_interval_oid(PyLong_AsLong(oid));
|
||||
oid = PyLong_FromLong(value);
|
||||
}
|
||||
}
|
||||
cast = PyDict_GetItem(psyco_types, oid);
|
||||
Dprintf("curs_get_cast: global dict: %p", cast);
|
||||
if (cast) { return cast; }
|
||||
|
Reference in New Issue
Block a user