(My point of view) Order the result by ID is also a bad idea, if you switch to another ID schema (for example UUID, descending sequence, etc.) you must rewrite a lot of code. The ID is something the application must not "know", order for example by name, by a created_at field (and that have more sense if you want "the last created user").
Regards. Franco Catena. On Aug 18, 9:01 pm, Ben Johnson <[email protected]> wrote: > I just switched to Postgres and some of my tests are failing. It seems > that Postgres defaults by ordering data by ID DESC, whereas MySQL > defaults to ordering by ID ASC. > > What is the best practice for handling this? Is there a setting in > Postgres you can change? Should I be explicitly specifying the order of > my data in my queries? > > In various places throughout my application I am doing things like: > > User.first > > This obviously is not good with the order of the data is not consistent. > I also feel like the first User should return the first user, not the > last one created. > > What do you think? > -- > Posted viahttp://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

