aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/CHANGELOG.md
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/CHANGELOG.md')
-rw-r--r--activerecord/CHANGELOG.md1745
1 files changed, 763 insertions, 982 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md
index 304c48bf44..a6ed8cdb06 100644
--- a/activerecord/CHANGELOG.md
+++ b/activerecord/CHANGELOG.md
@@ -1,1555 +1,1336 @@
-* ActiveRecord states are now correctly restored after a rollback for
- models that did not define any transactional callbacks (i.e.
- `after_commit`, `after_rollback` or `after_create`).
+* Bring back `db:test:prepare` to synchronize the test database schema.
- Fixes #13744.
+ Manual synchronization using `bin/rake db:test:prepare` is required
+ when a migration is rolled-back, edited and reapplied.
- *Godfrey Chan*
-
-* Make `touch` fire the `after_commit` and `after_rollback` callbacks.
+ `ActiveRecord::Base.maintain_test_schema` now uses `db:test:prepare`
+ to synchronize the schema. Plugins can use this task as a hook to
+ provide custom behavior after the schema has been loaded.
- *Harry Brundage*
+ NOTE: `test:prepare` runs before the schema is synchronized.
-* Enable partial indexes for sqlite >= 3.8.0
+ Fixes #17171, #15787.
- See http://www.sqlite.org/partialindex.html
+ *Yves Senn*
- *Cody Cutrer*
+* Change `reflections` public api to return the keys as String objects.
-* Don't try to get the subclass if the inheritance column doesn't exist
+ Fixes #16928.
- The `subclass_from_attrs` method is called even if the column specified by
- the `inheritance_column` setting doesn't exist. This prevents setting associations
- via the attributes hash if the association name clashes with the value of the setting,
- typically `:type`. This worked previously in Rails 3.2.
+ *arthurnn*
- *Ujjwal Thaakar*
+* Renaming a table in pg also renames the primary key index.
-* Enum mappings are now exposed via class methods instead of constants.
+ Fixes #12856
- Example:
+ *Sean Griffin*
- class Conversation < ActiveRecord::Base
- enum status: [ :active, :archived ]
- end
+* Make it possible to access fixtures excluded by a `default_scope`.
- Before:
+ *Yves Senn*
- Conversation::STATUS # => { "active" => 0, "archived" => 1 }
+* Fix preloading of associations with a scope containing joins along with
+ conditions on the joined association.
- After:
+ *Siddharth Sharma*
- Conversation.statuses # => { "active" => 0, "archived" => 1 }
+* Add `Table#name` to match `TableDefinition#name`.
- *Godfrey Chan*
+ *Cody Cutrer*
-* Set `NameError#name` when STI-class-lookup fails.
+* Cache `CollectionAssociation#reader` proxies separately before and after
+ the owner has been saved so that the proxy is not cached without the
+ owner's id.
- *Chulki Lee*
+ *Ben Woosley*
-* Fix bug in `becomes!` when changing from the base model to a STI sub-class.
+* `ActiveRecord::ReadOnlyRecord` now has a descriptive message.
- Fixes #13272.
+ *Franky W.*
- *the-web-dev*, *Yves Senn*
+* Fix preloading of associations which unscope a default scope.
-* Currently Active Record can be configured via the environment variable
- `DATABASE_URL` or by manually injecting a hash of values which is what Rails does,
- reading in `database.yml` and setting Active Record appropriately. Active Record
- expects to be able to use `DATABASE_URL` without the use of Rails, and we cannot
- rip out this functionality without deprecating. This presents a problem though
- when both config is set, and a `DATABASE_URL` is present. Currently the
- `DATABASE_URL` should "win" and none of the values in `database.yml` are
- used. This is somewhat unexpected, if one were to set values such as
- `pool` in the `production:` group of `database.yml` they are ignored.
+ Fixes #11036.
- There are many ways that Active Record initiates a connection today:
+ *Byron Bischoff*
- - Stand Alone (without rails)
- - `rake db:<tasks>`
- - `ActiveRecord.establish_connection`
+* Added SchemaDumper support for tables with jsonb columns.
- - With Rails
- - `rake db:<tasks>`
- - `rails <server> | <console>`
- - `rails dbconsole`
+ *Ted O'Meara*
- Now all of these behave exactly the same way. The best way to do
- this is to put all of this logic in one place so it is guaranteed to be used.
+* Deprecate `sanitize_sql_hash_for_conditions` without replacement. Using a
+ `Relation` for performing queries and updates is the prefered API.
- Here is the matrix of how this behavior works:
+ *Sean Griffin*
- ```
- No database.yml
- No DATABASE_URL
- => Error
- ```
+* Queries now properly type cast values that are part of a join statement,
+ even when using type decorators such as `serialize`.
- ```
- database.yml present
- No DATABASE_URL
- => Use database.yml configuration
- ```
+ *Melanie Gilman & Sean Griffin*
- ```
- No database.yml
- DATABASE_URL present
- => use DATABASE_URL configuration
- ```
+* MySQL enum type lookups, with values matching another type, no longer result
+ in an endless loop.
- ```
- database.yml present
- DATABASE_URL present
- => Merged into `url` sub key. If both specify `url` sub key, the `database.yml` `url`
- sub key "wins". If other paramaters `adapter` or `database` are specified in YAML,
- they are discarded as the `url` sub key "wins".
- ```
+ Fixes #17402.
- Current implementation uses `ActiveRecord::Base.configurations` to resolve and merge
- all connection information before returning. This is achieved through a utility
- class: `ActiveRecord::ConnectionHandling::MergeAndResolveDefaultUrlConfig`.
+ *Yves Senn*
- To understand the exact behavior of this class, it is best to review the
- behavior in `activerecord/test/cases/connection_adapters/connection_handler_test.rb`.
+* Raise `ArgumentError` when the body of a scope is not callable.
- *Richard Schneeman*
+ *Mauro George*
-* Make `change_column_null` revertable. Fixes #13576.
+* Use type column first in multi-column indexes created with `add-reference`.
- *Yves Senn*, *Nishant Modak*, *Prathamesh Sonpatki*
+ *Derek Prior*
-* Don't create/drop the test database if RAILS_ENV is specified explicitly.
+* Fix `Relation.rewhere` to work with Range values.
- Previously, when the environment was development, we would always
- create or drop both the test and development databases.
+ *Dan Olson*
- Now, if RAILS_ENV is explicitly defined as development, we don't create
- the test database.
+* `AR::UnknownAttributeError` now includes the class name of a record.
- *Damien Mathieu*
+ User.new(name: "Yuki Nishijima", project_attributes: {name: "kaminari"})
+ # => ActiveRecord::UnknownAttributeError: unknown attribute 'name' for User.
-* Initialize version on Migration objects so that it can be used in a migration,
- and it will be included in the announce message.
+ *Yuki Nishijima*
- *Dylan Thacker-Smith*
+* Fix a regression causing `after_create` callbacks to run before associated
+ records are autosaved.
-* `change_table` now uses the current adapter's `update_table_definition`
- method to retrieve a specific table definition.
- This ensures that `change_table` and `create_table` will use
- similar objects.
+ Fixes #17209.
- Fixes #13577 and #13503.
+ *Agis Anastasopoulos*
- *Nishant Modak*, *Prathamesh Sonpatki*, *Rafael Mendonça França*
+* Honor overridden `rack.test` in Rack environment for the connection
+ management middleware.
-* Fixed ActiveRecord::Store nil conversion TypeError when using YAML coder.
- In case the YAML passed as paramter is nil, uses an empty string.
+ *Simon Eskildsen*
- Fixes #13570.
+* Add a truncate method to the connection.
- *Thales Oliveira*
+ *Aaron Patterson*
-* Deprecate unused `ActiveRecord::Base.symbolized_base_class`
- and `ActiveRecord::Base.symbolized_sti_name` without replacement.
+* Don't autosave unchanged has_one through records.
- *Yves Senn*
+ *Alan Kennedy*, *Steve Parrington*
-* Since the `test_help.rb` file in Railties now automatically maintains
- your test schema, the `rake db:test:*` tasks are deprecated. This
- doesn't stop you manually running other tasks on your test database
- if needed:
+* Do not dump foreign keys for ignored tables.
- rake db:schema:load RAILS_ENV=test
+ *Yves Senn*
- *Jon Leighton*
+* PostgreSQL adapter correctly dumps foreign keys targeting tables
+ outside the schema search path.
-* Fix presence validator for association when the associated record responds to `to_a`.
+ Fixes #16907.
- *gmarik*
+ *Matthew Draper*, *Yves Senn*
-* Fixed regression on preload/includes with multiple arguments failing in certain conditions,
- raising a NoMethodError internally by calling `reflect_on_association` for `NilClass:Class`.
+* When a thread is killed, rollback the active transaction, instead of
+ committing it during the stack unwind. Previously, we could commit half-
+ completed work. This fix only works for Ruby 2.0+; on 1.9, we can't
+ distinguish a thread kill from an ordinary non-local (block) return, so must
+ default to committing.
- Fixes #13437.
+ *Chris Hanks*
- *Vipul A M*, *khustochka*
+* A `NullRelation` should represent nothing. This fixes a bug where
+ `Comment.where(post_id: Post.none)` returned a non-empty result.
-* Add the ability to nullify the `enum` column.
+ Fixes #15176.
- Example:
+ *Matthew Draper*, *Yves Senn*
- class Conversation < ActiveRecord::Base
- enum gender: [:female, :male]
- end
+* Include default column limits in schema.rb. Allows defaults to be changed
+ in the future without affecting old migrations that assumed old defaults.
- Conversation::GENDER # => { female: 0, male: 1 }
+ *Jeremy Kemper*
- # conversation.update! gender: 0
- conversation.female!
- conversation.female? # => true
- conversation.gender # => "female"
+* MySQL: schema.rb now includes TEXT and BLOB column limits.
- # conversation.update! gender: nil
- conversation.gender = nil
- conversation.gender.nil? # => true
- conversation.gender # => nil
+ *Jeremy Kemper*
- *Amr Tamimi*
+* MySQL: correct LONGTEXT and LONGBLOB limits from 2GB to their true 4GB.
-* Connection specification now accepts a "url" key. The value of this
- key is expected to contain a database URL. The database URL will be
- expanded into a hash and merged.
+ *Jeremy Kemper*
- *Richard Schneeman*
+* SQLite3Adapter now checks for views in `table_exists?`. Fixes #14041.
-* An `ArgumentError` is now raised on a call to `Relation#where.not(nil)`.
+ *Girish Sonawane*
- Example:
+* Introduce `connection.supports_views?` to check whether the current adapter
+ has support for SQL views. Connection adapters should define this method.
- User.where.not(nil)
+ *Yves Senn*
- # Before
- # => 'SELECT `users`.* FROM `users` WHERE (NOT (NULL))'
+* Allow included modules to override association methods.
- # After
- # => ArgumentError, 'Invalid argument for .where.not(), got nil.'
+ Fixes #16684.
- *Kuldeep Aggarwal*
+ *Yves Senn*
-* Deprecated use of string argument as a configuration lookup in
- `ActiveRecord::Base.establish_connection`. Instead, a symbol must be given.
+* Schema loading rake tasks (like `db:schema:load` and `db:setup`) maintain
+ the database connection to the current environment.
- *José Valim*
+ Fixes #16757.
-* Fixed `update_column`, `update_columns`, and `update_all` to correctly serialize
- values for `array`, `hstore` and `json` column types in PostgreSQL.
+ *Joshua Cody*, *Yves Senn*
- Fixes #12261.
+* MySQL: set the connection collation along with the charset.
- *Tadas Tamosauskas*, *Carlos Antonio da Silva*
+ Sets the connection collation to the database collation configured in
+ database.yml. Otherwise, `SET NAMES utf8mb4` will use the default
+ collation for that charset (utf8mb4_general_ci) when you may have chosen
+ a different collation, like utf8mb4_unicode_ci.
-* Do not consider PostgreSQL array columns as number or text columns.
+ This only applies to literal string comparisons, not column values, so it
+ is unlikely to affect you.
- The code uses these checks in several places to know what to do with a
- particular column, for instance AR attribute query methods has a branch
- like this:
+ *Jeremy Kemper*
- if column.number?
- !value.zero?
- end
+* `default_sequence_name` from the PostgreSQL adapter returns a `String`.
- This should never be true for array columns, since it would be the same
- as running [].zero?, which results in a NoMethodError exception.
+ *Yves Senn*
- Fixing this by ensuring that array columns in PostgreSQL never return
- true for number?/text? checks.
+* Fix a regression where whitespaces were stripped from DISTINCT queries in
+ PostgreSQL.
- *Carlos Antonio da Silva*
+ *Agis Anastasopoulos*
-* When connecting to a non-existant database, the error:
- `ActiveRecord::NoDatabaseError` will now be raised. When being used with Rails
- the error message will include information on how to create a database:
- `rake db:create`. Supported adapters: postgresql, mysql, mysql2, sqlite3
+ Fixes #16623.
- *Richard Schneeman*
+* Fix has_many :through relation merging failing when dynamic conditions are
+ passed as a lambda with an arity of one.
-* Do not raise `'cannot touch on a new record object'` exception on destroying
- already destroyed `belongs_to` association with `touch: true` option.
+ Fixes #16128.
- Fixes #13445.
+ *Agis Anastasopoulos*
- Example:
+* Fix `Relation#exists?` to work with polymorphic associations.
- # Given Comment has belongs_to :post, touch: true
- comment.post.destroy
- comment.destroy # no longer raises an error
+ Fixes #15821.
- *Paul Nikitochkin*
+ *Kassio Borges*
-* Fix a bug when assigning an array containing string numbers to a
- PostgreSQL integer array column.
+* Currently, Active Record rescues any errors raised within
+ `after_rollback`/`after_create` callbacks and prints them to the logs.
+ Future versions of Rails will not rescue these errors anymore and
+ just bubble them up like the other callbacks.
- Fixes #13444.
+ This commit adds an opt-in flag to enable not rescuing the errors.
Example:
- # Given Book#ratings is of type :integer, array: true
- Book.new(ratings: [1, 2]) # worked before
- Book.new(ratings: ['1', '2']) # now works as well
-
- *Damien Mathieu*
+ # Do not swallow errors in after_commit/after_rollback callbacks.
+ config.active_record.raise_in_transactional_callbacks = true
-* Improve the default select when `from` is used.
+ Fixes #13460.
- Previously, if you did something like Topic.from(:temp_topics), it
- would generate SQL like:
+ *arthurnn*
- SELECT topics.* FROM temp_topics;
+* Fix an issue where custom accessor methods (such as those generated by
+ `enum`) with the same name as a global method are incorrectly overridden
+ when subclassing.
- Which is will cause an error since there's not a topics table to select
- from.
+ Fixes #16288.
- Now the default if you use from is just `*`:
+ *Godfrey Chan*
- SELECT * FROM temp_topics;
+* `*_was` and `changes` now work correctly for in-place attribute changes as
+ well.
- *Cody Cutrer*
+ *Sean Griffin*
-* Fix `PostgreSQL` insert to properly extract table name from multiline string SQL.
+* Fix regression on `after_commit` that did not fire with nested transactions.
- Previously, executing an insert SQL in `PostgreSQL` with a command like this:
+ Fixes #16425.
- insert into articles(
- number)
- values(
- 5152
- )
+ *arthurnn*
- would not work because the adapter was unable to extract the correct `articles`
- table name.
+* Do not try to write timestamps when a table has no timestamps columns.
- *Kuldeep Aggarwal*
+ Fixes #8813.
-* `Relation` no longer has mutator methods like `#map!` and `#delete_if`. Convert
- to an `Array` by calling `#to_a` before using these methods.
+ *Sergey Potapov*
- It intends to prevent odd bugs and confusion in code that call mutator
- methods directly on the `Relation`.
+* `index_exists?` with `:name` option does verify specified columns.
Example:
- # Instead of this
- Author.where(name: 'Hank Moody').compact!
-
- # Now you have to do this
- authors = Author.where(name: 'Hank Moody').to_a
- authors.compact!
-
- *Lauro Caetano*
-
-* Better support for `where()` conditions that use a `belongs_to`
- association name.
-
- Using the name of an association in `where` previously worked only
- if the value was a single `ActiveRecord::Base` object. e.g.
-
- Post.where(author: Author.first)
-
- Any other values, including `nil`, would cause invalid SQL to be
- generated. This change supports arguments in the `where` query
- conditions where the key is a `belongs_to` association name and the
- value is `nil`, an `Array` of `ActiveRecord::Base` objects, or an
- `ActiveRecord::Relation` object.
-
- class Post < ActiveRecord::Base
- belongs_to :author
- end
-
- `nil` value finds records where the association is not set:
+ add_index :articles, :title, name: "idx_title"
- Post.where(author: nil)
- # SELECT "posts".* FROM "posts" WHERE "posts"."author_id" IS NULL
-
- `Array` values find records where the association foreign key
- matches the ids of the passed ActiveRecord models, resulting
- in the same query as `Post.where(author_id: [1,2])`:
-
- authors_array = [Author.find(1), Author.find(2)]
- Post.where(author: authors_array)
- # SELECT "posts".* FROM "posts" WHERE "posts"."author_id" IN (1, 2)
-
- `ActiveRecord::Relation` values find records using the same
- query as `Post.where(author_id: Author.where(last_name: "Emde"))`
-
- Post.where(author: Author.where(last_name: "Emde"))
- # SELECT "posts".* FROM "posts"
- # WHERE "posts"."author_id" IN (
- # SELECT "authors"."id" FROM "authors"
- # WHERE "authors"."last_name" = 'Emde')
-
- Polymorphic `belongs_to` associations will continue to be handled
- appropriately, with the polymorphic `association_type` field added
- to the query to match the base class of the value. This feature
- previously only worked when the value was a single `ActveRecord::Base`.
+ # Before:
+ index_exists? :articles, :title, name: "idx_title" # => `true`
+ index_exists? :articles, :body, name: "idx_title" # => `true`
- class Post < ActiveRecord::Base
- belongs_to :author, polymorphic: true
- end
+ # After:
+ index_exists? :articles, :title, name: "idx_title" # => `true`
+ index_exists? :articles, :body, name: "idx_title" # => `false`
- Post.where(author: Author.where(last_name: "Emde"))
- # Generates a query similar to:
- Post.where(author_id: Author.where(last_name: "Emde"), author_type: "Author")
+ *Yves Senn*, *Matthew Draper*
- *Martin Emde*
+* When calling `update_columns` on a record that is not persisted, the error
+ message now reflects whether that object is a new record or has been
+ destroyed.
-* Respect temporary option when dropping tables with MySQL.
+ *Lachlan Sylvester*
- Normal DROP TABLE also works, but commits the transaction.
+* Define `id_was` to get the previous value of the primary key.
- drop_table :temporary_table, temporary: true
+ Currently when we call `id_was` and we have a custom primary key name,
+ Active Record will return the current value of the primary key. This
+ makes it impossible to correctly do an update operation if you change the
+ id.
- *Cody Cutrer*
+ Fixes #16413.
-* Add option to create tables from a query.
+ *Rafael Mendonça França*
- create_table(:long_query, temporary: true,
- as: "SELECT * FROM orders INNER JOIN line_items ON order_id=orders.id")
+* Deprecate `DatabaseTasks.load_schema` to act on the current connection.
+ Use `.load_schema_current` instead. In the future `load_schema` will
+ require the `configuration` to act on as an argument.
- Generates:
+ *Yves Senn*
- CREATE TEMPORARY TABLE long_query AS
- SELECT * FROM orders INNER JOIN line_items ON order_id=orders.id
+* Fix automatic maintaining test schema to properly handle sql structure
+ schema format.
- *Cody Cutrer*
+ Fixes #15394.
-* `db:test:clone` and `db:test:prepare` must load Rails environment.
+ *Wojciech Wnętrzak*
- `db:test:clone` and `db:test:prepare` use `ActiveRecord::Base`. configurations,
- so we need to load the Rails environment, otherwise the config wont be in place.
+* Fix type casting to Decimal from Float with large precision.
- *arthurnn*
+ *Tomohiro Hashidate*
-* Use the right column to type cast grouped calculations with custom expressions.
+* Deprecate `Reflection#source_macro`
- Fixes #13230.
+ `Reflection#source_macro` is no longer needed in Active Record
+ source so it has been deprecated. Code that used `source_macro`
+ was removed in #16353.
- Example:
+ *Eileen M. Uchtitelle*, *Aaron Patterson*
- # Before
- Account.group(:firm_name).sum('0.01 * credit_limit')
- # => { '37signals' => '0.5' }
+* No verbose backtrace by `db:drop` when database does not exist.
- # After
- Account.group(:firm_name).sum('0.01 * credit_limit')
- # => { '37signals' => 0.5 }
+ Fixes #16295.
- *Paul Nikitochkin*
+ *Kenn Ejima*
-* Polymorphic `belongs_to` associations with the `touch: true` option set update the timestamps of
- the old and new owner correctly when moved between owners of different types.
+* Add support for PostgreSQL JSONB.
Example:
- class Rating < ActiveRecord::Base
- belongs_to :rateable, polymorphic: true, touch: true
+ create_table :posts do |t|
+ t.jsonb :meta_data
end
- rating = Rating.create rateable: Song.find(1)
- rating.update_attributes rateable: Book.find(2) # => timestamps of Song(1) and Book(2) are updated
-
- *Severin Schoepke*
-
-* Improve formatting of migration exception messages: make them easier to read
- with line breaks before/after, and improve the error for pending migrations.
-
- *John Bachir*
+ *Philippe Creux*, *Chris Teague*
-* Fix `last` with `offset` to return the proper record instead of always the last one.
+* `db:purge` with MySQL respects `Rails.env`.
- Example:
+ *Yves Senn*
- Model.offset(4).last
- # => returns the 4th record from the end.
+* `change_column_default :table, :column, nil` with PostgreSQL will issue a
+ `DROP DEFAULT` instead of a `DEFAULT NULL` query.
- Fixes #7441.
+ Fixes #16261.
- *kostya*, *Lauro Caetano*
+ *Matthew Draper*, *Yves Senn*
-* `type_to_sql` returns a `String` for unmapped columns. This fixes an error
- when using unmapped PostgreSQL array types.
+* Allow to specify a type for the foreign key column in `references`
+ and `add_reference`.
Example:
- change_colum :table, :column, :bigint, array: true
-
- Fixes #13146.
-
- *Jens Fahnenbruck*, *Yves Senn*
-
-* Fix `QueryCache` to work with nested blocks, so that it will only clear the existing cache
- after leaving the outer block instead of clearing it right after the inner block is finished.
-
- *Vipul A M*
-
-* The ERB in fixture files is no longer evaluated in the context of the main
- object. Helper methods used by multiple fixtures should be defined on the
- class object returned by `ActiveRecord::FixtureSet.context_class`.
-
- *Victor Costan*
-
-* Previously, the `has_one` macro incorrectly accepted the `counter_cache`
- option, but never actually supported it. Now it will raise an `ArgumentError`
- when using `has_one` with `counter_cache`.
-
- *Godfrey Chan*
-
-* Implement `rename_index` natively for MySQL >= 5.7.
-
- *Cody Cutrer*
-
-* Fix bug when validating the uniqueness of an aliased attribute.
-
- Fixes #12402.
-
- *Lauro Caetano*
-
-* Update counter cache on a `has_many` relationship regardless of default scope.
-
- Fixes #12952.
-
- *Uku Taht*
-
-* `rename_index` adds the new index before removing the old one. This allows to
- rename indexes on columns with a foreign key and prevents the following error:
-
- Cannot drop index 'index_engines_on_car_id': needed in a foreign key constraint
-
- *Cody Cutrer*, *Yves Senn*
-
-* Raise `ActiveRecord::RecordNotDestroyed` when a replaced child
- marked with `dependent: destroy` fails to be destroyed.
-
- Fixex #12812.
+ change_table :vehicle do |t|
+ t.references :station, type: :uuid
+ end
- *Brian Thomas Storti*
+ *Andrey Novikov*, *Łukasz Sarnacki*
-* Fix validation on uniqueness of empty association.
+* `create_join_table` removes a common prefix when generating the join table.
+ This matches the existing behavior of HABTM associations.
- *Evgeny Li*
+ Fixes #13683.
-* Make `ActiveRecord::Relation#unscope` affect relations it is merged in to.
+ *Stefan Kanev*
- *Jon Leighton*
+* Do not swallow errors on `compute_type` when having a bad `alias_method` on
+ a class.
-* Use strings to represent non-string `order_values`.
+ *arthurnn*
- *Yves Senn*
+* PostgreSQL invalid `uuid` are convert to nil.
-* Checks to see if the record contains the foreign key to set the inverse automatically.
+ *Abdelkader Boudih*
- *Edo Balvers*
+* Restore 4.0 behavior for using serialize attributes with `JSON` as coder.
-* Added `ActiveRecord::Base.to_param` for convenient "pretty" URLs derived from a model's attribute or method.
+ With 4.1.x, `serialize` started returning a string when `JSON` was passed as
+ the second attribute. It will now return a hash as per previous versions.
Example:
- class User < ActiveRecord::Base
- to_param :name
+ class Post < ActiveRecord::Base
+ serialize :comment, JSON
end
- user = User.find_by(name: 'Fancy Pants')
- user.id # => 123
- user.to_param # => "123-fancy-pants"
-
- *Javan Makhmali*
-
-* Added `ActiveRecord::Base.no_touching`, which allows ignoring touch on models.
-
- Example:
-
- Post.no_touching do
- Post.first.touch
+ class Comment
+ include ActiveModel::Model
+ attr_accessor :category, :text
end
- *Sam Stephenson*, *Damien Mathieu*
+ post = Post.create!
+ post.comment = Comment.new(category: "Animals", text: "This is a comment about squirrels.")
+ post.save!
-* Prevent the counter cache from being decremented twice when destroying
- a record on a `has_many :through` association.
+ # 4.0
+ post.comment # => {"category"=>"Animals", "text"=>"This is a comment about squirrels."}
- Fixes #11079.
+ # 4.1 before
+ post.comment # => "#<Comment:0x007f80ab48ff98>"
- *Dmitry Dedov*
+ # 4.1 after
+ post.comment # => {"category"=>"Animals", "text"=>"This is a comment about squirrels."}
-* Unify boolean type casting for `MysqlAdapter` and `Mysql2Adapter`.
- `type_cast` will return `1` for `true` and `0` for `false`.
+ When using `JSON` as the coder in `serialize`, Active Record will use the
+ new `ActiveRecord::Coders::JSON` coder which delegates its `dump/load` to
+ `ActiveSupport::JSON.encode/decode`. This ensures special objects are dumped
+ correctly using the `#as_json` hook.
- Fixes #11119.
+ To keep the previous behaviour, supply a custom coder instead
+ ([example](https://gist.github.com/jenncoop/8c4142bbe59da77daa63)).
- *Adam Williams*, *Yves Senn*
+ Fixes #15594.
-* Fix bug where `has_one` association record update result in crash, when replaced with itself.
+ *Jenn Cooper*
- Fixes #12834.
+* Do not use `RENAME INDEX` syntax for MariaDB 10.0.
- *Denis Redozubov*, *Sergio Cambra*
+ Fixes #15931.
-* Log bind variables after they are type casted. This makes it more
- transparent what values are actually sent to the database.
+ *Jeff Browning*
- irb(main):002:0> Event.find("im-no-integer")
- # Before: ... WHERE "events"."id" = $1 LIMIT 1 [["id", "im-no-integer"]]
- # After: ... WHERE "events"."id" = $1 LIMIT 1 [["id", 0]]
+* Calling `#empty?` on a `has_many` association would use the value from the
+ counter cache if one exists.
- *Yves Senn*
+ *David Verhasselt*
-* Fix uninitialized constant `TransactionState` error when `Marshall.load` is used on an Active Record result.
+* Fix the schema dump generated for tables without constraints and with
+ primary key with default value of custom PostgreSQL function result.
- Fixes #12790.
+ Fixes #16111.
- *Jason Ayre*
+ *Andrey Novikov*
-* `.unscope` now removes conditions specified in `default_scope`.
+* Fix the SQL generated when a `delete_all` is run on an association to not
+ produce an `IN` statements.
- *Jon Leighton*
+ Before:
-* Added `ActiveRecord::QueryMethods#rewhere` which will overwrite an existing, named where condition.
+ UPDATE "categorizations" SET "category_id" = NULL WHERE
+ "categorizations"."category_id" = 1 AND "categorizations"."id" IN (1, 2)
- Examples:
+ After:
- 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
+ UPDATE "categorizations" SET "category_id" = NULL WHERE
+ "categorizations"."category_id" = 1
- *DHH*
+ *Eileen M. Uchitelle, Aaron Patterson*
-* Extend `ActiveRecord::Base#cache_key` to take an optional list of timestamp attributes of which the highest will be used.
+* Avoid type casting boolean and `ActiveSupport::Duration` values to numeric
+ values for string columns. Otherwise, in some database, the string column
+ values will be coerced to a numeric allowing false or 0.seconds match any
+ string starting with a non-digit.
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)
+ App.where(apikey: false) # => SELECT * FROM users WHERE apikey = '0'
- *DHH*
+ *Dylan Thacker-Smith*
-* Added `ActiveRecord::Base#enum` for declaring enum attributes where the values map to integers in the database, but can be queried by name.
+* Add a `:required` option to singular associations, providing a nicer
+ API for presence validations on associations.
- Example:
+ *Sean Griffin*
- class Conversation < ActiveRecord::Base
- enum status: [:active, :archived]
- end
+* Fix an error in `reset_counters` when associations have `select` scope.
+ (Call to `count` generated invalid SQL.)
- Conversation::STATUS # => { active: 0, archived: 1 }
+ *Cade Truitt*
- # conversation.update! status: 0
- conversation.active!
- conversation.active? # => true
- conversation.status # => "active"
+* After a successful `reload`, `new_record?` is always false.
- # conversation.update! status: 1
- conversation.archived!
- conversation.archived? # => true
- conversation.status # => "archived"
+ Fixes #12101.
- # conversation.update! status: 1
- conversation.status = :archived
+ *Matthew Draper*
- *DHH*
+* PostgreSQL renaming table doesn't attempt to rename non existent sequences.
-* `ActiveRecord::Base#attribute_for_inspect` now truncates long arrays (more than 10 elements).
+ *Abdelkader Boudih*
- *Jan Bernacki*
+* Move 'dependent: :destroy' handling for `belongs_to`
+ from `before_destroy` to `after_destroy` callback chain
-* Allow for the name of the `schema_migrations` table to be configured.
+ Fixes #12380.
- *Jerad Phelps*
+ *Ivan Antropov*
-* Do not add to scope includes values from through associations.
- Fixed bug when providing `includes` in through association scope, and fetching targets.
+* Detect in-place modifications on String attributes.
- Example:
+ Before this change, an attribute modified in-place had to be marked as
+ changed in order for it to be persisted in the database. Now it is no longer
+ required.
- class Vendor < ActiveRecord::Base
- has_many :relationships, -> { includes(:user) }
- has_many :users, through: :relationships
- end
+ Before:
- vendor = Vendor.first
+ user = User.first
+ user.name << ' Griffin'
+ user.name_will_change!
+ user.save
+ user.reload.name # => "Sean Griffin"
- # Before
+ After:
- vendor.users.to_a # => Raises exception: not found `:user` for `User`
+ user = User.first
+ user.name << ' Griffin'
+ user.save
+ user.reload.name # => "Sean Griffin"
- # After
+ *Sean Griffin*
- vendor.users.to_a # => No exception is raised
+* Add `ActiveRecord::Base#validate!` that raises `RecordInvalid` if the record
+ is invalid.
- Fixes #12242, #9517, #10240.
+ *Bogdan Gusiev*, *Marc Schütz*
- *Paul Nikitochkin*
+* Support for adding and removing foreign keys. Foreign keys are now
+ a part of `schema.rb`. This is supported by Mysql2Adapter, MysqlAdapter
+ and PostgreSQLAdapter.
-* Type cast json values on write, so that the value is consistent
- with reading from the database.
+ Many thanks to *Matthew Higgins* for laying the foundation with his work on
+ [foreigner](https://github.com/matthuhiggins/foreigner).
Example:
- x = JsonDataType.new tags: {"string" => "foo", :symbol => :bar}
+ # within your migrations:
+ add_foreign_key :articles, :authors
+ remove_foreign_key :articles, :authors
- # Before:
- x.tags # => {"string" => "foo", :symbol => :bar}
+ *Yves Senn*
- # After:
- x.tags # => {"string" => "foo", "symbol" => "bar"}
+* Fix subtle bugs regarding attribute assignment on models with no primary
+ key. `'id'` will no longer be part of the attributes hash.
- *Severin Schoepke*
+ *Sean Griffin*
-* `ActiveRecord::Store` works together with PG `hstore` columns.
+* Deprecate automatic counter caches on `has_many :through`. The behavior was
+ broken and inconsistent.
- Fixes #12452.
+ *Sean Griffin*
- *Yves Senn*
+* `preload` preserves readonly flag for associations.
-* 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`.
+ See #15853.
*Yves Senn*
-* Save `has_one` association when primary key is manually set.
+* Assume numeric types have changed if they were assigned to a value that
+ would fail numericality validation, regardless of the old value. Previously
+ this would only occur if the old value was 0.
- Fixes #12302.
+ Example:
- *Lauro Caetano*
+ model = Model.create!(number: 5)
+ model.number = '5wibble'
+ model.number_changed? # => true
-* Allow any version of BCrypt when using `has_secure_password`.
+ Fixes #14731.
- *Mike Perham*
+ *Sean Griffin*
-* Sub-query generated for `Relation` passed as array condition did not take in account
- bind values and have invalid syntax.
+* `reload` no longer merges with the existing attributes.
+ The attribute hash is fully replaced. The record is put into the same state
+ as it would be with `Model.find(model.id)`.
- Generate sub-query with inline bind values.
+ *Sean Griffin*
- Fixes #12586.
+* The object returned from `select_all` must respond to `column_types`.
+ If this is not the case a `NoMethodError` is raised.
- *Paul Nikitochkin*
+ *Sean Griffin*
-* Fix a bug where rake db:structure:load crashed when the path contained
- spaces.
+* Detect in-place modifications of PG array types
- *Kevin Mook*
+ *Sean Griffin*
-* `ActiveRecord::QueryMethods#unscope` unscopes negative equality
+* Add `bin/rake db:purge` task to empty the current database.
- 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`.
+ *Yves Senn*
- *Eric Hankins*
+* Deprecate `serialized_attributes` without replacement.
-* Raise an exception when model without primary key calls `.find_with_ids`.
+ *Sean Griffin*
- *Shimpei Makimoto*
+* Correctly extract IPv6 addresses from `DATABASE_URI`: the square brackets
+ are part of the URI structure, not the actual host.
-* Make `Relation#empty?` use `exists?` instead of `count`.
+ Fixes #15705.
- *Szymon Nowak*
+ *Andy Bakun*, *Aaron Stone*
-* `rake db:structure:dump` no longer crashes when the port was specified as `Fixnum`.
+* Ensure both parent IDs are set on join records when both sides of a
+ through association are new.
- *Kenta Okamoto*
+ *Sean Griffin*
-* `NullRelation#pluck` takes a list of columns
+* `ActiveRecord::Dirty` now detects in-place changes to mutable values.
+ Serialized attributes on ActiveRecord models will no longer save when
+ unchanged.
- The method signature in `NullRelation` was updated to mimic that in
- `Calculations`.
+ Fixes #8328.
- *Derek Prior*
+ *Sean Griffin*
-* `scope_chain` should not be mutated for other reflections.
+* `Pluck` now works when selecting columns from different tables with the same
+ name.
- Currently `scope_chain` uses same array for building different
- `scope_chain` for different associations. During processing
- these arrays are sometimes mutated and because of in-place
- mutation the changed `scope_chain` impacts other reflections.
+ Fixes #15649.
- Fix is to dup the value before adding to the `scope_chain`.
+ *Sean Griffin*
- Fixes #3882.
+* Remove `cache_attributes` and friends. All attributes are cached.
- *Neeraj Singh*
+ *Sean Griffin*
-* Prevent the inversed association from being reloaded on save.
+* Remove deprecated method `ActiveRecord::Base.quoted_locking_column`.
- Fixes #9499.
+ *Akshay Vishnoi*
- *Dmitry Polushkin*
+* `ActiveRecord::FinderMethods.find` with block can handle proc parameter as
+ `Enumerable#find` does.
-* Generate subquery for `Relation` if it passed as array condition for `where`
- method.
+ Fixes #15382.
- Example:
+ *James Yang*
- # Before
- Blog.where('id in (?)', Blog.where(id: 1))
- # => SELECT "blogs".* FROM "blogs" WHERE "blogs"."id" = 1
- # => SELECT "blogs".* FROM "blogs" WHERE (id IN (1))
+* Make timezone aware attributes work with PostgreSQL array columns.
- # After
- Blog.where('id in (?)', Blog.where(id: 1).select(:id))
- # => SELECT "blogs".* FROM "blogs"
- # WHERE "blogs"."id" IN (SELECT "blogs"."id" FROM "blogs" WHERE "blogs"."id" = 1)
+ Fixes #13402.
- Fixes #12415.
+ *Kuldeep Aggarwal*, *Sean Griffin*
- *Paul Nikitochkin*
+* `ActiveRecord::SchemaMigration` has no primary key regardless of the
+ `primary_key_prefix_type` configuration.
-* For missed association exception message
- which is raised in `ActiveRecord::Associations::Preloader` class
- added owner record class name in order to simplify to find problem code.
+ Fixes #15051.
- *Paul Nikitochkin*
+ *JoseLuis Torres*, *Yves Senn*
-* `has_and_belongs_to_many` is now transparently implemented in terms of
- `has_many :through`. Behavior should remain the same, if not, it is a bug.
+* `rake db:migrate:status` works with legacy migration numbers like `00018_xyz.rb`.
-* `create_savepoint`, `rollback_to_savepoint` and `release_savepoint` accept
- a savepoint name.
+ Fixes #15538.
*Yves Senn*
-* Make `next_migration_number` accessible for third party generators.
+* Baseclass becomes! subclass.
- *Yves Senn*
+ Before this change, a record which changed its STI type, could not be
+ updated.
-* Objects instantiated using a null relationship will now retain the
- attributes of the where clause.
+ Fixes #14785.
- Fixes #11676, #11675, #11376.
+ *Matthew Draper*, *Earl St Sauver*, *Edo Balvers*
- *Paul Nikitochkin*, *Peter Brown*, *Nthalk*
+* Remove deprecated `ActiveRecord::Migrator.proper_table_name`. Use the
+ `proper_table_name` instance method on `ActiveRecord::Migration` instead.
-* Fixed `ActiveRecord::Associations::CollectionAssociation#find`
- when using `has_many` association with `:inverse_of` and finding an array of one element,
- it should return an array of one element too.
+ *Akshay Vishnoi*
- *arthurnn*
+* Fix regression on eager loading association based on SQL query rather than
+ existing column.
-* Callbacks on has_many should access the in memory parent if a inverse_of is set.
+ Fixes #15480.
- *arthurnn*
+ *Lauro Caetano*, *Carlos Antonio da Silva*
-* `ActiveRecord::ConnectionAdapters.string_to_time` respects
- string with timezone (e.g. Wed, 04 Sep 2013 20:30:00 JST).
+* Deprecate returning `nil` from `column_for_attribute` when no column exists.
+ It will return a null object in Rails 5.0
- Fixes #12278.
+ *Sean Griffin*
- *kennyj*
+* Implemented `ActiveRecord::Base#pretty_print` to work with PP.
-* Calling `update_attributes` will now throw an `ArgumentError` whenever it
- gets a `nil` argument. More specifically, it will throw an error if the
- argument that it gets passed does not respond to to `stringify_keys`.
+ *Ethan*
- Example:
+* Preserve type when dumping PostgreSQL point, bit, bit varying and money
+ columns.
- @my_comment.update_attributes(nil) # => raises ArgumentError
+ *Yves Senn*
- *John Wang*
+* New records remain new after YAML serialization.
-* Deprecate `quoted_locking_column` method, which isn't used anywhere.
+ *Sean Griffin*
- *kennyj*
+* PostgreSQL support default values for enum types. Fixes #7814.
-* Migration dump UUID default functions to schema.rb.
+ *Yves Senn*
- Fixes #10751.
+* PostgreSQL `default_sequence_name` respects schema. Fixes #7516.
- *kennyj*
+ *Yves Senn*
-* Fixed a bug in `ActiveRecord::Associations::CollectionAssociation#find_by_scan`
- when using `has_many` association with `:inverse_of` option and UUID primary key.
+* Fix `columns_for_distinct` of PostgreSQL adapter to work correctly
+ with orders without sort direction modifiers.
- Fixes #10450.
+ *Nikolay Kondratyev*
- *kennyj*
+* PostgreSQL `reset_pk_sequence!` respects schemas. Fixes #14719.
-* 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.
+ *Yves Senn*
- Fixes #11963.
+* Keep PostgreSQL `hstore` and `json` attributes as `Hash` in `@attributes`.
+ Fixes duplication in combination with `store_accessor`.
- *Paul Nikitochkin*
+ Fixes #15369.
-* `CollectionAssociation#first`/`#last` (e.g. `has_many`) use a `LIMIT`ed
- query to fetch results rather than loading the entire collection.
+ *Yves Senn*
- *Lann Martin*
+* `rake railties:install:migrations` respects the order of railties.
-* Make possible to run SQLite rake tasks without the `Rails` constant defined.
+ *Arun Agrawal*
- *Damien Mathieu*
+* Fix redefine a `has_and_belongs_to_many` inside inherited class
+ Fixing regression case, where redefining the same `has_and_belongs_to_many`
+ definition into a subclass would raise.
-* Allow Relation#from to accept other relations with bind values.
+ Fixes #14983.
- *Ryan Wallace*
+ *arthurnn*
-* Fix inserts with prepared statements disabled.
+* Fix `has_and_belongs_to_many` public reflection.
+ When defining a `has_and_belongs_to_many`, internally we convert that to two has_many.
+ But as `reflections` is a public API, people expect to see the right macro.
- Fixes #12023.
+ Fixes #14682.
- *Rafael Mendonça França*
+ *arthurnn*
-* Setting a has_one association on a new record no longer causes an empty
- transaction.
+* Fix serialization for records with an attribute named `format`.
- *Dylan Thacker-Smith*
+ Fixes #15188.
-* Fix `AR::Relation#merge` sometimes failing to preserve `readonly(false)` flag.
+ *Godfrey Chan*
- *thedarkone*
+* When a `group` is set, `sum`, `size`, `average`, `minimum` and `maximum`
+ on a NullRelation should return a Hash.
-* Re-use `order` argument pre-processing for `reorder`.
+ *Kuldeep Aggarwal*
- *Paul Nikitochkin*
+* Fix serialized fields returning serialized data after being updated with
+ `update_column`.
-* Fix PredicateBuilder so polymorphic association keys in `where` clause can
- accept objects other than direct descendants of `ActiveRecord::Base` (decorated
- models, for example).
+ *Simon Hørup Eskildsen*
- *Mikhail Dieterle*
+* Fix polymorphic eager loading when using a String as foreign key.
-* PostgreSQL adapter recognizes negative money values formatted with
- parentheses (eg. `($1.25) # => -1.25`)).
- Fixes #11899.
+ Fixes #14734.
- *Yves Senn*
+ *Lauro Caetano*
-* Stop interpreting SQL 'string' columns as :string type because there is no
- common STRING datatype in SQL.
+* Change belongs_to touch to be consistent with timestamp updates
- *Ben Woosley*
+ If a model is set up with a belongs_to: touch relationship the parent
+ record will only be touched if the record was modified. This makes it
+ consistent with timestamp updating on the record itself.
-* `ActiveRecord::FinderMethods#exists?` returns `true`/`false` in all cases.
+ *Brock Trappitt*
- *Xavier Noria*
+* Fix the inferred table name of a `has_and_belongs_to_many` auxiliary
+ table inside a schema.
-* Assign inet/cidr attribute with `nil` value for invalid address.
+ Fixes #14824.
- Example:
+ *Eric Chahin*
- record = User.new
- record.logged_in_from_ip # is type of an inet or a cidr
+* Remove unused `:timestamp` type. Transparently alias it to `:datetime`
+ in all cases. Fixes inconsistencies when column types are sent outside of
+ `ActiveRecord`, such as for XML Serialization.
- # Before:
- record.logged_in_from_ip = 'bad ip address' # raise exception
+ *Sean Griffin*
- # After:
- record.logged_in_from_ip = 'bad ip address' # do not raise exception
- record.logged_in_from_ip # => nil
- record.logged_in_from_ip_before_type_cast # => 'bad ip address'
+* Fix bug that added `table_name_prefix` and `table_name_suffix` to
+ extension names in PostgreSQL when migrating.
- *Paul Nikitochkin*
+ *Joao Carlos*
-* `add_to_target` now accepts a second optional `skip_callbacks` argument
+* The `:index` option in migrations, which previously was only available for
+ `references`, now works with any column types.
- If truthy, it will skip the :before_add and :after_add callbacks.
+ *Marc Schütz*
- *Ben Woosley*
+* Add support for counter name to be passed as parameter on `CounterCache::ClassMethods#reset_counters`.
-* Fix interactions between `:before_add` callbacks and nested attributes
- assignment of `has_many` associations, when the association was not
- yet loaded:
+ *jnormore*
- - A `:before_add` callback was being called when a nested attributes
- assignment assigned to an existing record.
+* Restrict deletion of record when using `delete_all` with `uniq`, `group`, `having`
+ or `offset`.
- - Nested Attributes assignment did not affect the record in the
- association target when a `:before_add` callback triggered the
- loading of the association
+ In these cases the generated query ignored them and that caused unintended
+ records to be deleted.
- *Jörg Schray*
+ Fixes #11985.
-* Allow enable_extension migration method to be revertible.
+ *Leandro Facchinetti*
- *Eric Tipton*
+* Floats with limit >= 25 that get turned into doubles in MySQL no longer have
+ their limit dropped from the schema.
-* Type cast hstore values on write, so that the value is consistent
- with reading from the database.
+ Fixes #14135.
- Example:
+ *Aaron Nelson*
- x = Hstore.new tags: {"bool" => true, "number" => 5}
+* Fix how to calculate associated class name when using namespaced `has_and_belongs_to_many`
+ association.
- # Before:
- x.tags # => {"bool" => true, "number" => 5}
+ Fixes #14709.
- # After:
- x.tags # => {"bool" => "true", "number" => "5"}
+ *Kassio Borges*
- *Yves Senn* , *Severin Schoepke*
+* `ActiveRecord::Relation::Merger#filter_binds` now compares equivalent symbols and
+ strings in column names as equal.
-* Fix multidimensional PG arrays containing non-string items.
+ This fixes a rare case in which more bind values are passed than there are
+ placeholders for them in the generated SQL statement, which can make PostgreSQL
+ throw a `StatementInvalid` exception.
- *Yves Senn*
+ *Nat Budin*
-* Fixes bug when using includes combined with select, the select statement was overwritten.
+* Fix `stored_attributes` to correctly merge the details of stored
+ attributes defined in parent classes.
- Fixes #11773.
+ Fixes #14672.
- *Edo Balvers*
+ *Brad Bennett*, *Jessica Yao*, *Lakshmi Parthasarathy*
-* Load fixtures from linked folders.
+* `change_column_default` allows `[]` as argument to `change_column_default`.
- *Kassio Borges*
+ Fixes #11586.
-* Create a directory for sqlite3 file if not present on the system.
+ *Yves Senn*
- *Richard Schneeman*
+* Handle `name` and `"char"` column types in the PostgreSQL adapter.
-* Removed redundant override of `xml` column definition for PG,
- in order to use `xml` column type instead of `text`.
+ `name` and `"char"` are special character types used internally by
+ PostgreSQL and are used by internal system catalogs. These field types
+ can sometimes show up in structure-sniffing queries that feature internal system
+ structures or with certain PostgreSQL extensions.
- *Paul Nikitochkin*, *Michael Nikitochkin*
+ *J Smith*, *Yves Senn*
-* Revert `ActiveRecord::Relation#order` change that make new order
- prepend the old one.
+* Fix `PostgreSQLAdapter::OID::Float#type_cast` to convert Infinity and
+ NaN PostgreSQL values into a native Ruby `Float::INFINITY` and `Float::NAN`
Before:
- User.order("name asc").order("created_at desc")
- # SELECT * FROM users ORDER BY created_at desc, name asc
+ Point.create(value: 1.0/0)
+ Point.last.value # => 0.0
After:
- User.order("name asc").order("created_at desc")
- # SELECT * FROM users ORDER BY name asc, created_at desc
+ Point.create(value: 1.0/0)
+ Point.last.value # => Infinity
- This also affects order defined in `default_scope` or any kind of associations.
+ *Innokenty Mikhailov*
-* Add ability to define how a class is converted to Arel predicates.
- For example, adding a very vendor specific regex implementation:
+* Allow the PostgreSQL adapter to handle bigserial primary key types again.
- regex_handler = proc do |column, value|
- Arel::Nodes::InfixOperation.new('~', column, value.source)
- end
- ActiveRecord::PredicateBuilder.register_handler(Regexp, regex_handler)
+ Fixes #10410.
- *Sean Griffin & @joannecheng*
+ *Patrick Robertson*
-* Don't allow `quote_value` to be called without a column.
+* Deprecate joining, eager loading and preloading of instance dependent
+ associations without replacement. These operations happen before instances
+ are created. The current behavior is unexpected and can result in broken
+ behavior.
- Some adapters require column information to do their job properly.
- By enforcing the provision of the column for this internal method
- we ensure that those using adapters that require column information
- will always get the proper behavior.
+ Fixes #15024.
- *Ben Woosley*
+ *Yves Senn*
-* When using optimistic locking, `update` was not passing the column to `quote_value`
- to allow the connection adapter to properly determine how to quote the value. This was
- affecting certain databases that use specific column types.
+* Fix `has_and_belongs_to_many` CollectionAssociation size calculations.
- Fixes #6763.
+ `has_and_belongs_to_many` should fall back to using the normal CollectionAssociation's
+ size calculation if the collection is not cached or loaded.
- *Alfred Wong*
+ Fixes #14913, #14914.
-* rescue from all exceptions in `ConnectionManagement#call`
+ *Fred Wu*
- Fixes #11497.
+* Return a non zero status when running `rake db:migrate:status` and migration table does
+ not exist.
- As `ActiveRecord::ConnectionAdapters::ConnectionManagement` middleware does
- not rescue from Exception (but only from StandardError), the Connection
- Pool quickly runs out of connections when multiple erroneous Requests come
- in right after each other.
+ *Paul B.*
- Rescuing from all exceptions and not just StandardError, fixes this
- behaviour.
+* Add support for module-level `table_name_suffix` in models.
- *Vipul A M*
+ This makes `table_name_suffix` work the same way as `table_name_prefix` when
+ using namespaced models.
-* `change_column` for PostgreSQL adapter respects the `:array` option.
+ *Jenner LaFave*
- *Yves Senn*
+* Revert the behaviour of `ActiveRecord::Relation#join` changed through 4.0 => 4.1 to 4.0.
-* Remove deprecation warning from `attribute_missing` for attributes that are columns.
+ In 4.1.0 `Relation#join` is delegated to `Arel#SelectManager`.
+ In 4.0 series it is delegated to `Array#join`.
- *Arun Agrawal*
+ *Bogdan Gusiev*
-* Remove extra decrement of transaction deep level.
+* Log nil binary column values correctly.
- Fixes #4566.
+ When an object with a binary column is updated with a nil value
+ in that column, the SQL logger would throw an exception when trying
+ to log that nil value. This only occurs when updating a record
+ that already has a non-nil value in that column since an initial nil
+ value isn't included in the SQL anyway (at least, when dirty checking
+ is enabled.) The column's new value will now be logged as `<NULL binary data>`
+ to parallel the existing `<N bytes of binary data>` for non-nil values.
- *Paul Nikitochkin*
+ *James Coleman*
-* Reset @column_defaults when assigning `locking_column`.
- We had a potential problem. For example:
+* Rails will now pass a custom validation context through to autosave associations
+ in order to validate child associations with the same context.
- class Post < ActiveRecord::Base
- self.column_defaults # if we call this unintentionally before setting locking_column ...
- self.locking_column = 'my_locking_column'
- end
+ Fixes #13854.
- Post.column_defaults["my_locking_column"]
- => nil # expected value is 0 !
+ *Eric Chahin*, *Aaron Nelson*, *Kevin Casey*
- *kennyj*
+* Stringify all variables keys of MySQL connection configuration.
-* Remove extra select and update queries on save/touch/destroy ActiveRecord model
- with belongs to reflection with option `touch: true`.
+ When `sql_mode` variable for MySQL adapters set in configuration as `String`
+ was ignored and overwritten by strict mode option.
- Fixes #11288.
+ Fixes #14895.
*Paul Nikitochkin*
-* Remove deprecated nil-passing to the following `SchemaCache` methods:
- `primary_keys`, `tables`, `columns` and `columns_hash`.
+* Ensure SQLite3 statements are closed on errors.
- *Yves Senn*
+ Fixes #13631.
-* Remove deprecated block filter from `ActiveRecord::Migrator#migrate`.
+ *Timur Alperovich*
- *Yves Senn*
+* Give `ActiveRecord::PredicateBuilder` private methods the privacy they deserve.
-* Remove deprecated String constructor from `ActiveRecord::Migrator`.
+ *Hector Satre*
- *Yves Senn*
+* When using a custom `join_table` name on a `habtm`, rails was not saving it
+ on Reflections. This causes a problem when rails loads fixtures, because it
+ uses the reflections to set database with fixtures.
-* Remove deprecated `scope` use without passing a callable object.
+ Fixes #14845.
- *Arun Agrawal*
+ *Kassio Borges*
-* Remove deprecated `transaction_joinable=` in favor of `begin_transaction`
- with `:joinable` option.
+* Reset the cache when modifying a Relation with cached Arel.
+ Additionally display a warning message to make the user aware.
- *Arun Agrawal*
+ *Yves Senn*
-* Remove deprecated `decrement_open_transactions`.
+* PostgreSQL should internally use `:datetime` consistently for TimeStamp. Assures
+ different spellings of timestamps are treated the same.
- *Arun Agrawal*
+ Example:
-* Remove deprecated `increment_open_transactions`.
+ mytimestamp.simplified_type('timestamp without time zone')
+ # => :datetime
+ mytimestamp.simplified_type('timestamp(6) without time zone')
+ # => also :datetime (previously would be :timestamp)
- *Arun Agrawal*
+ See #14513.
-* Remove deprecated `PostgreSQLAdapter#outside_transaction?`
- method. You can use `#transaction_open?` instead.
+ *Jefferson Lai*
- *Yves Senn*
+* `ActiveRecord::Base.no_touching` no longer triggers callbacks or start empty transactions.
-* Remove deprecated `ActiveRecord::Fixtures.find_table_name` in favor of
- `ActiveRecord::Fixtures.default_fixture_model_name`.
+ Fixes #14841.
- *Vipul A M*
+ *Lucas Mazza*
-* Removed deprecated `columns_for_remove` from `SchemaStatements`.
+* Fix name collision with `Array#select!` with `Relation#select!`.
- *Neeraj Singh*
+ Fixes #14752.
-* Remove deprecated `SchemaStatements#distinct`.
+ *Earl St Sauver*
- *Francesco Rodriguez*
+* Fix unexpected behavior for `has_many :through` associations going through
+ a scoped `has_many`.
-* Move deprecated `ActiveRecord::TestCase` into the rails test
- suite. The class is no longer public and is only used for internal
- Rails tests.
+ If a `has_many` association is adjusted using a scope, and another
+ `has_many :through` uses this association, then the scope adjustment is
+ unexpectedly neglected.
- *Yves Senn*
+ Fixes #14537.
-* Removed support for deprecated option `:restrict` for `:dependent`
- in associations.
+ *Jan Habermann*
- *Neeraj Singh*
+* `@destroyed` should always be set to `false` when an object is duped.
-* Removed support for deprecated `delete_sql` in associations.
+ *Kuldeep Aggarwal*
- *Neeraj Singh*
+* Enable `has_many` associations to support irregular inflections.
-* Removed support for deprecated `insert_sql` in associations.
+ Fixes #8928.
- *Neeraj Singh*
+ *arthurnn*, *Javier Goizueta*
-* Removed support for deprecated `finder_sql` in associations.
+* Fix `count` used with a grouping not returning a Hash.
- *Neeraj Singh*
+ Fixes #14721.
-* Support array as root element in JSON fields.
+ *Eric Chahin*
- *Alexey Noskov & Francesco Rodriguez*
+* `sanitize_sql_like` helper method to escape a string for safe use in an SQL
+ LIKE statement.
-* Removed support for deprecated `counter_sql` in associations.
+ Example:
- *Neeraj Singh*
+ class Article
+ def self.search(term)
+ where("title LIKE ?", sanitize_sql_like(term))
+ end
+ end
-* Do not invoke callbacks when `delete_all` is called on collection.
+ Article.search("20% _reduction_")
+ # => Query looks like "... title LIKE '20\% \_reduction\_' ..."
- 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 `:delete_all` deletion
- strategy for that collection will be applied.
+ *Rob Gilson*, *Yves Senn*
- User can also force a deletion strategy by passing parameter to
- `delete_all`. For example you can do `@post.comments.delete_all(:nullify)`.
+* Do not quote uuid default value on `change_column`.
- *Neeraj Singh*
+ Fixes #14604.
-* Calling default_scope without a proc will now raise `ArgumentError`.
+ *Eric Chahin*
- *Neeraj Singh*
+* The comparison between `Relation` and `CollectionProxy` should be consistent.
-* Removed deprecated method `type_cast_code` from Column.
+ Example:
- *Neeraj Singh*
+ author.posts == Post.where(author_id: author.id)
+ # => true
+ Post.where(author_id: author.id) == author.posts
+ # => true
-* Removed deprecated options `delete_sql` and `insert_sql` from HABTM
- association.
+ Fixes #13506.
- Removed deprecated options `finder_sql` and `counter_sql` from
- collection association.
+ *Lauro Caetano*
- *Neeraj Singh*
+* Calling `delete_all` on an unloaded `CollectionProxy` no longer
+ generates an SQL statement containing each id of the collection:
-* Remove deprecated `ActiveRecord::Base#connection` method.
- Make sure to access it via the class.
+ Before:
- *Yves Senn*
+ DELETE FROM `model` WHERE `model`.`parent_id` = 1
+ AND `model`.`id` IN (1, 2, 3...)
-* Remove deprecation warning for `auto_explain_threshold_in_seconds`.
+ After:
- *Yves Senn*
+ DELETE FROM `model` WHERE `model`.`parent_id` = 1
-* Remove deprecated `:distinct` option from `Relation#count`.
+ *Eileen M. Uchitelle*, *Aaron Patterson*
- *Yves Senn*
+* Fix invalid SQL when aggregate methods (`empty?`, `any?`, `count`) used
+ with `select`.
-* Removed deprecated methods `partial_updates`, `partial_updates?` and
- `partial_updates=`.
+ Fixes #13648.
- *Neeraj Singh*
+ *Simon Woker*
-* Removed deprecated method `scoped`.
+* PostgreSQL adapter only warns once for every missing OID per connection.
- *Neeraj Singh*
+ Fixes #14275.
-* Removed deprecated method `default_scopes?`.
+ *Matthew Draper*, *Yves Senn*
- *Neeraj Singh*
+* PostgreSQL adapter automatically reloads it's type map when encountering
+ unknown OIDs.
-* Remove implicit join references that were deprecated in 4.0.
+ Fixes #14678.
- Example:
+ *Matthew Draper*, *Yves Senn*
- # before with implicit joins
- Comment.where('posts.author_id' => 7)
+* Fix insertion of records via `has_many :through` association with scope.
- # after
- Comment.references(:posts).where('posts.author_id' => 7)
+ Fixes #3548.
- *Yves Senn*
+ *Ivan Antropov*
-* Apply default scope when joining associations. For example:
+* Auto-generate stable fixture UUIDs on PostgreSQL.
- class Post < ActiveRecord::Base
- default_scope -> { where published: true }
- end
+ Fixes #11524.
- class Comment
- belongs_to :post
- end
+ *Roderick van Domburg*
- When calling `Comment.joins(:post)`, we expect to receive only
- comments on published posts, since that is the default scope for
- posts.
+* Fix a problem where an enum would overwrite values of another enum with the
+ same name in an unrelated class.
- Before this change, the default scope from `Post` was not applied,
- so we'd get comments on unpublished posts.
+ Fixes #14607.
- *Jon Leighton*
+ *Evan Whalen*
-* Remove `activerecord-deprecated_finders` as a dependency.
+* PostgreSQL and SQLite string columns no longer have a default limit of 255.
- *Łukasz Strzałkowski*
+ Fixes #13435, #9153.
-* Remove Oracle / Sqlserver / Firebird database tasks that were deprecated in 4.0.
+ *Vladimir Sazhin*, *Toms Mikoss*, *Yves Senn*
- *kennyj*
+* Make possible to have an association called `records`.
-* `find_each` now returns an `Enumerator` when called without a block, so that it
- can be chained with other `Enumerable` methods.
+ Fixes #11645.
- *Ben Woosley*
+ *prathamesh-sonpatki*
-* `ActiveRecord::Result.each` now returns an `Enumerator` when called without
- a block, so that it can be chained with other `Enumerable` methods.
+* `to_sql` on an association now matches the query that is actually executed, where it
+ could previously have incorrectly accrued additional conditions (e.g. as a result of
+ a previous query). `CollectionProxy` now always defers to the association scope's
+ `arel` method so the (incorrect) inherited one should be entirely concealed.
- *Ben Woosley*
+ Fixes #14003.
+
+ *Jefferson Lai*
-* Flatten merged join_values before building the joins.
+* Block a few default Class methods as scope name.
- While joining_values special treatment is given to string values.
- By flattening the array it ensures that string values are detected
- as strings and not arrays.
+ For instance, this will raise:
- Fixes #10669.
+ scope :public, -> { where(status: 1) }
- *Neeraj Singh and iwiznia*
+ *arthurnn*
-* Do not load all child records for inverse case.
+* Fix error when using `with_options` with lambda.
- currently `post.comments.find(Comment.first.id)` would load all
- comments for the given post to set the inverse association.
+ Fixes #9805.
- This has a huge performance penalty. Because if post has 100k
- records and all these 100k records would be loaded in memory
- even though the comment id was supplied.
+ *Lauro Caetano*
- Fix is to use in-memory records only if loaded? is true. Otherwise
- load the records using full sql.
+* Switch `sqlite3:///` URLs (which were temporarily
+ deprecated in 4.1) from relative to absolute.
- Fixes #10509.
+ If you still want the previous interpretation, you should replace
+ `sqlite3:///my/path` with `sqlite3:my/path`.
- *Neeraj Singh*
+ *Matthew Draper*
-* `inspect` on Active Record model classes does not initiate a
- new connection. This means that calling `inspect`, when the
- database is missing, will no longer raise an exception.
- Fixes #10936.
+* Treat blank UUID values as `nil`.
Example:
- Author.inspect # => "Author(no database connection)"
-
- *Yves Senn*
+ Sample.new(uuid_field: '') #=> <Sample id: nil, uuid_field: nil>
-* Handle single quotes in PostgreSQL default column values.
- Fixes #10881.
+ *Dmitry Lavrov*
- *Dylan Markow*
+* Enable support for materialized views on PostgreSQL >= 9.3.
-* Log the sql that is actually sent to the database.
+ *Dave Lee*
- If I have a query that produces sql
- `WHERE "users"."name" = 'a b'` then in the log all the
- whitespace is being squeezed. So the sql that is printed in the
- log is `WHERE "users"."name" = 'a b'`.
+* The PostgreSQL adapter supports custom domains. Fixes #14305.
- Do not squeeze whitespace out of sql queries. Fixes #10982.
+ *Yves Senn*
- *Neeraj Singh*
+* PostgreSQL `Column#type` is now determined through the corresponding OID.
+ The column types stay the same except for enum columns. They no longer have
+ `nil` as type but `enum`.
-* Fixture setup no longer depends on `ActiveRecord::Base.configurations`.
- This is relevant when `ENV["DATABASE_URL"]` is used in place of a `database.yml`.
+ See #7814.
*Yves Senn*
-* Fix mysql2 adapter raises the correct exception when executing a query on a
- closed connection.
+* Fix error when specifying a non-empty default value on a PostgreSQL array
+ column.
- *Yves Senn*
+ Fixes #10613.
-* Ambiguous reflections are on :through relationships are no longer supported.
- For example, you need to change this:
+ *Luke Steensen*
- class Author < ActiveRecord::Base
- has_many :posts
- has_many :taggings, through: :posts
- end
+* Fix error where `.persisted?` throws SystemStackError for an unsaved model with a
+ custom primary key that did not save due to validation error.
- class Post < ActiveRecord::Base
- has_one :tagging
- has_many :taggings
- end
+ Fixes #14393.
- class Tagging < ActiveRecord::Base
- end
+ *Chris Finne*
- To this:
+* Introduce `validate` as an alias for `valid?`.
- class Author < ActiveRecord::Base
- has_many :posts
- has_many :taggings, through: :posts, source: :tagging
- end
+ This is more intuitive when you want to run validations but don't care about the return value.
- class Post < ActiveRecord::Base
- has_one :tagging
- has_many :taggings
- end
+ *Henrik Nyh*
- class Tagging < ActiveRecord::Base
- end
+* Create indexes inline in CREATE TABLE for MySQL.
- *Aaron Patterson*
+ This is important, because adding an index on a temporary table after it has been created
+ would commit the transaction.
-* Remove column restrictions for `count`, let the database raise if the SQL is
- invalid. The previous behavior was untested and surprising for the user.
- Fixes #5554.
+ It also allows creating and dropping indexed tables with fewer queries and fewer permissions
+ required.
Example:
- User.select("name, username").count
- # Before => SELECT count(*) FROM users
- # After => ActiveRecord::StatementInvalid
-
- # you can still use `count(:all)` to perform a query unrelated to the
- # selected columns
- User.select("name, username").count(:all) # => SELECT count(*) FROM users
-
- *Yves Senn*
-
-* Rails now automatically detects inverse associations. If you do not set the
- `:inverse_of` option on the association, then Active Record will guess the
- inverse association based on heuristics.
-
- Note that automatic inverse detection only works on `has_many`, `has_one`,
- and `belongs_to` associations. Extra options on the associations will
- also prevent the association's inverse from being found automatically.
-
- The automatic guessing of the inverse association uses a heuristic based
- on the name of the class, so it may not work for all associations,
- especially the ones with non-standard names.
-
- You can turn off the automatic detection of inverse associations by setting
- the `:inverse_of` option to `false` like so:
-
- class Taggable < ActiveRecord::Base
- belongs_to :tag, inverse_of: false
+ create_table :temp, temporary: true, as: "SELECT id, name, zip FROM a_really_complicated_query" do |t|
+ t.index :zip
end
+ # => CREATE TEMPORARY TABLE temp (INDEX (zip)) AS SELECT id, name, zip FROM a_really_complicated_query
- *John Wang*
+ *Cody Cutrer*, *Steve Rice*, *Rafael Mendonça Franca*
-* Fix `add_column` with `array` option when using PostgreSQL. Fixes #10432.
+* Use singular table name in generated migrations when
+ `ActiveRecord::Base.pluralize_table_names` is `false`.
- *Adam Anderson*
+ Fixes #13426.
-* Usage of `implicit_readonly` is being removed`. Please use `readonly` method
- explicitly to mark records as `readonly.
- Fixes #10615.
+ *Kuldeep Aggarwal*
+
+* `touch` accepts many attributes to be touched at once.
Example:
- user = User.joins(:todos).select("users.*, todos.title as todos_title").readonly(true).first
- user.todos_title = 'clean pet'
- user.save! # will raise error
+ # touches :signed_at, :sealed_at, and :updated_at/on attributes.
+ Photo.last.touch(:signed_at, :sealed_at)
- *Yves Senn*
+ *James Pinto*
-* Fix the `:primary_key` option for `has_many` associations.
+* `rake db:structure:dump` only dumps schema information if the schema
+ migration table exists.
- Fixes #10693.
+ Fixes #14217.
*Yves Senn*
-* Fix bug where tiny types are incorrectly coerced as boolean when the length is more than 1.
+* Reap connections that were checked out by now-dead threads, instead
+ of waiting until they disconnect by themselves. Before this change,
+ a suitably constructed series of short-lived threads could starve
+ the connection pool, without ever having more than a couple alive at
+ the same time.
- Fixes #10620.
+ *Matthew Draper*
- *Aaron Patterson*
+* `pk_and_sequence_for` now ensures that only the pg_depend entries
+ pointing to pg_class, and thus only sequence objects, are considered.
-* Also support extensions in PostgreSQL 9.1. This feature has been supported since 9.1.
+ *Josh Williams*
- *kennyj*
+* `where.not` adds `references` for `includes` like normal `where` calls do.
-* Deprecate `ConnectionAdapters::SchemaStatements#distinct`,
- as it is no longer used by internals.
+ Fixes #14406.
- *Ben Woosley*
-
-* Fix pending migrations error when loading schema and `ActiveRecord::Base.table_name_prefix`
- is not blank.
+ *Yves Senn*
- Call `assume_migrated_upto_version` on connection to prevent it from first
- being picked up in `method_missing`.
+* Extend fixture `$LABEL` replacement to allow string interpolation.
- In the base class, `Migration`, `method_missing` expects the argument to be a
- table name, and calls `proper_table_name` on the arguments before sending to
- `connection`. If `table_name_prefix` or `table_name_suffix` is used, the schema
- version changes to `prefix_version_suffix`, breaking `rake test:prepare`.
+ Example:
- Fixes #10411.
+ martin:
+ email: $LABEL@email.com
- *Kyle Stevens*
+ users(:martin).email # => martin@email.com
-* Method `read_attribute_before_type_cast` should accept input as symbol.
+ *Eric Steele*
- *Neeraj Singh*
+* Add support for `Relation` be passed as parameter on `QueryCache#select_all`.
-* Confirm a record has not already been destroyed before decrementing counter cache.
+ Fixes #14361.
- *Ben Tucker*
+ *arthurnn*
-* Fixed a bug in `ActiveRecord#sanitize_sql_hash_for_conditions` in which
- `self.class` is an argument to `PredicateBuilder#build_from_hash`
- causing `PredicateBuilder` to call non-existent method
- `Class#reflect_on_association`.
+* Passing an Active Record object to `find` or `exists?` is now deprecated.
+ Call `.id` on the object first.
- *Zach Ohlgren*
+ *Aaron Patterson*
-* While removing index if column option is missing then raise IrreversibleMigration exception.
+* Only use BINARY for MySQL case sensitive uniqueness check when column
+ has a case insensitive collation.
- Following code should raise `IrreversibleMigration`. But the code was
- failing since options is an array and not a hash.
+ *Ryuta Kamizono*
- def change
- change_table :users do |t|
- t.remove_index [:name, :email]
- end
- end
+* Support for MySQL 5.6 fractional seconds.
- Fix was to check if the options is a Hash before operating on it.
+ *arthurnn*, *Tatsuhiko Miyagawa*
- Fixes #10419.
+* Support for PostgreSQL `citext` data type enabling case-insensitive
+ `where` values without needing to wrap in UPPER/LOWER sql functions.
- *Neeraj Singh*
+ *Troy Kruthoff*, *Lachlan Sylvester*
-* Do not overwrite manually built records during one-to-one nested attribute assignment
+* Only save has_one associations if record has changes.
+ Previously after save related callbacks, such as `#after_commit`, were triggered when the has_one
+ object did not get saved to the db.
- For one-to-one nested associations, if you build the new (in-memory)
- child object yourself before assignment, then the NestedAttributes
- module will not overwrite it, e.g.:
+ *Alan Kennedy*
- class Member < ActiveRecord::Base
- has_one :avatar
- accepts_nested_attributes_for :avatar
+* Allow strings to specify the `#order` value.
- def avatar
- super || build_avatar(width: 200)
- end
- end
+ Example:
- member = Member.new
- member.avatar_attributes = {icon: 'sad'}
- member.avatar.width # => 200
+ Model.order(id: 'asc').to_sql == Model.order(id: :asc).to_sql
- *Olek Janiszewski*
+ *Marcelo Casiraghi*, *Robin Dupret*
-* fixes bug introduced by #3329. Now, when autosaving associations,
- deletions happen before inserts and saves. This prevents a 'duplicate
- unique value' database error that would occur if a record being created had
- the same value on a unique indexed field as that of a record being destroyed.
+* Dynamically register PostgreSQL enum OIDs. This prevents "unknown OID"
+ warnings on enum columns.
- *Johnny Holton*
+ *Dieter Komendera*
-* Handle aliased attributes in ActiveRecord::Relation.
+* `includes` is able to detect the right preloading strategy when string
+ joins are involved.
- When using symbol keys, ActiveRecord will now translate aliased attribute names to the actual column name used in the database:
+ Fixes #14109.
- With the model
+ *Aaron Patterson*, *Yves Senn*
- class Topic
- alias_attribute :heading, :title
- end
+* Fix error with validation with enum fields for records where the value for
+ any enum attribute is always evaluated as 0 during uniqueness validation.
- The call
+ Fixes #14172.
- Topic.where(heading: 'The First Topic')
+ *Vilius Luneckas* *Ahmed AbouElhamayed*
- should yield the same result as
+* `before_add` callbacks are fired before the record is saved on
+ `has_and_belongs_to_many` associations *and* on `has_many :through`
+ associations. Before this change, `before_add` callbacks would be fired
+ before the record was saved on `has_and_belongs_to_many` associations, but
+ *not* on `has_many :through` associations.
- Topic.where(title: 'The First Topic')
+ Fixes #14144.
- This also applies to ActiveRecord::Relation::Calculations calls such as `Model.sum(:aliased)` and `Model.pluck(:aliased)`.
+* Fix STI classes not defining an attribute method if there is a conflicting
+ private method defined on its ancestors.
- This will not work with SQL fragment strings like `Model.sum('DISTINCT aliased')`.
+ Fixes #11569.
*Godfrey Chan*
-* Mute `psql` output when running rake db:schema:load.
+* Coerce strings when reading attributes. Fixes #10485.
- *Godfrey Chan*
+ Example:
-* Trigger a save on `has_one association=(associate)` when the associate contents have changed.
+ book = Book.new(title: 12345)
+ book.save!
+ book.title # => "12345"
- Fixes #8856.
+ *Yves Senn*
- *Chris Thompson*
+* Deprecate half-baked support for PostgreSQL range values with excluding beginnings.
+ We currently map PostgreSQL ranges to Ruby ranges. This conversion is not fully
+ possible because the Ruby range does not support excluded beginnings.
-* Abort a rake task when missing db/structure.sql like `db:schema:load` task.
+ The current solution of incrementing the beginning is not correct and is now
+ deprecated. For subtypes where we don't know how to increment (e.g. `#succ`
+ is not defined) it will raise an `ArgumentException` for ranges with excluding
+ beginnings.
- *kennyj*
+ *Yves Senn*
-* rake:db:test:prepare falls back to original environment after execution.
+* Support for user created range types in PostgreSQL.
- *Slava Markevich*
+ *Yves Senn*
-Please check [4-0-stable](https://github.com/rails/rails/blob/4-0-stable/activerecord/CHANGELOG.md) for previous changes.
+Please check [4-1-stable](https://github.com/rails/rails/blob/4-1-stable/activerecord/CHANGELOG.md) for previous changes.