diff options
author | Tekin Suleyman <tekin@tekin.co.uk> | 2018-11-17 13:50:01 -0800 |
---|---|---|
committer | Tekin Suleyman <tekin@tekin.co.uk> | 2018-11-26 16:19:52 -0800 |
commit | 3b9982a3b778b63488975eb03592d33aa9fb04dd (patch) | |
tree | 1c738d8c2e7b47ed20fe0937b8a723b6eb1ae310 /activerecord/CHANGELOG.md | |
parent | 85b080365313437f646070ca214fef433c06db6a (diff) | |
download | rails-3b9982a3b778b63488975eb03592d33aa9fb04dd.tar.gz rails-3b9982a3b778b63488975eb03592d33aa9fb04dd.tar.bz2 rails-3b9982a3b778b63488975eb03592d33aa9fb04dd.zip |
Make implicit order column configurable
When calling ordered finder methods such as +first+ or +last+ without an
explicit order clause, ActiveRecord sorts records by primary key. This
can result in unpredictable and surprising behaviour when the primary
key is not an auto-incrementing integer, for example when it's a UUID.
This change makes it possible to override the column used for implicit
ordering such that +first+ and +last+ will return more predictable
results. For Example:
class Project < ActiveRecord::Base
self.implicit_order_column = "created_at"
end
Diffstat (limited to 'activerecord/CHANGELOG.md')
-rw-r--r-- | activerecord/CHANGELOG.md | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index 6186595a56..13cc486e7f 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -1,3 +1,20 @@ +* Make the implicit order column configurable. + + When calling ordered finder methods such as +first+ or +last+ without an + explicit order clause, ActiveRecord sorts records by primary key. This can + result in unpredictable and surprising behaviour when the primary key is + not an auto-incrementing integer, for example when it's a UUID. This change + makes it possible to override the column used for implicit ordering such + that +first+ and +last+ will return more predictable results. + + Example: + + class Project < ActiveRecord::Base + self.implicit_order_column = "created_at" + end + + *Tekin Suleyman* + * Bump minimum PostgreSQL version to 9.3. *Yasuo Honda* |