On Nov 30, 2007 9:28 PM, Michael Bayer <[EMAIL PROTECTED]> wrote:
>
> yes...add type_=DateTime to your coalesce() call -
> func.coalesce(date1, date2, type_=DateTime)
This doesn't work, I'm afraid.
# Table t_incident defined with
sa.Column("orr_id", sa.types.Integer, primary_key=True),
sa.Column("last_entry_date", sa.types.DateTime, nullable=True),
sa.Column("create_date", sa.types.DateTime, nullable=False),
# Standalone column definition
c_activity = sa.func.coalesce(
t_incident.c.last_entry_date,
t_incident.c.create_date,
type_=sa.types.DateTime,
).label("activity")
>>> sql = sa.select([tables.t_incident.c.orr_id, tables.c_activity,
tables.t_incident.c.create_date, tables.t_incident.c.last_entry_date],
limit=1)
>>> row = model.engine.execute(sql).fetchone()
>>> row
(6001L, '2007-05-30 23:24:46', datetime.datetime(2005, 9, 6, 17, 14,
34), datetime.datetime(2007, 5, 30, 23, 24, 46))
The second element should be a datetime rather than a string.
Using SQLAlchemy 0.4.1, Pylons dev, Python 2.5.1, Kubuntu Linux 2007.10
--
Mike Orr <[EMAIL PROTECTED]>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---