aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/CHANGELOG.md
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/CHANGELOG.md')
-rw-r--r--activerecord/CHANGELOG.md181
1 files changed, 181 insertions, 0 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md
index 89a12d4223..e2dc8045e2 100644
--- a/activerecord/CHANGELOG.md
+++ b/activerecord/CHANGELOG.md
@@ -1,3 +1,184 @@
+* Support for PostgreSQL foreign tables.
+
+ *fatkodima*
+
+* Fix relation merger issue with `left_outer_joins`.
+
+ *Mehmet Emin İNAÇ*
+
+* Don't allow destroyed object mutation after `save` or `save!` is called.
+
+ *Ryuta Kamizono*
+
+* Take into account association conditions when deleting through records.
+
+ Fixes #18424.
+
+ *Piotr Jakubowski*
+
+* Fix nested `has_many :through` associations on unpersisted parent instances.
+
+ For example, if you have
+
+ class Post < ActiveRecord::Base
+ belongs_to :author
+ has_many :books, through: :author
+ has_many :subscriptions, through: :books
+ end
+
+ class Author < ActiveRecord::Base
+ has_one :post
+ has_many :books
+ has_many :subscriptions, through: :books
+ end
+
+ class Book < ActiveRecord::Base
+ belongs_to :author
+ has_many :subscriptions
+ end
+
+ class Subscription < ActiveRecord::Base
+ belongs_to :book
+ end
+
+ Before:
+
+ If `post` is not persisted, then `post.subscriptions` will be empty.
+
+ After:
+
+ If `post` is not persisted, then `post.subscriptions` can be set and used
+ just like it would if `post` were persisted.
+
+ Fixes #16313.
+
+ *Zoltan Kiss*
+
+* Fixed inconsistency with `first(n)` when used with `limit()`.
+ The `first(n)` finder now respects the `limit()`, making it consistent
+ with `relation.to_a.first(n)`, and also with the behavior of `last(n)`.
+
+ Fixes #23979.
+
+ *Brian Christian*
+
+* Use `count(:all)` in `HasManyAssociation#count_records` to prevent invalid
+ SQL queries for association counting.
+
+ *Klas Eskilson*
+
+* Fix to invoke callbacks when using `update_attribute`.
+
+ *Mike Busch*
+
+* Fix `count(:all)` to correctly work `distinct` with custom SELECT list.
+
+ *Ryuta Kamizono*
+
+* Using subselect for `delete_all` with `limit` or `offset`.
+
+ *Ryuta Kamizono*
+
+* Undefine attribute methods on descendants when resetting column
+ information.
+
+ *Chris Salzberg*
+
+* Log database query callers
+
+ Add `verbose_query_logs` configuration option to display the caller
+ of database queries in the log to facilitate N+1 query resolution
+ and other debugging.
+
+ Enabled in development only for new and upgraded applications. Not
+ recommended for use in the production environment since it relies
+ on Ruby's `Kernel#caller_locations` which is fairly slow.
+
+ *Olivier Lacan*
+
+* Fix conflicts `counter_cache` with `touch: true` by optimistic locking.
+
+ ```
+ # create_table :posts do |t|
+ # t.integer :comments_count, default: 0
+ # t.integer :lock_version
+ # t.timestamps
+ # end
+ class Post < ApplicationRecord
+ end
+
+ # create_table :comments do |t|
+ # t.belongs_to :post
+ # end
+ class Comment < ApplicationRecord
+ belongs_to :post, touch: true, counter_cache: true
+ end
+ ```
+
+ Before:
+ ```
+ post = Post.create!
+ # => begin transaction
+ INSERT INTO "posts" ("created_at", "updated_at", "lock_version")
+ VALUES ("2017-12-11 21:27:11.387397", "2017-12-11 21:27:11.387397", 0)
+ commit transaction
+
+ comment = Comment.create!(post: post)
+ # => begin transaction
+ INSERT INTO "comments" ("post_id") VALUES (1)
+
+ UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) + 1,
+ "lock_version" = COALESCE("lock_version", 0) + 1 WHERE "posts"."id" = 1
+
+ UPDATE "posts" SET "updated_at" = '2017-12-11 21:27:11.398330',
+ "lock_version" = 1 WHERE "posts"."id" = 1 AND "posts"."lock_version" = 0
+ rollback transaction
+ # => ActiveRecord::StaleObjectError: Attempted to touch a stale object: Post.
+
+ Comment.take.destroy!
+ # => begin transaction
+ DELETE FROM "comments" WHERE "comments"."id" = 1
+
+ UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) - 1,
+ "lock_version" = COALESCE("lock_version", 0) + 1 WHERE "posts"."id" = 1
+
+ UPDATE "posts" SET "updated_at" = '2017-12-11 21:42:47.785901',
+ "lock_version" = 1 WHERE "posts"."id" = 1 AND "posts"."lock_version" = 0
+ rollback transaction
+ # => ActiveRecord::StaleObjectError: Attempted to touch a stale object: Post.
+ ```
+
+ After:
+ ```
+ post = Post.create!
+ # => begin transaction
+ INSERT INTO "posts" ("created_at", "updated_at", "lock_version")
+ VALUES ("2017-12-11 21:27:11.387397", "2017-12-11 21:27:11.387397", 0)
+ commit transaction
+
+ comment = Comment.create!(post: post)
+ # => begin transaction
+ INSERT INTO "comments" ("post_id") VALUES (1)
+
+ UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) + 1,
+ "lock_version" = COALESCE("lock_version", 0) + 1,
+ "updated_at" = '2017-12-11 21:37:09.802642' WHERE "posts"."id" = 1
+ commit transaction
+
+ comment.destroy!
+ # => begin transaction
+ DELETE FROM "comments" WHERE "comments"."id" = 1
+
+ UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) - 1,
+ "lock_version" = COALESCE("lock_version", 0) + 1,
+ "updated_at" = '2017-12-11 21:39:02.685520' WHERE "posts"."id" = 1
+ commit transaction
+ ```
+
+ Fixes #31199.
+
+ *bogdanvlviv*
+
* Add support for PostgreSQL operator classes to `add_index`.
Example: