yes...add type_=DateTime to your coalesce() call -
func.coalesce(date1, date2, type_=DateTime)
when we implement ticket #615, standard functions like "coalesce" will
be available in a generic form and will also know what their
appropriate return type is (in this case it would probably go off the
type of the first argument), so the explicit type_ wont be needed.
On Nov 30, 7:09 pm, "Mike Orr" <[EMAIL PROTECTED]> wrote:
> I have a calculated column that takes the first non-NULL value among
> three dates. It should remain a datetime object but instead it's
> being converted to a string. Is it possible to tell SQLAlchemy to
> treat this value like a DateTime column?
>
> # Table t_incident defined with
> 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,
> ).label("activity")
>
> # Mapping
> orm.mapper(Incident, t_incident, properties={
> "activity": orm.column_property(c_activity)
> })
>
> --
> 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
-~----------~----~----~----~------~----~------~--~---