bump
On Mar 19, 8:45 am, gsterndale
<gsternd...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> I''d like to have database agnostic code, however I have been
> unsuccessful writing conditions that work for both postgres and mysql
> for the following:
>
> # postgres only
> conditions = ["curtain_at + CAST (CAST (duration AS VARCHAR) ||
''
> SECOND'' AS INTERVAL) >= ? AND curtain_at < ?",
Time.now, Time.now +
> 2.hours]
>
> # MySQL only
> conditions = ["curtain_at + INTERVAL duration SECOND >= ? and
> curtain_at < ?", Time.now, Time.now + 2.hours]
>
> Concert.find(:all, :conditions => conditions)
>
> Can anyone lend some SQL expertise?
>
> As a last resort, how can I determine what the current database is so
> I can selectively set conditions?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---