You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently posts & private posts when order_oldest_first / order_newest_first are actually (under the hood) ordered by id.
This seems appealing in some ways, but it is a bit of a nightmare. In particular if the creation order is screwed up (e.g. by importing) then you have problems. It also just feels wrong to me -- and it was deeply surprising when I found out.
I have started changing this behaviour to be ordered by created_at
Of course changing this is quite a bit of work, as much test data currently relies on this, and some untested behaviours (e.g. Post / PrivatePost#page())
However, I've also discovered that there are one or two places where some desired behaviours rely on a natural id-ordering (rather than explicit call to order_oldest_first) which is not dependable (at least in postgres).
timdiggins
changed the title
[Private]Posts should be ordered by created_at not by id
Posts and PrivatePosts should be ordered by created_at not by id
Aug 7, 2016
FYI: Having looked through the usages of .posts, none are actually reordering the posts, and many are relying on the id-order. I think we should change the default order of the associations (not the model) to be order_oldest_first. this can be overridden with .reorder(). This may be a controversial choice!
Currently posts & private posts when
order_oldest_first
/order_newest_first
are actually (under the hood) ordered by id.This seems appealing in some ways, but it is a bit of a nightmare. In particular if the creation order is screwed up (e.g. by importing) then you have problems. It also just feels wrong to me -- and it was deeply surprising when I found out.
I have started changing this behaviour to be ordered by
created_at
Of course changing this is quite a bit of work, as much test data currently relies on this, and some untested behaviours (e.g.
Post
/PrivatePost
#page()
)However, I've also discovered that there are one or two places where some desired behaviours rely on a natural id-ordering (rather than explicit call to
order_oldest_first
) which is not dependable (at least in postgres).order_oldest_first
for the associations inTopic
andPrivateTopic
#page
for bothPost
andPrivatePost
#page
by extracting to either PostCommon or PageCalculableThe text was updated successfully, but these errors were encountered: