I'm on Rails 4 and have a begin_date:date
attribute on a Project
model. I'm using ActiveRecord, and the following request returns different results on Postgres vs SQLite when there are nil
values:
User.first.projects.order(begin_date: :desc, end_date: :desc)
In Postgres nil
values are treated as of higher value than existing value (hence come first), while in SQLite records with nil
value comes last.
Am I doing something wrong or is this the expected behaviour?
How could I reconstruct the above query such that it renders equal results (in regard of
nil
values) on both Postgres and SQLite?
PS. Please, if you have strong opinions that I should use the same db technology in all environments: I thank you for your consideration, but I know about this and this question is not about that subject.