diff options
Diffstat (limited to 'activerecord/CHANGELOG.md')
-rw-r--r-- | activerecord/CHANGELOG.md | 202 |
1 files changed, 180 insertions, 22 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index 4ca33491aa..d59101d621 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -1,3 +1,165 @@ +* Delegate `empty?`, `none?` and `one?`. Now they can be invoked as model class methods. + + Example: + + # When no record is found on the table + Topic.empty? # => true + Topic.none? # => true + + # When only one record is found on the table + Topic.one? # => true + + *Kenta Shirai* + +* The form builder now properly displays values when passing a proc form + default to the attributes API. + + Fixes #24249. + + *Sean Griffin* + +* The schema cache is now cleared after the `db:migrate` task is run. + + Closes #24273. + + *Chris Arcand* + +* MySQL: strict mode respects other SQL modes rather than overwriting them. + Setting `strict: true` adds `STRICT_ALL_TABLES` to `sql_mode`. Setting + `strict: false` removes `STRICT_TRANS_TABLES`, `STRICT_ALL_TABLES`, and + `TRADITIONAL` from `sql_mode`. + + *Ryuta Kamizono* + +* Execute default_scope defined by abstract class in the context of subclass. + + Fixes #23413. + Fixes #10658. + + *Mehmet Emin İNAÇ* + +* Fix an issue when preloading associations with extensions. + Previously every association with extension methods was transformed into an + instance dependent scope. This is no longer the case. + + Fixes #23934. + + *Yves Senn* + +* Deprecate `{insert|update|delete}_sql` in `DatabaseStatements`. + Use the `{insert|update|delete}` public methods instead. + + *Ryuta Kamizono* + +* Added a configuration option to have active record raise an ArgumentError + if the order or limit is ignored in a batch query, rather than logging a + warning message. + + *Scott Ringwelski* + +* Honour the order of the joining model in a `has_many :through` association when eager loading. + + Example: + + The below will now follow the order of `by_lines` when eager loading `authors`. + + class Article < ActiveRecord::Base + has_many :by_lines, -> { order(:position) } + has_many :authors, through: :by_lines + end + + Fixes #17864. + + *Yasyf Mohamedali*, *Joel Turkel* + +* Ensure that the Suppressor runs before validations. + + This moves the suppressor up to be run before validations rather than after + validations. There's no reason to validate a record you aren't planning on saving. + + *Eileen M. Uchitelle* + +## Rails 5.0.0.beta3 (February 24, 2016) ## + +* Save many-to-many objects based on association primary key. + + Fixes #20995. + + *himesh-r* + +* Ensure that mutations of the array returned from `ActiveRecord::Relation#to_a` + do not affect the original relation, by returning a duplicate array each time. + + This brings the behavior in line with `CollectionProxy#to_a`, which was + already more careful. + + *Matthew Draper* + +* Fixed `where` for polymorphic associations when passed an array containing different types. + + Fixes #17011. + + Example: + + PriceEstimate.where(estimate_of: [Treasure.find(1), Car.find(2)]) + # => SELECT "price_estimates".* FROM "price_estimates" + WHERE (("price_estimates"."estimate_of_type" = 'Treasure' AND "price_estimates"."estimate_of_id" = 1) + OR ("price_estimates"."estimate_of_type" = 'Car' AND "price_estimates"."estimate_of_id" = 2)) + + *Philippe Huibonhoa* + +* Fix a bug where using `t.foreign_key` twice with the same `to_table` within + the same table definition would only create one foreign key. + + *George Millo* + +* Fix a regression on has many association, where calling a child from parent in child's callback + results in same child records getting added repeatedly to target. + + Fixes #13387. + + *Bogdan Gusiev*, *Jon Hinson* + +* Rework `ActiveRecord::Relation#last`. + + 1. Never perform additional SQL on loaded relation + 2. Use SQL reverse order instead of loading relation if relation doesn't have limit + 3. Deprecated relation loading when SQL order can not be automatically reversed + + Topic.order("title").load.last(3) + # before: SELECT ... + # after: No SQL + + Topic.order("title").last + # before: SELECT * FROM `topics` + # after: SELECT * FROM `topics` ORDER BY `topics`.`title` DESC LIMIT 1 + + Topic.order("coalesce(author, title)").last + # before: SELECT * FROM `topics` + # after: Deprecation Warning for irreversible order + + *Bogdan Gusiev* + +* Allow `joins` to be unscoped. + + Fixes #13775. + + *Takashi Kokubun* + +* Add ActiveRecord `#second_to_last` and `#third_to_last` methods. + + *Brian Christian* + +* Added `numeric` helper into migrations. + + Example: + + create_table(:numeric_types) do |t| + t.numeric :numeric_type, precision: 10, scale: 2 + end + + *Mehmet Emin İNAÇ* + * Bumped the minimum supported version of PostgreSQL to >= 9.1. Both PG 9.0 and 8.4 are past their end of life date: http://www.postgresql.org/support/versioning/ @@ -106,6 +268,21 @@ ## Rails 5.0.0.beta1 (December 18, 2015) ## +* Limit record touching to once per transaction. + + If you have a parent/grand-parent relation like: + + Comment belongs_to :message, touch: true + Message belongs_to :project, touch: true + Project belongs_to :account, touch: true + + When the lowest entry(`Comment`) is saved, now, it won't repeat the touch + call multiple times for the parent records. + + Related #18606. + + *arthurnn* + * Order the result of `find(ids)` to match the passed array, if the relation has no explicit order defined. @@ -380,13 +557,13 @@ * Add option to index errors in nested attributes For models which have nested attributes, errors within those models will - now be indexed if :index_errors is specified when defining a + now be indexed if `:index_errors` is specified when defining a has_many relationship, or if its set in the global config. Example: class Guitar < ActiveRecord::Base - has_many :tuning_pegs + has_many :tuning_pegs, index_errors: true accepts_nested_attributes_for :tuning_pegs end @@ -602,7 +779,7 @@ *Ben Murphy*, *Matthew Draper* -* `bin/rake db:migrate` uses +* `bin/rails db:migrate` uses `ActiveRecord::Tasks::DatabaseTasks.migrations_paths` instead of `Migrator.migrations_paths`. @@ -1004,13 +1181,6 @@ *Alex Coomans* -* Dump indexes in `create_table` instead of `add_index`. - - If the adapter supports indexes in `create_table`, generated SQL is - slightly more efficient. - - *Ryuta Kamizono* - * Correctly dump `:options` on `create_table` for MySQL. *Ryuta Kamizono* @@ -1385,18 +1555,6 @@ *Chris Sinjakli* -* Validation errors would be raised for parent records when an association - was saved when the parent had `validate: false`. It should not be the - responsibility of the model to validate an associated object unless the - object was created or modified by the parent. - - This fixes the issue by skipping validations if the parent record is - persisted, not changed, and not marked for destruction. - - Fixes #17621. - - *Eileen M. Uchitelle*, *Aaron Patterson* - * Fix n+1 query problem when eager loading nil associations (fixes #18312) *Sammy Larbi* |