On Dec 3, 2007 1:33 PM, Michael Bayer <[EMAIL PROTECTED]> wrote:
>
>
> On Dec 3, 2007, at 4:05 PM, Mike Orr wrote:
>
> >
> > 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.
>
> oh...well actually in this case its because MSDateTime doesn't do any
> date/time conversion, since mysqldb returns datetime objects for us
> and we dont need to convert from strings...we only do it for sqlite
> right now.  if MySQL itself is returning a datetime, then MySQLdb
> should as well, is it possible this is a bug on the MySQLdb side ?

It looks like that's the case.

>>> import MySQLdb
>>> conn = MySQLdb.connect(...)
>>> c = conn.cursor()
>>> c.execute("SELECT orr_id, COALESCE(last_entry_date, create_date)
AS activity, last_entry_date, create_date FROM Incident LIMIT 1")
1L
>>> c.fetchone()
(6001L, '2007-05-30 23:24:46', datetime.datetime(2007, 5, 30, 23, 24,
46), datetime.datetime(2005, 9, 6, 17, 14, 34))

I looked in my last non-SA application, and it's using the coalesce
only for the select, and formatting the display date from the
underlying fields.  So I guess that's the best we can get unless I
want to parse the string back into a date.  I guess this would be a
good case for an ORM property since it's read-only.

-- 
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 sqlalchemy@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to