On Monday, February 6, 2017 at 9:32:55 PM UTC-8, Satyanarayana Gandham
wrote:
>
> Hi,
>
> I have a Sequel Model (Event) which has a DateTime column(start_time),
> Now, I want to get all the events which starts on Sunday. Since, my
> development database is MySQL, I would do as
> "Event.where{DAYOFWEEK(starts_at) =~ 1}". Here, `DAYOFWEEK` is a MySQL
> specific function. But we want to use other databases like PostgreSQL or
> SQLite. The mysql functions doesn't work in other databases.
>
> What will I have to do to make it work on multiple databases(relational)?
>
In general, you can use a case statement for this:
case DB.database_type
when :mysql
# ...
when :postgres
# ...
when :sqlite
# ...
end
Thanks,
Jeremy
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.