aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/CHANGELOG.md
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/CHANGELOG.md')
-rw-r--r--activerecord/CHANGELOG.md189
1 files changed, 167 insertions, 22 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md
index 0b7fbe5a48..0497f6326e 100644
--- a/activerecord/CHANGELOG.md
+++ b/activerecord/CHANGELOG.md
@@ -1,3 +1,160 @@
+* `.unscope` now removes conditions specified in `default_scope`.
+
+ *Jon Leighton*
+
+* Added ActiveRecord::QueryMethods#rewhere which will overwrite an existing, named where condition.
+
+ Examples:
+
+ Post.where(trashed: true).where(trashed: false) #=> WHERE `trashed` = 1 AND `trashed` = 0
+ Post.where(trashed: true).rewhere(trashed: false) #=> WHERE `trashed` = 0
+ Post.where(active: true).where(trashed: true).rewhere(trashed: false) #=> WHERE `active` = 1 AND `trashed` = 0
+
+ *DHH*
+
+* Extend ActiveRecord::Base#cache_key to take an optional list of timestamp attributes of which the highest will be used.
+
+ Example:
+
+ # last_reviewed_at will be used, if that's more recent than updated_at, or vice versa
+ Person.find(5).cache_key(:updated_at, :last_reviewed_at)
+
+ *DHH*
+
+* Added ActiveRecord::Base#enum for declaring enum attributes where the values map to integers in the database, but can be queried by name.
+
+ Example:
+
+ class Conversation < ActiveRecord::Base
+ enum status: [:active, :archived]
+ end
+
+ Conversation::STATUS # => { active: 0, archived: 1 }
+
+ # conversation.update! status: 0
+ conversation.active!
+ conversation.active? # => true
+ conversation.status # => :active
+
+ # conversation.update! status: 1
+ conversation.archived!
+ conversation.archived? # => true
+ conversation.status # => :archived
+
+ # conversation.update! status: 1
+ conversation.status = :archived
+
+ *DHH*
+
+* ActiveRecord::Base#attribute_for_inspect now truncates long arrays (more than 10 elements)
+
+ *Jan Bernacki*
+
+* Allow for the name of the schema_migrations table to be configured.
+
+ *Jerad Phelps*
+
+* Do not add to scope includes values from through associations.
+ Fixed bug when providing `includes` in through association scope, and fetching targets.
+
+ Example:
+
+ class Vendor < ActiveRecord::Base
+ has_many :relationships, -> { includes(:user) }
+ has_many :users, through: :relationships
+ end
+
+ vendor = Vendor.first
+
+ # Before
+
+ vendor.users.to_a # => Raises exception: not found `:user` for `User`
+
+ # After
+
+ vendor.users.to_a # => No exception is raised
+
+ Fixes #12242, #9517, #10240.
+
+ *Paul Nikitochkin*
+
+* Type cast json values on write, so that the value is consistent
+ with reading from the database.
+
+ Example:
+
+ x = JsonDataType.new tags: {"string" => "foo", :symbol => :bar}
+
+ # Before:
+ x.tags # => {"string" => "foo", :symbol => :bar}
+
+ # After:
+ x.tags # => {"string" => "foo", "symbol" => "bar"}
+
+ *Severin Schoepke*
+
+* `ActiveRecord::Store` works together with PG `hstore` columns.
+ Fixes #12452.
+
+ *Yves Senn*
+
+* Fix bug where `ActiveRecord::Store` used a global `Hash` to keep track of
+ all registered `stored_attributes`. Now every subclass of
+ `ActiveRecord::Base` has it's own `Hash`.
+
+ *Yves Senn*
+
+* Save `has_one` association when primary key is manually set.
+
+ Fixes #12302.
+
+ *Lauro Caetano*
+
+* Allow any version of BCrypt when using `has_secure_password`.
+
+ *Mike Perham*
+
+* Sub-query generated for `Relation` passed as array condition did not take in account
+ bind values and have invalid syntax.
+
+ Generate sub-query with inline bind values.
+
+ Fixes #12586.
+
+ *Paul Nikitochkin*
+
+* Fix a bug where rake db:structure:load crashed when the path contained
+ spaces.
+
+ *Kevin Mook*
+
+* `ActiveRecord::QueryMethods#unscope` unscopes negative equality
+
+ Allows you to call `#unscope` on a relation with negative equality
+ operators, i.e. `Arel::Nodes::NotIn` and `Arel::Nodes::NotEqual` that have
+ been generated through the use of `where.not`.
+
+ *Eric Hankins*
+
+* Raise an exception when model without primary key calls `.find_with_ids`.
+
+ *Shimpei Makimoto*
+
+* Make `Relation#empty?` use `exists?` instead of `count`.
+
+ *Szymon Nowak*
+
+* `rake db:structure:dump` no longer crashes when the port was specified as `Fixnum`.
+
+ *Kenta Okamoto*
+
+* `NullRelation#pluck` takes a list of columns
+
+ The method signature in `NullRelation` was updated to mimic that in
+ `Calculations`.
+
+ *Derek Prior*
+
* `scope_chain` should not be mutated for other reflections.
Currently `scope_chain` uses same array for building different
@@ -105,18 +262,6 @@
*kennyj*
-* ActiveRecord::Base#<=> has been removed. Primary keys may not be in order,
- or even be numbers, so sorting by id doesn't make sense. Please use `sort_by`
- and specify the attribute you wish to sort with. For example, change:
-
- Post.all.to_a.sort
-
- to:
-
- Post.all.to_a.sort_by(&:id)
-
- *Aaron Patterson*
-
* Fix: joins association, with defined in the scope block constraints by using several
where constraints and at least of them is not `Arel::Nodes::Equality`,
generates invalid SQL expression.
@@ -245,7 +390,7 @@
* Fixes bug when using includes combined with select, the select statement was overwritten.
- Fixes #11773
+ Fixes #11773.
*Edo Balvers*
@@ -335,13 +480,13 @@
* Reset @column_defaults when assigning `locking_column`.
We had a potential problem. For example:
- class Post < ActiveRecord::Base
- self.column_defaults # if we call this unintentionally before setting locking_column ...
- self.locking_column = 'my_locking_column'
- end
+ class Post < ActiveRecord::Base
+ self.column_defaults # if we call this unintentionally before setting locking_column ...
+ self.locking_column = 'my_locking_column'
+ end
- Post.column_defaults["my_locking_column"]
- => nil # expected value is 0 !
+ Post.column_defaults["my_locking_column"]
+ => nil # expected value is 0 !
*kennyj*
@@ -436,11 +581,11 @@
Method `delete_all` should not be invoking callbacks and this
feature was deprecated in Rails 4.0. This is being removed.
`delete_all` will continue to honor the `:dependent` option. However
- if `:dependent` value is `:destroy` then the default deletion
+ if `:dependent` value is `:destroy` then the `:delete_all` deletion
strategy for that collection will be applied.
User can also force a deletion strategy by passing parameter to
- `delete_all`. For example you can do `@post.comments.delete_all(:nullify)` .
+ `delete_all`. For example you can do `@post.comments.delete_all(:nullify)`.
*Neeraj Singh*
@@ -588,7 +733,7 @@
*Neeraj Singh*
-* Fixture setup does no longer depend on `ActiveRecord::Base.configurations`.
+* Fixture setup no longer depends on `ActiveRecord::Base.configurations`.
This is relevant when `ENV["DATABASE_URL"]` is used in place of a `database.yml`.
*Yves Senn*