Issue #2164 new

INTERVAL - should this be in base types?

Anonymous created an issue

using cast and INTERVAL seems to cause a problem:

import sqlalchemy as sa
import sqlalchemy.dialects.postgresql as sa_pg
s1 =[week ago', sa_pg.DATE)](sa.cast('1))
print s1
s2 =[seconds', sa_pg.INTERVAL)](sa.cast('100))
print s2

AttributeError: 'GenericTypeCompiler' object has no attribute 'visit_INTERVAL'

The DATE cast works fine. The INTERVAL cast fails.

0.6.7 and 0.7b5 (current as of 7606:4d99799ee724070fe0fe7404f655854d223f6e93)

Comments (2)

  1. Mike Bayer repo owner

    INTERVAL is part of the SQL standard, but only Oracle and PG support it, and the SQL standard syntax is somewhat ridiculous. So INTERVAL is not in the base types module.

    In your case you are probably looking just for this:

    print s2.compile(dialect=sa_pg.dialect())

    but the bigger issue of INTERVAL, something to think about.

  2. Log in to comment