Closed
Description
Migrated issue, originally created by Anonymous
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.
Attachments: ora_test.py | smart_type_affinity.patch
Metadata
Metadata
Assignees
Labels
Type
Projects
Relationships
Development
No branches or pull requests
Activity
sqlalchemy-bot commentedon Feb 10, 2010
Anonymous wrote:
Testcase for func.current_date() vs. func.sysdate().
sqlalchemy-bot commentedon Feb 10, 2010
Changes by Anonymous:
sqlalchemy-bot commentedon Feb 10, 2010
Michael Bayer (@zzzeek) wrote:
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.sqlalchemy-bot commentedon Feb 10, 2010
Changes by Michael Bayer (@zzzeek):
sqlalchemy-bot commentedon Feb 10, 2010
Michael Bayer (@zzzeek) wrote:
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).sqlalchemy-bot commentedon Feb 11, 2010
Michael Bayer (@zzzeek) wrote:
the change in 85d335b should fix this issue, but have not had time to test on oracle.
sqlalchemy-bot commentedon Feb 12, 2010
Anonymous wrote:
It does, thank you very much for fixing it that fast!
Cheers,
Hynek
sqlalchemy-bot commentedon Feb 12, 2010
Michael Bayer (@zzzeek) wrote:
good enough for me.
sqlalchemy-bot commentedon Feb 12, 2010
Changes by Michael Bayer (@zzzeek):