aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/CHANGELOG.md
Commit message (Collapse)AuthorAgeFilesLines
...
* CHANGELOG entryBrian Christian2018-07-191-0/+6
|
* Add missing load config dependency to `rake db:seed`Tobias Bielohlawek2018-07-101-0/+5
|
* Merge pull request #33280 from nkondratyev/fix/mysql-time-default-valuesRyuta Kamizono2018-07-091-0/+4
|\ | | | | | | Fix default value for mysql time types with specified precision
| * Fix default value for mysql time types with specified precisionNikolay Kondratyev2018-07-041-0/+4
|/ | | | | | | | | | | | | | | | The TIME, DATETIME, and TIMESTAMP types [have supported](https://mariadb.com/kb/en/library/microseconds-in-mariadb/) a fractional seconds precision from 0 to 6. Default values from time columns with specified precision is read as `current_timestamp(n)` from information schema. rake `db:schema:dump` produces `schema.rb` **without** default values for time columns with the specified precision: t.datetime "last_message_at", precision: 6, null: false rake `db:schema:dump` produces `schema.rb` **with** default values for time columns with the specified precision: t.datetime "last_message_at", precision: 6, default: -> { "current_timestamp(6)" }, null: false
* Fix `touch` option to behave consistently with `Persistence#touch` methodRyuta Kamizono2018-06-181-0/+4
| | | | | | | | | | | | | | | | `touch` option was added to `increment!` (#27660) and `update_counters` (#26995). But that option behaves inconsistently with `Persistence#touch` method. If `touch` option is passed attribute names, it won't update update_at/on attributes unlike `Persistence#touch` method. Due to changed from `Persistence#touch` to `increment!` with `touch` option, #31405 has a regression that `counter_cache` with `touch` option which is passed attribute names won't update update_at/on attributes. I think that the inconsistency is not intended. To get back consistency, ensure that `touch` option updates update_at/on attributes.
* Merge pull request #29373 from untidy-hair/store_accessor_enhanceRyuta Kamizono2018-06-131-2/+2
|\ | | | | | | Allow prefix/suffix options for store accessors
* | :scissors:Ryuta Kamizono2018-06-101-1/+1
| | | | | | | | [ci skip]
* | Migrations will raise an exception if there are multiple column definitions ↵Federico Martinez2018-06-011-0/+6
| | | | | | | | (same name).
* | [skip ci] Add changelog about bumping minimum SQLite version to 3.8Yasuo Honda2018-06-011-0/+4
| | | | | | | | Related to #32923
* | Merge pull request #32952 from mechanicles/32940-fixRyuta Kamizono2018-05-291-0/+6
|\ \ | |/ |/| | | Fix parent record should not get saved with duplicate children records
| * Fix parent record should not get saved with duplicate children recordsSantosh Wadghule2018-05-281-0/+6
|/ | | | - Fixes #32940
* Fix logic on disabling commit callbacksBrian Durand2018-05-041-0/+4
| | | | Commit callbacks are intentionally disabled when errors occur when calling the callback chain in order to reset the internal record state. However, the implicit order of operations on the logic for checking if callbacks are disabled is wrong. The result is that callbacks can be unexpectedly when errors occur in transactions.
* Loaded associations should not run a new query when size is calledGraham Turner2018-04-261-0/+5
| | | | | | | Already loaded associations were running an extra query when `size` was called on the association. This fix ensures that an extra query is no longer run. Update tests to use proper methods
* Can preload associations through polymorphic associationsDana Sherson2018-04-201-0/+4
|
* Add `touch_all` method to `ActiveRecord::Relation`fatkodima2018-04-131-0/+8
|
* [ci skip] Fully quantify Active Record module in changelog.Kasper Timm Hansen2018-04-021-1/+1
|
* Add AR::Base.base_class? predicateBogdan Gusiev2018-04-021-0/+4
|
* Add custom prefix to ActiveRecord::Store accessorsTan Huynh2018-03-231-0/+4
| | | | | | Add a prefix option to ActiveRecord::Store.store_accessor and ActiveRecord::Store.store. This option allows stores to have identical keys with different accessors.
* Remove changelog header for unreleased versionRafael Mendonça França2018-03-131-2/+0
| | | | | | We only add the header when releasing to avoid some conflicts. [ci skip]
* Remove CHANGELOG entries which were backported to 5-2-stableRyuta Kamizono2018-02-281-14/+0
|
* Fix a typo in activerecord/CHANGELOG.mdokkez2018-02-281-1/+1
| | | | columsn -> columns
* Merge pull request #31966 from kg8m/fix_limited_ids_forRyuta Kamizono2018-02-281-0/+8
|\ | | | | | | Use column alias of primary_key in limited_ids_for
| * Fix `#columsn_for_distinct` of MySQL and PostgreSQLkg8m2018-02-271-0/+8
|/ | | | | | | Prevent `ActiveRecord::FinderMethods#limited_ids_for` from using correct primary key values even if `ORDER BY` columns include other table's primary key. Fixes #28364.
* Make `reflection.klass` raise if `polymorphic?` not to be misusedRyuta Kamizono2018-02-191-0/+6
| | | | | | | | | | | | | | | | This is an alternative of #31877 to fix #31876 caused by #28808. This issue was caused by a combination of several loose implementation. * finding automatic inverse association of polymorphic without context (caused by #28808) * returning `klass` even if `polymorphic?` (exists before #28808) * loose verification by `valid_inverse_reflection?` (exists before #28808) This makes `klass` raise if `polymorphic?` not to be misused. This issue will not happen unless polymorphic `klass` is misused. Fixes #31876. Closes #31877.
* Add a CHANGELOG entry for #31941 [ci skip]Ryuta Kamizono2018-02-191-0/+4
|
* Rails 6 requires Ruby 2.4.1+Jeremy Daer2018-02-171-0/+5
| | | | | | Skipping over 2.4.0 to sidestep the `"symbol_from_string".to_sym.dup` bug. References #32028
* Deprecate update_attributes and update_attributes!Eddie Lebow2018-02-171-0/+3
| | | | Closes #31998
* Add #create_or_find_by to lean on unique constraints (#31989)David Heinemeier Hansson2018-02-141-0/+6
| | | Add #create_or_find_by to lean on unique constraints
* Start Rails 6.0 development!!!Rafael Mendonça França2018-01-301-667/+1
| | | | :tada::tada::tada:
* Deprecate `expand_hash_conditions_for_aggregates`Ryuta Kamizono2018-01-291-0/+5
| | | | | This can not expand an array of aggregated objects correctly, and is no longer used internally since 159b21b5.
* Merge pull request #31724 from orekyuu/fix-expand-composed-object-arrayRyuta Kamizono2018-01-291-0/+14
|\ | | | | | | Fix not expanded problem when passing an Array object as argument to the where method using composed_of column.
| * Fix not expanded problem when passing an Array object as argument to the ↵orekyuu2018-01-261-0/+14
|/ | | | | | | | | | | | | | where method using composed_of column. Fixes #31723 ``` david_balance = customers(:david).balance Customer.where(balance: [david_balance]).to_sql # Before: WHERE `customers`.`balance` = NULL # After : WHERE `customers`.`balance` = 50 ```
* Fix `count(:all)` with eager loading and having an order other than the ↵Ryuta Kamizono2018-01-251-0/+6
| | | | | | | | | | | | | | | | | | | driving table This is a regression caused by 6beb4de. In PostgreSQL, ORDER BY expressions must appear in SELECT list when using DISTINCT. When using `count(:all)` with eager loading, Active Record enforces DISTINCT to count the driving table records only. 6beb4de was caused the regression because `count(:all)` with DISTINCT path no longer removes ORDER BY. We need to ignore ORDER BY when DISTINCT is enforced, otherwise not always generated valid SQL for PostgreSQL. Fixes #31783.
* Expand AR to Active Record [ci skip]Ryuta Kamizono2018-01-251-2/+2
|
* Clear the transaction state when AR object is dupedYuriy Ustushenko2018-01-251-0/+6
|
* Support for PostgreSQL foreign tablesfatkodima2018-01-221-0/+4
|
* Fix relation merger issue with `left_outer_joins`Mehmet Emin INAC2018-01-151-0/+4
|
* Don't allow destroyed object mutation after `save` or `save!` is calledRyuta Kamizono2018-01-151-0/+4
| | | | | | | | | | Currently `object.save` will unfreeze the object, due to `changes_applied` replaces frozen `@attributes` to new `@attributes`. Since originally destroyed objects are not allowed to be mutated, `save` and `save!` should not return success in that case. Fixes #28563.
* Merge pull request #23146 from piotrj/issue_18424Ryuta Kamizono2018-01-111-0/+6
|\ | | | | | | When deleting through records, take into account association conditions
* \ Merge pull request #16314 from ↵Ryuta Kamizono2018-01-101-0/+38
|\ \ | | | | | | | | | | | | | | | zoltankiss/allow-nested-has-many-associations-on-unpersisted-parent-instances fix nested `has many :through` associations on unpersisted parent instances
* | | resolve inconsistencies between first and to_a.first with limitBrian Christian2018-01-091-0/+8
| | |
* | | Merge pull request #27561 from fishbrain/count-all-in-has-many-associationRyuta Kamizono2018-01-031-0/+5
|\ \ \ | | | | | | | | | | | | Use `count(:all)` in HasManyAssociation#count_records
| * | | Use `count(:all)` in HasManyAssociation#count_recordsKlas Eskilson2017-02-071-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: Calling `count` on an association can cause invalid SQL queries to be created where the `SELECT COUNT(a, b, c)` function receives multiple columns. This will cause a `StatementInvalid` exception later on. Solution: Use `count(:all)`, which generates a `SELECT COUNT(*)...` query independently of the association. This also includes a test case that, before the fix, broke.
* | | | Merge pull request #27780 from ↵Ryuta Kamizono2017-12-251-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | mikelikesbikes/fix-update-attribute-callbacks-issue save attributes changed by callbacks after update_attribute
* | | | Remove verbose_query_logs from new_framework_defaults_5_2.rbEugene Kenny2017-12-201-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The `app:update` rake task will regenerate `development.rb` so that it contains this option; that means we're currently adding it to existing apps in two places, which is unnecessary and confusing. Also: - Remove inaccurate comment about which stack frames are ignored - Clarify that the feature uses `caller_locations`, not `caller` - Remove unused return value in `extract_callstack`
* | | | Fix `count(:all)` to correctly work `distinct` with custom SELECT listRyuta Kamizono2017-12-201-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently `count(:all)` with `distinct` doesn't work correctly because SELECT list is always replaced to `*` or primary key in that case even if having custom SELECT list. And also, PostgreSQL has a limitation that ORDER BY expressions must appear in select list for SELECT DISTINCT. Therefore, we should not replace custom SELECT list when using `count(:all)` with `distinct`. Closes #31277.
* | | | Using subselect for `delete_all` with `limit` or `offset`Ryuta Kamizono2017-12-191-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | Arel doesn't support subselect generation for DELETE unlike UPDATE yet, but we already have that generation in connection adapters. We can simply use the subselect generated by that one.
* | | | Add changelog entry for e1ceb10Chris Salzberg2017-12-171-0/+5
| | | |
* | | | Log call site for all queriesOlivier Lacan2017-12-131-1/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This new ActiveRecord configuration option allows you to easily pinpoint what line of application code is triggering SQL queries in the development log by appending below each SQL statement log the line of Ruby code that triggered it. It’s useful with N+1 issues, and to locate stray queries. By default this new option ignores Rails and Ruby code in order to surface only callers from your application Ruby code or your gems. It is enabled on newly generated Rails 5.2 applications and can be enabled on existing Rails applications: ```ruby Rails.application.configure do # ... config.active_record.verbose_query_logs = true end ``` The `rails app:upgrade` task will also add it to `config/development.rb`. This feature purposely avoids coupling with ActiveSupport::BacktraceCleaner since ActiveRecord can be used without ActiveRecord. This decision can be reverted in the future to allow more configurable backtraces (the exclusion of gem callers for example).
* | | | Fix conflicts `counter_cache` with `touch: true` by optimistic locking.bogdanvlviv2017-12-121-0/+83
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ``` # 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.