aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/CHANGELOG.md
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/CHANGELOG.md')
-rw-r--r--activerecord/CHANGELOG.md727
1 files changed, 299 insertions, 428 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md
index c7928e503b..16f3f47d29 100644
--- a/activerecord/CHANGELOG.md
+++ b/activerecord/CHANGELOG.md
@@ -1,653 +1,524 @@
-* Fix PredicateBuilder so polymorhic association keys in `where` clause can
- also accept not only `ActiveRecord::Base` direct descendances (decorated
- models, for example).
+* Allow `:precision` option for time type columns.
- *Mikhail Dieterle*
+ *Ryuta Kamizono*
-* PostgreSQL adapter recognizes negative money values formatted with
- parentheses (eg. `($1.25) # => -1.25`)).
- Fixes #11899.
+* Have `enum` perform type casting consistently with the rest of Active
+ Record, such as `where`.
- *Yves Senn*
-
-* Stop interpreting SQL 'string' columns as :string type because there is no
- common STRING datatype in SQL.
-
- *Ben Woosley*
-
-* `ActiveRecord::FinderMethods#exists?` returns `true`/`false` in all cases.
-
- *Xavier Noria*
-
-* Assign inet/cidr attribute with `nil` value for invalid address.
-
- Example:
-
- record = User.new
- record.logged_in_from_ip # is type of an inet or a cidr
-
- # Before:
- record.logged_in_from_ip = 'bad ip address' # raise exception
-
- # 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'
-
- *Paul Nikitochkin*
-
-* `add_to_target` now accepts a second optional `skip_callbacks` argument
-
- If truthy, it will skip the :before_add and :after_add callbacks.
-
- *Ben Woosley*
-
-* Fix interactions between `:before_add` callbacks and nested attributes
- assignment of `has_many` associations, when the association was not
- yet loaded:
-
- - A `:before_add` callback was being called when a nested attributes
- assignment assigned to an existing record.
-
- - Nested Attributes assignment did not affect the record in the
- association target when a `:before_add` callback triggered the
- loading of the association
-
- *Jörg Schray*
-
-* Allow enable_extension migration method to be revertible.
+ *Sean Griffin*
- *Eric Tipton*
+* `scoping` no longer pollutes the current scope of sibling classes when using
+ STI. e.x.
-* Type cast hstore values on write, so that the value is consistent
- with reading from the database.
-
- Example:
-
- x = Hstore.new tags: {"bool" => true, "number" => 5}
+ StiOne.none.scoping do
+ StiTwo.all
+ end
- # Before:
- x.tags # => {"bool" => true, "number" => 5}
+ Fixes #18806.
- # After:
- x.tags # => {"bool" => "true", "number" => "5"}
+ *Sean Griffin*
- *Yves Senn* , *Severin Schoepke*
+* `remove_reference` with `foreign_key: true` removes the foreign key before
+ removing the column. This fixes a bug where it was not possible to remove
+ the column on MySQL.
-* Fix multidimensional PG arrays containing non-string items.
+ Fixes #18664.
*Yves Senn*
-* Load fixtures from linked folders.
-
- *Kassio Borges*
+* `find_in_batches` now accepts an `:end_at` parameter that complements the `:start`
+ parameter to specify where to stop batch processing.
-* Create a directory for sqlite3 file if not present on the system.
+ *Vipul A M*
- *Richard Schneeman*
+* Fix rounding problem for PostgreSQL timestamp column.
-* Removed redundant override of `xml` column definition for PG,
- in order to use `xml` column type instead of `text`.
+ If timestamp column have the precision, it need to format according to
+ the precision of timestamp column.
- *Paul Nikitochkin*, *Michael Nikitochkin*
+ *Ryuta Kamizono*
-* Revert `ActiveRecord::Relation#order` change that make new order
- prepend the old one.
+* Respect the database default charset for `schema_migrations` table.
- Before:
+ The charset of `version` column in `schema_migrations` table is depend
+ on the database default charset and collation rather than the encoding
+ of the connection.
- User.order("name asc").order("created_at desc")
- # SELECT * FROM users ORDER BY created_at desc, name asc
+ *Ryuta Kamizono*
- After:
+* Raise `ArgumentError` when passing `nil` or `false` to `Relation#merge`.
- User.order("name asc").order("created_at desc")
- # SELECT * FROM users ORDER BY name asc, created_at desc
+ These are not valid values to merge in a relation so it should warn the users
+ early.
- This also affects order defined in `default_scope` or any kind of associations.
+ *Rafael Mendonça França*
-* Add ability to define how a class is converted to Arel predicates.
- For example, adding a very vendor specific regex implementation:
+* Use `SCHEMA` instead of `DB_STRUCTURE` for specifying structure file.
- regex_handler = proc do |column, value|
- Arel::Nodes::InfixOperation.new('~', column, value.source)
- end
- ActiveRecord::PredicateBuilder.register_handler(Regexp, regex_handler)
+ This makes the db:structure tasks consistent with test:load_structure.
- *Sean Griffin & @joannecheng*
+ *Dieter Komendera*
-* Don't allow `quote_value` to be called without a column.
+* Respect custom primary keys for associations when calling `Relation#where`
- 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 #18813.
- *Ben Woosley*
+ *Sean Griffin*
-* 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.
+* Fixed several edge cases which could result in a counter cache updating
+ twice or not updating at all for `has_many` and `has_many :through`.
- Fixes: #6763
+ Fixes #10865.
- *Alfred Wong*
+ *Sean Griffin*
-* rescue from all exceptions in `ConnectionManagement#call`
+* Foreign keys added by migrations were given random, generated names. This
+ meant a different `structure.sql` would be generated every time a developer
+ ran migrations on their machine.
- Fixes #11497
+ The generated part of foreign key names is now a hash of the table name and
+ column name, which is consistent every time you run the migration.
- 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.
+ *Chris Sinjakli*
- Rescuing from all exceptions and not just StandardError, fixes this
- behaviour.
+* 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.
- *Vipul A M*
+ This fixes the issue by skipping validations if the parent record is
+ persisted, not changed, and not marked for destruction.
-* `change_column` for PostgreSQL adapter respects the `:array` option.
-
- *Yves Senn*
+ Fixes #17621.
-* Remove deprecation warning from `attribute_missing` for attributes that are columns.
+ *Eileen M. Uchitelle, Aaron Patterson*
- *Arun Agrawal*
+* Fix n+1 query problem when eager loading nil associations (fixes #18312)
-* Remove extra decrement of transaction deep level.
+ *Sammy Larbi*
- Fixes: #4566
+* Change the default error message from `can't be blank` to `must exist` for
+ the presence validator of the `:required` option on `belongs_to`/`has_one` associations.
- *Paul Nikitochkin*
+ *Henrik Nygren*
-* Reset @column_defaults when assigning `locking_column`.
- We had a potential problem. For example:
+* Fixed ActiveRecord::Relation#group method when argument is SQL reserved key word:
- class Post < ActiveRecord::Base
- self.column_defaults # if we call this unintentionally before setting locking_column ...
- self.locking_column = 'my_locking_column'
- end
-
- Post.column_defaults["my_locking_column"]
- => nil # expected value is 0 !
-
- *kennyj*
-
-* Remove extra select and update queries on save/touch/destroy ActiveRecord model
- with belongs to reflection with option `touch: true`.
+ Example:
- Fixes: #11288
+ SplitTest.group(:key).count
+ Property.group(:value).count
- *Paul Nikitochkin*
+ *Bogdan Gusiev*
-* Remove deprecated nil-passing to the following `SchemaCache` methods:
- `primary_keys`, `tables`, `columns` and `columns_hash`.
+* Added the `#or` method on ActiveRecord::Relation, allowing use of the OR
+ operator to combine WHERE or HAVING clauses.
- *Yves Senn*
+ Example:
-* Remove deprecated block filter from `ActiveRecord::Migrator#migrate`.
+ Post.where('id = 1').or(Post.where('id = 2'))
+ # => SELECT * FROM posts WHERE (id = 1) OR (id = 2)
- *Yves Senn*
+ *Sean Griffin*, *Matthew Draper*, *Gael Muller*, *Olivier El Mekki*
-* Remove deprecated String constructor from `ActiveRecord::Migrator`.
+* Don't define autosave association callbacks twice from
+ `accepts_nested_attributes_for`.
- *Yves Senn*
+ Fixes #18704.
-* Remove deprecated `scope` use without passing a callable object.
+ *Sean Griffin*
- *Arun Agrawal*
+* Integer types will no longer raise a `RangeError` when assigning an
+ attribute, but will instead raise when going to the database.
-* Remove deprecated `transaction_joinable=` in favor of `begin_transaction`
- with `:joinable` option.
+ Fixes several vague issues which were never reported directly. See the
+ commit message from the commit which added this line for some examples.
- *Arun Agrawal*
+ *Sean Griffin*
-* Remove deprecated `decrement_open_transactions`.
+* Values which would error while being sent to the database (such as an
+ ASCII-8BIT string with invalid UTF-8 bytes on SQLite3), no longer error on
+ assignment. They will still error when sent to the database, but you are
+ given the ability to re-assign it to a valid value.
- *Arun Agrawal*
+ Fixes #18580.
-* Remove deprecated `increment_open_transactions`.
+ *Sean Griffin*
- *Arun Agrawal*
+* Don't remove join dependencies in `Relation#exists?`
-* Remove deprecated `PostgreSQLAdapter#outside_transaction?`
- method. You can use `#transaction_open?` instead.
+ Fixes #18632.
- *Yves Senn*
+ *Sean Griffin*
-* Remove deprecated `ActiveRecord::Fixtures.find_table_name` in favor of
- `ActiveRecord::Fixtures.default_fixture_model_name`.
+* Invalid values assigned to a JSON column are assumed to be `nil`.
- *Vipul A M*
+ Fixes #18629.
-* Removed deprecated `columns_for_remove` from `SchemaStatements`.
+ *Sean Griffin*
- *Neeraj Singh*
+* Add `ActiveRecord::Base#accessed_fields`, which can be used to quickly
+ discover which fields were read from a model when you are looking to only
+ select the data you need from the database.
-* Remove deprecated `SchemaStatements#distinct`.
+ *Sean Griffin*
- *Francesco Rodriguez*
+* Introduce the `:if_exists` option for `drop_table`.
-* Move deprecated `ActiveRecord::TestCase` into the rails test
- suite. The class is no longer public and is only used for internal
- Rails tests.
+ Example:
- *Yves Senn*
+ drop_table(:posts, if_exists: true)
-* Removed support for deprecated option `:restrict` for `:dependent`
- in associations.
+ That would execute:
- *Neeraj Singh*
+ DROP TABLE IF EXISTS posts
-* Removed support for deprecated `delete_sql` in associations.
+ If the table doesn't exist, `if_exists: false` (the default) raises an
+ exception whereas `if_exists: true` does nothing.
- *Neeraj Singh*
+ *Cody Cutrer*, *Stefan Kanev*, *Ryuta Kamizono*
-* Removed support for deprecated `insert_sql` in associations.
+* Don't run SQL if attribute value is not changed for update_attribute method.
- *Neeraj Singh*
+ *Prathamesh Sonpatki*
-* Removed support for deprecated `finder_sql` in associations.
+* `time` columns can now get affected by `time_zone_aware_attributes`. If you have
+ set `config.time_zone` to a value other than `'UTC'`, they will be treated
+ as in that time zone by default in Rails 5.1. If this is not the desired
+ behavior, you can set
- *Neeraj Singh*
+ ActiveRecord::Base.time_zone_aware_types = [:datetime]
-* Support array as root element in JSON fields.
+ A deprecation warning will be emitted if you have a `:time` column, and have
+ not explicitly opted out.
- *Alexey Noskov & Francesco Rodriguez*
+ Fixes #3145.
-* Removed support for deprecated `counter_sql` in associations.
+ *Sean Griffin*
- *Neeraj Singh*
+* Tests now run after_commit callbacks. You no longer have to declare
+ `uses_transaction ‘test name’` to test the results of an after_commit.
-* Do not invoke callbacks when `delete_all` is called on collection.
+ after_commit callbacks run after committing a transaction whose parent
+ is not `joinable?`: un-nested transactions, transactions within test cases,
+ and transactions in `console --sandbox`.
- 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 default deletion
- strategy for that collection will be applied.
+ *arthurnn*, *Ravil Bayramgalin*, *Matthew Draper*
- User can also force a deletion strategy by passing parameter to
- `delete_all`. For example you can do `@post.comments.delete_all(:nullify)` .
+* `nil` as a value for a binary column in a query no longer logs as
+ "<NULL binary data>", and instead logs as just "nil".
- *Neeraj Singh*
+ *Sean Griffin*
-* Calling default_scope without a proc will now raise `ArgumentError`.
+* `attribute_will_change!` will no longer cause non-persistable attributes to
+ be sent to the database.
- *Neeraj Singh*
+ Fixes #18407.
-* Removed deprecated method `type_cast_code` from Column.
+ *Sean Griffin*
- *Neeraj Singh*
+* Remove support for the `protected_attributes` gem.
-* Removed deprecated options `delete_sql` and `insert_sql` from HABTM
- association.
+ *Carlos Antonio da Silva*, *Roberto Miranda*
- Removed deprecated options `finder_sql` and `counter_sql` from
- collection association.
+* Fix accessing of fixtures having non-string labels like Fixnum.
- *Neeraj Singh*
+ *Prathamesh Sonpatki*
-* Remove deprecated `ActiveRecord::Base#connection` method.
- Make sure to access it via the class.
+* Remove deprecated support to preload instance-dependent associations.
*Yves Senn*
-* Remove deprecation warning for `auto_explain_threshold_in_seconds`.
+* Remove deprecated support for PostgreSQL ranges with exclusive lower bounds.
*Yves Senn*
-* Remove deprecated `:distinct` option from `Relation#count`.
+* Remove deprecation when modifying a relation with cached arel.
+ This raises an `ImmutableRelation` error instead.
*Yves Senn*
-* Removed deprecated methods `partial_updates`, `partial_updates?` and
- `partial_updates=`.
+* Added `ActiveRecord::SecureToken` in order to encapsulate generation of
+ unique tokens for attributes in a model using `SecureRandom`.
- *Neeraj Singh*
+ *Roberto Miranda*
-* Removed deprecated method `scoped`
+* Change the behavior of boolean columns to be closer to Ruby's semantics.
- *Neeraj Singh*
+ Before this change we had a small set of "truthy", and all others are "falsy".
-* Removed deprecated method `default_scopes?`
+ Now, we have a small set of "falsy" values and all others are "truthy" matching
+ Ruby's semantics.
- *Neeraj Singh*
+ *Rafael Mendonça França*
-* Remove implicit join references that were deprecated in 4.0.
+* Deprecate `ActiveRecord::Base.errors_in_transactional_callbacks=`.
- Example:
+ *Rafael Mendonça França*
- # before with implicit joins
- Comment.where('posts.author_id' => 7)
+* Change transaction callbacks to not swallow errors.
- # after
- Comment.references(:posts).where('posts.author_id' => 7)
+ Before this change any errors raised inside a transaction callback
+ were getting rescued and printed in the logs.
- *Yves Senn*
+ Now these errors are not rescued anymore and just bubble up, as the other callbacks.
-* Apply default scope when joining associations. For example:
+ *Rafael Mendonça França*
- class Post < ActiveRecord::Base
- default_scope -> { where published: true }
- end
+* Remove deprecated `sanitize_sql_hash_for_conditions`.
- class Comment
- belongs_to :post
- end
+ *Rafael Mendonça França*
- When calling `Comment.joins(:post)`, we expect to receive only
- comments on published posts, since that is the default scope for
- posts.
+* Remove deprecated `Reflection#source_macro`.
- Before this change, the default scope from `Post` was not applied,
- so we'd get comments on unpublished posts.
+ *Rafael Mendonça França*
- *Jon Leighton*
+* Remove deprecated `symbolized_base_class` and `symbolized_sti_name`.
-* Remove `activerecord-deprecated_finders` as a dependency
+ *Rafael Mendonça França*
- *Łukasz Strzałkowski*
+* Remove deprecated `ActiveRecord::Base.disable_implicit_join_references=`.
-* Remove Oracle / Sqlserver / Firebird database tasks that were deprecated in 4.0.
+ *Rafael Mendonça França*
- *kennyj*
+* Remove deprecated access to connection specification using a string accessor.
-* `find_each` now returns an `Enumerator` when called without a block, so that it
- can be chained with other `Enumerable` methods.
+ Now all strings will be handled as a URL.
- *Ben Woosley*
+ *Rafael Mendonça França*
-* `ActiveRecord::Result.each` now returns an `Enumerator` when called without
- a block, so that it can be chained with other `Enumerable` methods.
+* Change the default `null` value for `timestamps` to `false`.
- *Ben Woosley*
+ *Rafael Mendonça França*
-* Flatten merged join_values before building the joins.
+* Return an array of pools from `connection_pools`.
- 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.
+ *Rafael Mendonça França*
- Fixes #10669.
+* Return a null column from `column_for_attribute` when no column exists.
- *Neeraj Singh and iwiznia*
+ *Rafael Mendonça França*
-* Do not load all child records for inverse case.
+* Remove deprecated `serialized_attributes`.
- currently `post.comments.find(Comment.first.id)` would load all
- comments for the given post to set the inverse association.
+ *Rafael Mendonça França*
- 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.
+* Remove deprecated automatic counter caches on `has_many :through`.
- Fix is to use in-memory records only if loaded? is true. Otherwise
- load the records using full sql.
+ *Rafael Mendonça França*
- Fixes #10509.
+* Change the way in which callback chains can be halted.
- *Neeraj Singh*
+ The preferred method to halt a callback chain from now on is to explicitly
+ `throw(:abort)`.
+ In the past, returning `false` in an ActiveRecord `before_` callback had the
+ side effect of halting the callback chain.
+ This is not recommended anymore and, depending on the value of the
+ `config.active_support.halt_callback_chains_on_return_false` option, will
+ either not work at all or display a deprecation warning.
-* `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.
+ *claudiob*
- Example:
+* Clear query cache on rollback.
- Author.inspect # => "Author(no database connection)"
+ *Florian Weingarten*
- *Yves Senn*
+* Fixed setting of foreign_key for through associations while building of new record.
-* Handle single quotes in PostgreSQL default column values.
- Fixes #10881.
+ Fixes #12698.
- *Dylan Markow*
+ *Ivan Antropov*
-* Log the sql that is actually sent to the database.
+* Improve a dump of the primary key support. If it is not a default primary key,
+ correctly dump the type and options.
- 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'`.
+ Fixes #14169, #16599.
- Do not squeeze whitespace out of sql queries. Fixes #10982.
+ *Ryuta Kamizono*
- *Neeraj Singh*
+* Format the datetime string according to the precision of the datetime field.
-* Fixture setup does no longer depend on `ActiveRecord::Base.configurations`.
- This is relevant when `ENV["DATABASE_URL"]` is used in place of a `database.yml`.
+ Incompatible to rounding behavior between MySQL 5.6 and earlier.
- *Yves Senn*
+ In 5.5, when you insert `2014-08-17 12:30:00.999999` the fractional part
+ is ignored. In 5.6, it's rounded to `2014-08-17 12:30:01`:
-* Fix mysql2 adapter raises the correct exception when executing a query on a
- closed connection.
+ http://bugs.mysql.com/bug.php?id=68760
- *Yves Senn*
+ *Ryuta Kamizono*
-* Ambiguous reflections are on :through relationships are no longer supported.
- For example, you need to change this:
+* Allow precision option for MySQL datetimes.
- class Author < ActiveRecord::Base
- has_many :posts
- has_many :taggings, :through => :posts
- end
+ *Ryuta Kamizono*
- class Post < ActiveRecord::Base
- has_one :tagging
- has_many :taggings
- end
+* Fixed automatic inverse_of for models nested in module.
- class Tagging < ActiveRecord::Base
- end
+ *Andrew McCloud*
- To this:
+* Change `ActiveRecord::Relation#update` behavior so that it can
+ be called without passing ids of the records to be updated.
- class Author < ActiveRecord::Base
- has_many :posts
- has_many :taggings, :through => :posts, :source => :tagging
- end
+ This change allows to update multiple records returned by
+ `ActiveRecord::Relation` with callbacks and validations.
- class Post < ActiveRecord::Base
- has_one :tagging
- has_many :taggings
- end
+ # Before
+ # ArgumentError: wrong number of arguments (1 for 2)
+ Comment.where(group: 'expert').update(body: "Group of Rails Experts")
- class Tagging < ActiveRecord::Base
- end
+ # After
+ # Comments with group expert updated with body "Group of Rails Experts"
+ Comment.where(group: 'expert').update(body: "Group of Rails Experts")
- *Aaron Patterson*
+ *Prathamesh Sonpatki*
-* 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.
+* Fix `reaping_frequency` option when the value is a string.
- Example:
+ This usually happens when it is configured using `DATABASE_URL`.
- User.select("name, username").count
- # Before => SELECT count(*) FROM users
- # After => ActiveRecord::StatementInvalid
+ *korbin*
- # 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
+* Fix error message when trying to create an associated record and the foreign
+ key is missing.
- *Yves Senn*
+ Before this fix the following exception was being raised:
-* 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.
+ NoMethodError: undefined method `val' for #<Arel::Nodes::BindParam:0x007fc64d19c218>
- 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.
+ Now the message is:
- 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.
+ ActiveRecord::UnknownAttributeError: unknown attribute 'foreign_key' for Model.
- You can turn off the automatic detection of inverse associations by setting
- the `:inverse_of` option to `false` like so:
+ *Rafael Mendonça França*
- class Taggable < ActiveRecord::Base
- belongs_to :tag, inverse_of: false
- end
-
- *John Wang*
-
-* Fix `add_column` with `array` option when using PostgreSQL. Fixes #10432
-
- *Adam Anderson*
-
-* Usage of `implicit_readonly` is being removed`. Please use `readonly` method
- explicitly to mark records as `readonly.
- Fixes #10615.
+* When a table has a composite primary key, the `primary_key` method for
+ SQLite3 and PostgreSQL adapters was only returning the first field of the key.
+ Ensures that it will return nil instead, as Active Record doesn't support
+ composite primary keys.
- Example:
+ Fixes #18070.
- user = User.joins(:todos).select("users.*, todos.title as todos_title").readonly(true).first
- user.todos_title = 'clean pet'
- user.save! # will raise error
+ *arthurnn*
- *Yves Senn*
+* `validates_size_of` / `validates_length_of` do not count records,
+ which are `marked_for_destruction?`.
-* Fix the `:primary_key` option for `has_many` associations.
- Fixes #10693.
+ Fixes #7247.
*Yves Senn*
-* Fix bug where tiny types are incorrectly coerced as boolean when the length is more than 1.
-
- Fixes #10620.
-
- *Aaron Patterson*
-
-* Also support extensions in PostgreSQL 9.1. This feature has been supported since 9.1.
+* Ensure `first!` and friends work on loaded associations.
- *kennyj*
+ Fixes #18237.
-* Deprecate `ConnectionAdapters::SchemaStatements#distinct`,
- as it is no longer used by internals.
+ *Sean Griffin*
- *Ben Woosley*
+* `eager_load` preserves readonly flag for associations.
-* Fix pending migrations error when loading schema and `ActiveRecord::Base.table_name_prefix`
- is not blank.
+ Closes #15853.
- Call `assume_migrated_upto_version` on connection to prevent it from first
- being picked up in `method_missing`.
+ *Takashi Kokubun*
- 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`.
+* Provide `:touch` option to `save()` to accommodate saving without updating
+ timestamps.
- Fixes #10411.
+ Fixes #18202.
- *Kyle Stevens*
+ *Dan Olson*
-* Method `read_attribute_before_type_cast` should accept input as symbol.
+* Provide a more helpful error message when an unsupported class is passed to
+ `serialize`.
- *Neeraj Singh*
+ Fixes #18224.
-* Confirm a record has not already been destroyed before decrementing counter cache.
+ *Sean Griffin*
- *Ben Tucker*
+* Add bigint primary key support for MySQL.
-* 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`.
+ Example:
- *Zach Ohlgren*
+ create_table :foos, id: :bigint do |t|
+ end
-* While removing index if column option is missing then raise IrreversibleMigration exception.
+ *Ryuta Kamizono*
- Following code should raise `IrreversibleMigration`. But the code was
- failing since options is an array and not a hash.
+* Support for any type primary key.
- def change
- change_table :users do |t|
- t.remove_index [:name, :email]
- end
- end
+ Fixes #14194.
- Fix was to check if the options is a Hash before operating on it.
+ *Ryuta Kamizono*
- Fixes #10419.
+* Dump the default `nil` for PostgreSQL UUID primary key.
- *Neeraj Singh*
+ *Ryuta Kamizono*
-* Do not overwrite manually built records during one-to-one nested attribute assignment
+* Add a `:foreign_key` option to `references` and associated migration
+ methods. The model and migration generators now use this option, rather than
+ the `add_foreign_key` form.
- 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.:
+ *Sean Griffin*
- class Member < ActiveRecord::Base
- has_one :avatar
- accepts_nested_attributes_for :avatar
-
- def avatar
- super || build_avatar(width: 200)
- end
- end
+* Don't raise when writing an attribute with an out-of-range datetime passed
+ by the user.
- member = Member.new
- member.avatar_attributes = {icon: 'sad'}
- member.avatar.width # => 200
+ *Grey Baker*
- *Olek Janiszewski*
+* Replace deprecated `ActiveRecord::Tasks::DatabaseTasks#load_schema` with
+ `ActiveRecord::Tasks::DatabaseTasks#load_schema_for`.
-* 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.
+ *Yves Senn*
- *Johnny Holton*
+* Fixes bug with 'ActiveRecord::Type::Numeric' that causes negative values to
+ be marked as having changed when set to the same negative value.
-* Handle aliased attributes in ActiveRecord::Relation.
+ Closes #18161.
- When using symbol keys, ActiveRecord will now translate aliased attribute names to the actual column name used in the database:
+ *Daniel Fox*
- With the model
+* Introduce `force: :cascade` option for `create_table`. Using this option
+ will recreate tables even if they have dependent objects (like foreign keys).
+ `db/schema.rb` now uses `force: :cascade`. This makes it possible to
+ reload the schema when foreign keys are in place.
- class Topic
- alias_attribute :heading, :title
- end
+ *Matthew Draper*, *Yves Senn*
- The call
+* `db:schema:load` and `db:structure:load` no longer purge the database
+ before loading the schema. This is left for the user to do.
+ `db:test:prepare` will still purge the database.
- Topic.where(heading: 'The First Topic')
+ Closes #17945.
- should yield the same result as
+ *Yves Senn*
- Topic.where(title: 'The First Topic')
+* Fix undesirable RangeError by `Type::Integer`. Add `Type::UnsignedInteger`.
- This also applies to ActiveRecord::Relation::Calculations calls such as `Model.sum(:aliased)` and `Model.pluck(:aliased)`.
+ *Ryuta Kamizono*
- This will not work with SQL fragment strings like `Model.sum('DISTINCT aliased')`.
+* Add `foreign_type` option to `has_one` and `has_many` association macros.
- *Godfrey Chan*
+ This option enables to define the column name of associated object's type for polymorphic associations.
-* Mute `psql` output when running rake db:schema:load.
+ *Ulisses Almeida*, *Kassio Borges*
- *Godfrey Chan*
+* Remove deprecated behavior allowing nested arrays to be passed as query
+ values.
-* Trigger a save on `has_one association=(associate)` when the associate contents have changed.
+ *Melanie Gilman*
- Fix #8856.
+* Deprecate passing a class as a value in a query. Users should pass strings
+ instead.
- *Chris Thompson*
+ *Melanie Gilman*
-* Abort a rake task when missing db/structure.sql like `db:schema:load` task.
+* `add_timestamps` and `remove_timestamps` now properly reversible with
+ options.
- *kennyj*
+ *Noam Gagliardi-Rabinovich*
-* rake:db:test:prepare falls back to original environment after execution.
+* `ActiveRecord::ConnectionAdapters::ColumnDumper#column_spec` and
+ `ActiveRecord::ConnectionAdapters::ColumnDumper#prepare_column_options` no
+ longer have a `types` argument. They should access
+ `connection#native_database_types` directly.
- *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-2-stable](https://github.com/rails/rails/blob/4-2-stable/activerecord/CHANGELOG.md) for previous changes.