Skip to content

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

Closed
@sqlalchemy-bot

Description

@sqlalchemy-bot
Collaborator

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

Activity

sqlalchemy-bot

sqlalchemy-bot commented on Feb 10, 2010

@sqlalchemy-bot
CollaboratorAuthor

Anonymous wrote:

Testcase for func.current_date() vs. func.sysdate().

sqlalchemy-bot

sqlalchemy-bot commented on Feb 10, 2010

@sqlalchemy-bot
CollaboratorAuthor

Changes by Anonymous:

  • attached file ora_test.py
sqlalchemy-bot

sqlalchemy-bot commented on Feb 10, 2010

@sqlalchemy-bot
CollaboratorAuthor

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

sqlalchemy-bot commented on Feb 10, 2010

@sqlalchemy-bot
CollaboratorAuthor

Changes by Michael Bayer (@zzzeek):

  • set milestone to "0.6.0"
sqlalchemy-bot

sqlalchemy-bot commented on Feb 10, 2010

@sqlalchemy-bot
CollaboratorAuthor

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

sqlalchemy-bot commented on Feb 11, 2010

@sqlalchemy-bot
CollaboratorAuthor

Michael Bayer (@zzzeek) wrote:

the change in 85d335b should fix this issue, but have not had time to test on oracle.

sqlalchemy-bot

sqlalchemy-bot commented on Feb 12, 2010

@sqlalchemy-bot
CollaboratorAuthor

Anonymous wrote:

It does, thank you very much for fixing it that fast!

Cheers,
Hynek

sqlalchemy-bot

sqlalchemy-bot commented on Feb 12, 2010

@sqlalchemy-bot
CollaboratorAuthor

Michael Bayer (@zzzeek) wrote:

good enough for me.

sqlalchemy-bot

sqlalchemy-bot commented on Feb 12, 2010

@sqlalchemy-bot
CollaboratorAuthor

Changes by Michael Bayer (@zzzeek):

  • changed status to closed
added this to the 0.6.0 milestone on Nov 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingoracle

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @sqlalchemy-bot

        Issue actions

          Oracle: Arithmetics using func.current_date() are broken, lacks special handling like func.sysdate() · Issue #1683 · sqlalchemy/sqlalchemy