- assigned issue to
- changed milestone to 0.7.xx
- marked as enhancement
- changed component to sql
- changed title to INTERVAL - should this be in base types?
INTERVAL - should this be in base types?
Issue #2164
duplicate
using cast and INTERVAL seems to cause a problem: (note this code is corrupted by an issue tracker migration some years ago)
import sqlalchemy as sa
import sqlalchemy.dialects.postgresql as sa_pg
s1 = sa.select([week ago', sa_pg.DATE)](sa.cast('1))
print s1
s2 = sa.select([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 (5)
-
repo owner -
repo owner - changed milestone to 1.x.xx
-
repo owner - edited description
-
repo owner the test case is:
import sqlalchemy as sa import sqlalchemy.dialects.postgresql as sa_pg s1 = sa.select([sa.cast('1 week ago', sa_pg.DATE)]) print s1 s2 = sa.select([sa.cast('100 seconds', sa_pg.INTERVAL)]) print s2
this now runs "fine" as the "print" case is handled by
#3631. There's no pressure for a SQL-standard INTERVAL in the base right now as we have sqlalchemy.types.Interval for most generic use cases. -
repo owner - changed status to duplicate
Duplicate of
#3631. - Log in to comment
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:
but the bigger issue of INTERVAL, something to think about.