aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/CHANGELOG.md
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/CHANGELOG.md')
-rw-r--r--activerecord/CHANGELOG.md443
1 files changed, 389 insertions, 54 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md
index 3576f5c905..cd4b297c8c 100644
--- a/activerecord/CHANGELOG.md
+++ b/activerecord/CHANGELOG.md
@@ -1,3 +1,345 @@
+* 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) ##
+
+* 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/
+
+ *Remo Mueller*
+
+## Rails 5.0.0.beta2 (February 01, 2016) ##
+
+* `ActiveRecord::Relation#reverse_order` throws `ActiveRecord::IrreversibleOrderError`
+ when the order can not be reversed using current trivial algorithm.
+ Also raises the same error when `#reverse_order` is called on
+ relation without any order and table has no primary key:
+
+ Topic.order("concat(author_name, title)").reverse_order
+ # Before: SELECT `topics`.* FROM `topics` ORDER BY concat(author_name DESC, title) DESC
+ # After: raises ActiveRecord::IrreversibleOrderError
+ Edge.all.reverse_order
+ # Before: SELECT `edges`.* FROM `edges` ORDER BY `edges`.`` DESC
+ # After: raises ActiveRecord::IrreversibleOrderError
+
+ *Bogdan Gusiev*
+
+* Improve schema_migrations insertion performance by inserting all versions
+ in one INSERT SQL.
+
+ *Akira Matsuda*, *Naoto Koshikawa*
+
+* Using `references` or `belongs_to` in migrations will always add index
+ for the referenced column by default, without adding `index: true` option
+ to generated migration file. Users can opt out of this by passing
+ `index: false`.
+
+ Fixes #18146.
+
+ *Matthew Draper*, *Prathamesh Sonpatki*
+
+* Run `type` attributes through attributes API type-casting before
+ instantiating the corresponding subclass. This makes it possible to define
+ custom STI mappings.
+
+ Fixes #21986.
+
+ *Yves Senn*
+
+* Don't try to quote functions or expressions passed to `:default` option if
+ they are passed as procs.
+
+ This will generate proper query with the passed function or expression for
+ the default option, instead of trying to quote it in incorrect fashion.
+
+ Example:
+
+ create_table :posts do |t|
+ t.datetime :published_at, default: -> { 'NOW()' }
+ end
+
+ *Ryuta Kamizono*
+
+* Fix regression when loading fixture files with symbol keys.
+
+ Fixes #22584.
+
+ *Yves Senn*
+
+* Use `version` column as primary key for schema_migrations table because
+ `schema_migrations` versions are guaranteed to be unique.
+
+ This makes it possible to use `update_attributes` on models that do
+ not have a primary key.
+
+ *Richard Schneeman*
+
+* Add short-hand methods for text and blob types in MySQL.
+
+ In Pg and Sqlite3, `:text` and `:binary` have variable unlimited length.
+ But in MySQL, these have limited length for each types (ref #21591, #21619).
+ This change adds short-hand methods for each text and blob types.
+
+ Example:
+
+ create_table :foos do |t|
+ t.tinyblob :tiny_blob
+ t.mediumblob :medium_blob
+ t.longblob :long_blob
+ t.tinytext :tiny_text
+ t.mediumtext :medium_text
+ t.longtext :long_text
+ end
+
+ *Ryuta Kamizono*
+
+* Take into account UTC offset when assigning string representation of
+ timestamp with offset specified to attribute of time type.
+
+ *Andrey Novikov*
+
+* When calling `first` with a `limit` argument, return directly from the
+ `loaded?` records if available.
+
+ *Ben Woosley*
+
+* Deprecate sending the `offset` argument to `find_nth`. Please use the
+ `offset` method on relation instead.
+
+ *Ben Woosley*
+
+## Rails 5.0.0.beta1 (December 18, 2015) ##
+
+* Order the result of `find(ids)` to match the passed array, if the relation
+ has no explicit order defined.
+
+ Fixes #20338.
+
+ *Miguel Grazziotin*, *Matthew Draper*
+
+* Omit default limit values in dumped schema. It's tidier, and if the defaults
+ change in the future, we can address that via Migration API Versioning.
+
+ *Jean Boussier*
+
+* Support passing the schema name as a prefix to table name in
+ `ConnectionAdapters::SchemaStatements#indexes`. Previously the prefix would
+ be considered a full part of the index name, and only the schema in the
+ current search path would be considered.
+
+ *Grey Baker*
+
+* Ignore index name in `index_exists?` and `remove_index` when not passed a
+ name to check for.
+
+ *Grey Baker*
+
+* Extract support for the legacy `mysql` database adapter from core. It will
+ live on in a separate gem for now, but most users should just use `mysql2`.
+
+ *Abdelkader Boudih*
+
+* ApplicationRecord is a new superclass for all app models, analogous to app
+ controllers subclassing ApplicationController instead of
+ ActionController::Base. This gives apps a single spot to configure app-wide
+ model behavior.
+
+ Newly generated applications have `app/models/application_record.rb`
+ present by default.
+
+ *Genadi Samokovarov*
+
+* Version the API presented to migration classes, so we can change parameter
+ defaults without breaking existing migrations, or forcing them to be
+ rewritten through a deprecation cycle.
+
+ New migrations specify the Rails version they were written for:
+
+ class AddStatusToOrders < ActiveRecord::Migration[5.0]
+ def change
+ # ...
+ end
+ end
+
+ *Matthew Draper*, *Ravil Bayramgalin*
+
+* Use bind params for `limit` and `offset`. This will generate significantly
+ fewer prepared statements for common tasks like pagination. To support this
+ change, passing a string containing a comma to `limit` has been deprecated,
+ and passing an Arel node to `limit` is no longer supported.
+
+ Fixes #22250.
+
+ *Sean Griffin*
+
+* Introduce after_{create,update,delete}_commit callbacks.
+
+ Before:
+
+ after_commit :add_to_index_later, on: :create
+ after_commit :update_in_index_later, on: :update
+ after_commit :remove_from_index_later, on: :destroy
+
+ After:
+
+ after_create_commit :add_to_index_later
+ after_update_commit :update_in_index_later
+ after_destroy_commit :remove_from_index_later
+
+ Fixes #22515.
+
+ *Genadi Samokovarov*
+
+* Respect the column default values for `inheritance_column` when
+ instantiating records through the base class.
+
+ Fixes #17121.
+
+ Example:
+
+ # The schema of BaseModel has `t.string :type, default: 'SubType'`
+ subtype = BaseModel.new
+ assert_equals SubType, subtype.class
+
+ *Kuldeep Aggarwal*
+
+* Fix `rake db:structure:dump` on Postgres when multiple schemas are used.
+
+ Fixes #22346.
+
+ *Nick Muerdter*, *ckoenig*
+
+* Add schema dumping support for PostgreSQL geometric data types.
+
+ *Ryuta Kamizono*
+
+* Except keys of `build_record`'s argument from `create_scope` in `initialize_attributes`.
+
+ Fixes #21893.
+
+ *Yuichiro Kaneko*
+
+* Deprecate `connection.tables` on the SQLite3 and MySQL adapters.
+ Also deprecate passing arguments to `#tables`.
+ And deprecate `table_exists?`.
+
+ The `#tables` method of some adapters (mysql, mysql2, sqlite3) would return
+ both tables and views while others (postgresql) just return tables. To make
+ their behavior consistent, `#tables` will return only tables in the future.
+
+ The `#table_exists?` method would check both tables and views. To make
+ their behavior consistent with `#tables`, `#table_exists?` will check only
+ tables in the future.
+
+ *Yuichiro Kaneko*
+
+* Improve support for non Active Record objects on `validates_associated`
+
+ Skipping `marked_for_destruction?` when the associated object does not responds
+ to it make easier to validate virtual associations built on top of Active Model
+ objects and/or serialized objects that implement a `valid?` instance method.
+
+ *Kassio Borges*, *Lucas Mazza*
+
+* Change connection management middleware to return a new response with
+ a body proxy, rather than mutating the original.
+
+ *Kevin Buchanan*
+
* Make `db:migrate:status` to render `1_some.rb` format migrate files.
These files are in `db/migrate`:
@@ -60,7 +402,7 @@
*Takashi Kokubun*
-* Use advisory locking to raise a ConcurrentMigrationError instead of
+* Use advisory locking to raise a `ConcurrentMigrationError` instead of
attempting to migrate when another migration is currently running.
*Sam Davies*
@@ -80,7 +422,7 @@
*Aaron Suggs*
* Avoid disabling errors on the PostgreSQL connection when enabling the
- standard_conforming_strings setting. Errors were previously disabled because
+ `standard_conforming_strings` setting. Errors were previously disabled because
the setting wasn't writable in Postgres 8.1 and didn't exist in earlier
versions. Now Rails only supports Postgres 8.2+ we're fine to assume the
setting exists. Disabling errors caused problems when using a connection
@@ -92,7 +434,7 @@
*Harry Marr*
-* Set `scope.reordering_value` to `true` if :reordering values are specified.
+* Set `scope.reordering_value` to `true` if `:reordering`-values are specified.
Fixes #21886.
@@ -151,13 +493,13 @@
validates_numericality_of :pitch
end
- - Old style
- - `guitar.errors["tuning_pegs.pitch"] = ["is not a number"]`
+ # Old style
+ guitar.errors["tuning_pegs.pitch"] = ["is not a number"]
- - New style (if defined globally, or set in has_many_relationship)
- - `guitar.errors["tuning_pegs[1].pitch"] = ["is not a number"]`
+ # New style (if defined globally, or set in has_many_relationship)
+ guitar.errors["tuning_pegs[1].pitch"] = ["is not a number"]
- *Michael Probber and Terence Sun*
+ *Michael Probber*, *Terence Sun*
* Exit with non-zero status for failed database rake tasks.
@@ -170,21 +512,23 @@
*Rafael Sales*
-* Add ability to default to `uuid` as primary key when generating database migrations
+* Add ability to default to `uuid` as primary key when generating database migrations.
- config.generators do |g|
- g.orm :active_record, primary_key_type: :uuid
- end
+ Example:
+
+ config.generators do |g|
+ g.orm :active_record, primary_key_type: :uuid
+ end
*Jon McCartie*
-* Don't cache arguments in #find_by if they are an ActiveRecord::Relation
+* Don't cache arguments in `#find_by` if they are an `ActiveRecord::Relation`.
- Fixes #20817
+ Fixes #20817.
*Hiroaki Izu*
-* Qualify column name inserted by `group` in calculation
+* Qualify column name inserted by `group` in calculation.
Giving `group` an unqualified column name now works, even if the relation
has `JOIN` with another table which also has a column of the name.
@@ -209,11 +553,11 @@
*Jake Worth*
* Add an immutable string type to help reduce memory usage for apps which do
- not need mutation detection on Strings.
+ not need mutation detection on strings.
*Sean Griffin*
-* Give `AcriveRecord::Relation#update` its own deprecation warning when
+* Give `ActiveRecord::Relation#update` its own deprecation warning when
passed an `ActiveRecord::Base` instance.
Fixes #21945.
@@ -227,7 +571,7 @@
*Yves Senn*
-* No longer pass depreacted option `-i` to `pg_dump`.
+* No longer pass deprecated option `-i` to `pg_dump`.
*Paul Sadauskas*
@@ -242,7 +586,7 @@
*Matthew Draper*, *Jean Boussier*
-* Remove unused `pk_and_sequence_for` in AbstractMysqlAdapter.
+* Remove unused `pk_and_sequence_for` in `AbstractMysqlAdapter`.
*Ryuta Kamizono*
@@ -250,10 +594,10 @@
To load the fixtures file `accounts.yml` as the `User` model, use:
- _fixture:
- model_class: User
- david:
- name: David
+ _fixture:
+ model_class: User
+ david:
+ name: David
Fixes #9516.
@@ -268,7 +612,7 @@
*Jimmy Bourassa*
-* Fixed taking precision into count when assigning a value to timestamp attribute
+* Fixed taking precision into count when assigning a value to timestamp attribute.
Timestamp column can have less precision than ruby timestamp
In result in how big a fraction of a second can be stored in the
@@ -298,7 +642,7 @@
*Yves Senn*, *Matthew Draper*
* Add `ActiveRecord::Base.ignored_columns` to make some columns
- invisible from ActiveRecord.
+ invisible from Active Record.
*Jean Boussier*
@@ -309,9 +653,9 @@
* Ensure `select` quotes aliased attributes, even when using `from`.
- Fixes #21488
+ Fixes #21488.
- *Sean Griffin & @johanlunds*
+ *Sean Griffin*, *@johanlunds*
* MySQL: support `unsigned` numeric data types.
@@ -356,7 +700,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`.
@@ -374,6 +718,13 @@
*Wojciech Wnętrzak*
+* Instantiating an AR model with `ActionController::Parameters` now raises
+ an `ActiveModel::ForbiddenAttributesError` if the parameters include a
+ `type` field that has not been explicitly permitted. Previously, the
+ `type` field was simply ignored in the same situation.
+
+ *Prem Sichanugrist*
+
* PostgreSQL, `create_schema`, `drop_schema` and `rename_table` now quote
schema names.
@@ -429,7 +780,7 @@
* Add `ActiveRecord::Relation#in_batches` to work with records and relations
in batches.
- Available options are `of` (batch size), `load`, `begin_at`, and `end_at`.
+ Available options are `of` (batch size), `load`, `start`, and `finish`.
Examples:
@@ -630,7 +981,7 @@
* Include the `Enumerable` module in `ActiveRecord::Relation`
- *Sean Griffin & bogdan*
+ *Sean Griffin*, *bogdan*
* Use `Enumerable#sum` in `ActiveRecord::Relation` if a block is given.
@@ -666,7 +1017,7 @@
Fixes #20515.
- *Sean Griffin & jmondo*
+ *Sean Griffin*, *jmondo*
* Deprecate the PostgreSQL `:point` type in favor of a new one which will return
`Point` objects instead of an `Array`
@@ -751,13 +1102,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*
@@ -1056,13 +1400,16 @@
*Sean Griffin*
* `scoping` no longer pollutes the current scope of sibling classes when using
- STI. e.x.
+ STI.
+
+ Fixes #18806.
+
+ Example:
StiOne.none.scoping do
StiTwo.all
end
- Fixes #18806.
*Sean Griffin*
@@ -1074,7 +1421,7 @@
*Yves Senn*
-* `find_in_batches` now accepts an `:end_at` parameter that complements the `:start`
+* `find_in_batches` now accepts an `:finish` parameter that complements the `:start`
parameter to specify where to stop batch processing.
*Vipul A M*
@@ -1103,7 +1450,7 @@
* Use `SCHEMA` instead of `DB_STRUCTURE` for specifying a structure file.
- This makes the db:structure tasks consistent with test:load_structure.
+ This makes the `db:structure` tasks consistent with `test:load_structure`.
*Dieter Komendera*
@@ -1129,18 +1476,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*