Oracle: Arithmetics using func.current_date() are broken, lacks special handling like func.sysdate()

Issue #1683 resolved
Former user created an issue

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)

  1. Mike Bayer 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.

  2. Mike Bayer 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).

  3. Log in to comment