- attached ora_test.py
Oracle: Arithmetics using func.current_date() are broken, lacks special handling like func.sysdate()
I've stumbled over this while porting software to 0.6:
When doing arithmetics with func.current_date(), SQLAlchemy assumes that the result is an _OracleDate which leads to the following exception:
File "/usr/local/lib/python2.6/site-packages/SQLAlchemy-0.6beta1-py2.6.egg/sqlalchemy/dialects/oracle/cx_oracle.py", line 90, in process
return value.date()
AttributeError: 'datetime.timedelta' object has no attribute 'date'
The same code with func.sysdate() instead of func.current_date() works fine. It used to work with func.current_date() in 0.5.
I'm going to attach a test case.
Comments (7)
-
Account Deleted -
repo owner - changed milestone to 0.6.0
its because 0.5 did an isinstance() on the return value. would like to see if we can more deeply integrate
util.determine_date_affinity()
first before falling back to that. -
repo owner I.e. the attached patch makes
_BinaryExpressions
more intelligent about their resultant type. this would fix the oracle issue and also make the solution for PG's extract cleaner. just concerned about overhead here so I might want to consolidate some of the type/expression related function calls (i.e. adapt_operator() and resultant_affinities() could somehow be rolled together). -
repo owner the change in 85d335b01bf64a27e99cee915205afd99e7191b5 should fix this issue, but have not had time to test on oracle.
-
Account Deleted It does, thank you very much for fixing it that fast!
Cheers, Hynek
-
repo owner - changed status to resolved
good enough for me.
-
repo owner - removed milestone
Removing milestone: 0.6.0 (automated comment)
- Log in to comment
Testcase for func.current_date() vs. func.sysdate().