rahajiyev-ybDSSfEhYYe0mqiBIQXl+w@public.gmane.org
2012-May-07 07:31 UTC
ActiveRecord Postgres small inconsistency
Hi, I''m using Rails 3.2.1 and following through Mike Hartl''s tutorial. irb(main):024:0> User.first User Load (0.6ms) SELECT "users".* FROM "users" LIMIT 1 => ... irb(main):025:0> User.last User Load (1.0ms) SELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1 => ... Here''s what PostgreSQL docs say concerning ORDER-less SELECTs: "If the ORDER BY clause is specified, the returned rows are sorted in the specified order. If ORDER BY is not given, the rows are returned in whatever order the system finds fastest to produce. (See ORDER BY Clause below.)" So, shouldn''t ORDER BY .. ASC be specified explicitly, instead of relying on an implementation detail that might later change? Thanks. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 7 May 2012 08:31, rahajiyev-ybDSSfEhYYe0mqiBIQXl+w@public.gmane.org <rahajiyev-ybDSSfEhYYe0mqiBIQXl+w@public.gmane.org>wrote:> Hi, I''m using Rails 3.2.1 and following through Mike Hartl''s > tutorial. > > irb(main):024:0> User.first > User Load (0.6ms) SELECT "users".* FROM "users" LIMIT 1 > => ... > irb(main):025:0> User.last > User Load (1.0ms) SELECT "users".* FROM "users" ORDER BY > "users"."id" DESC LIMIT 1 > => ... > > Here''s what PostgreSQL docs say concerning ORDER-less SELECTs: > "If the ORDER BY clause is specified, the returned rows are sorted in > the specified order. If ORDER BY is not given, the rows are returned > in whatever order the system finds fastest to produce. (See ORDER BY > Clause below.)" > > > So, shouldn''t ORDER BY .. ASC be specified explicitly, instead of > relying on an implementation detail that might later change? >This strikes me as a good suggestion. I''ll put a pull request together for it unless anyone has any objections. Jeremy Walker http://www.ihid.co.uk> > Thanks. > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 7 May 2012 17:34, Jeremy Walker <jez.walker-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On 7 May 2012 08:31, rahajiyev-ybDSSfEhYYe0mqiBIQXl+w@public.gmane.org <rahajiyev-ybDSSfEhYYe0mqiBIQXl+w@public.gmane.org>wrote: > >> Hi, I''m using Rails 3.2.1 and following through Mike Hartl''s >> tutorial. >> >> irb(main):024:0> User.first >> User Load (0.6ms) SELECT "users".* FROM "users" LIMIT 1 >> => ... >> irb(main):025:0> User.last >> User Load (1.0ms) SELECT "users".* FROM "users" ORDER BY >> "users"."id" DESC LIMIT 1 >> => ... >> >> Here''s what PostgreSQL docs say concerning ORDER-less SELECTs: >> "If the ORDER BY clause is specified, the returned rows are sorted in >> the specified order. If ORDER BY is not given, the rows are returned >> in whatever order the system finds fastest to produce. (See ORDER BY >> Clause below.)" >> >> >> So, shouldn''t ORDER BY .. ASC be specified explicitly, instead of >> relying on an implementation detail that might later change? >> > > This strikes me as a good suggestion. I''ll put a pull request together for > it unless anyone has any objections. >After a quick browse through the code, this has already been added to Rails master and will appear in a future release.> > Jeremy Walker > http://www.ihid.co.uk > > >> >> Thanks. >> >> -- >> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit this group at >> http://groups.google.com/group/rubyonrails-talk?hl=en. >> >> >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Could you please send the link of this commit? On Monday, May 7, 2012 1:52:57 PM UTC-3, iHiD wrote:> > > > On 7 May 2012 17:34, Jeremy Walker <jez.w...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <javascript:>>wrote: > >> >> >> On 7 May 2012 08:31, raha...-ybDSSfEhYYe0mqiBIQXl+w@public.gmane.org <javascript:> < >> raha...-ybDSSfEhYYe0mqiBIQXl+w@public.gmane.org <javascript:>> wrote: >> >>> Hi, I''m using Rails 3.2.1 and following through Mike Hartl''s >>> tutorial. >>> >>> irb(main):024:0> User.first >>> User Load (0.6ms) SELECT "users".* FROM "users" LIMIT 1 >>> => ... >>> irb(main):025:0> User.last >>> User Load (1.0ms) SELECT "users".* FROM "users" ORDER BY >>> "users"."id" DESC LIMIT 1 >>> => ... >>> >>> Here''s what PostgreSQL docs say concerning ORDER-less SELECTs: >>> "If the ORDER BY clause is specified, the returned rows are sorted in >>> the specified order. If ORDER BY is not given, the rows are returned >>> in whatever order the system finds fastest to produce. (See ORDER BY >>> Clause below.)" >>> >>> >>> So, shouldn''t ORDER BY .. ASC be specified explicitly, instead of >>> relying on an implementation detail that might later change? >>> >> >> This strikes me as a good suggestion. I''ll put a pull request together >> for it unless anyone has any objections. >> > > After a quick browse through the code, this has already been added to > Rails master and will appear in a future release. > > >> >> Jeremy Walker >> http://www.ihid.co.uk >> >> >>> >>> Thanks. >>> >>> -- >>> 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 rubyonra...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<javascript:> >>> . >>> To unsubscribe from this group, send email to >>> rubyonrails-ta...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <javascript:>. >>> For more options, visit this group at >>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>> >>> >> >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/Ce_RjF-EQrAJ. For more options, visit https://groups.google.com/groups/opt_out.