timedeltas going in have their microseconds divided by 1000

Issue #7 resolved
Shai Berger
created an issue

Note this session. cc is a cx_Oracle cursor:

>>> cc.execute('select :v1 from dual', [timedelta(days=6, seconds=0.16)])
<cx_Oracle.Cursor on <cx_Oracle.Connection to ...>>
>>> cc.fetchall()[0][0]
datetime.timedelta(6, 0, 160)

And so, 0.16 seconds have turned into 160 microseconds, or 0.00016 seconds.

Looking at sources, IntervalVar_SetValue() puts the microseconds into the OCIInterval as they are, but OracleIntervalToPythonDelta divides by 1000. Looking at tests, it seems interval values defined in SQL are fetched correctly -- so the latter is correct (the "fractional seconds" are nanoseconds); we just need to multiply by 1000 when setting the value from a timedelta.

Comments (2)

  1. Log in to comment