aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/CHANGELOG.md
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/CHANGELOG.md')
-rw-r--r--activerecord/CHANGELOG.md787
1 files changed, 377 insertions, 410 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md
index c5df36c526..6cdf9ebd9b 100644
--- a/activerecord/CHANGELOG.md
+++ b/activerecord/CHANGELOG.md
@@ -1,675 +1,642 @@
-* Set Rails console to use log formatter and log level as specified for the
- given environment.
+* PostgreSQL, no longer disables user triggers if system triggers can't be
+ disabled. Disabling user triggers does not fulfill what the method promises.
+ Rails currently requires superuser privileges for this method.
- Fixes #15470.
-
- *Jacob Evelyn*
-
-* New records remain new after YAML serialization.
-
- *Sean Griffin*
-
-* PostgreSQL support default values for enum types. Fixes #7814.
-
- *Yves Senn*
-
-* PostgreSQL `default_sequence_name` respects schema. Fixes #7516.
-
- *Yves Senn*
-
-* Fixed `columns_for_distinct` of postgresql adapter to work correctly
- with orders without sort direction modifiers.
-
- *Nikolay Kondratyev*
-
-* PostgreSQL `reset_pk_sequence!` respects schemas. Fixes #14719.
+ If you absolutely rely on this behavior, consider patching
+ `disable_referential_integrity`.
*Yves Senn*
-* Keep PostgreSQL `hstore` and `json` attributes as `Hash` in `@attributes`.
- Fixes duplication in combination with `store_accessor`.
+* Restore aborted transaction state when `disable_referential_integrity` fails
+ due to missing permissions.
- Fixes #15369.
+ *Toby Ovod-Everett*, *Yves Senn*
- *Yves Senn*
-
-* `rake railties:install:migrations` respects the order of railties.
-
- *Arun Agrawal*
-
-* Fix redefine a has_and_belongs_to_many inside inherited class
- Fixing regression case, where redefining the same has_an_belongs_to_many
- definition into a subclass would raise.
-
- Fixes #14983.
-
- *arthurnn*
+* PostgreSQL, print warning message if `disable_referential_integrity` fails
+ due to missing permissions.
-* 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.
+ *Andrey Nering*, *Yves Senn*
- Fixes #14682.
+* Allow `:limit` option for MySQL bigint primary key support.
- *arthurnn*
-
-* Fixed serialization for records with an attribute named `format`.
+ Example:
- Fixes #15188.
+ create_table :foos, id: :primary_key, limit: 8 do |t|
+ end
- *Godfrey Chan*
+ # or
-* When a `group` is set, `sum`, `size`, `average`, `minimum` and `maximum`
- on a NullRelation should return a Hash.
+ create_table :foos, id: false do |t|
+ t.primary_key :id, limit: 8
+ end
- *Kuldeep Aggarwal*
+ *Ryuta Kamizono*
-* Fixed serialized fields returning serialized data after being updated with
- `update_column`.
+* `belongs_to` will now trigger a validation error by default if the association is not present.
+ You can turn this off on a per-association basis with `optional: true`.
+ (Note this new default only applies to new Rails apps that will be generated with
+ `config.active_record.belongs_to_required_by_default = true` in initializer.)
- *Simon Hørup Eskildsen*
+ *Josef Šimánek*
-* Fixed polymorphic eager loading when using a String as foreign key.
+* Fixed ActiveRecord::Relation#becomes! and changed_attributes issues for type
+ column.
- Fixes #14734.
+ Fixes #17139.
- *Lauro Caetano*
+ *Miklos Fazekas*
-* Change belongs_to touch to be consistent with timestamp updates
+* Format the time string according to the precision of the time column.
- 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.
+ *Ryuta Kamizono*
- *Brock Trappitt*
+* Allow `:precision` option for time type columns.
-* Fixed the inferred table name of a has_and_belongs_to_many auxiliar
- table inside a schema.
+ *Ryuta Kamizono*
- Fixes #14824
+* Add `ActiveRecord::Base.suppress` to prevent the receiver from being saved
+ during the given block.
- *Eric Chahin*
+ For example, here's a pattern of creating notifications when new comments
+ are posted. (The notification may in turn trigger an email, a push
+ notification, or just appear in the UI somewhere):
-* 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.
+ class Comment < ActiveRecord::Base
+ belongs_to :commentable, polymorphic: true
+ after_create -> { Notification.create! comment: self,
+ recipients: commentable.recipients }
+ end
- *Sean Griffin*
+ That's what you want the bulk of the time. New comment creates a new
+ Notification. But there may well be off cases, like copying a commentable
+ and its comments, where you don't want that. So you'd have a concern
+ something like this:
+
+ module Copyable
+ def copy_to(destination)
+ Notification.suppress do
+ # Copy logic that creates new comments that we do not want triggering
+ # notifications.
+ end
+ end
+ end
-* Fix bug that added `table_name_prefix` and `table_name_suffix` to
- extension names in PostgreSQL when migrating.
+ *Michael Ryan*
- *Joao Carlos*
+* `:time` option added for `#touch`.
-* The `:index` option in migrations, which previously was only available for
- `references`, now works with any column types.
+ Fixes #18905.
- *Marc Schütz*
+ *Hyonjee Joo*
-* Add support for counter name to be passed as parameter on `CounterCache::ClassMethods#reset_counters`.
+* Deprecated passing of `start` value to `find_in_batches` and `find_each`
+ in favour of `begin_at` value.
- *jnormore*
+ *Vipul A M*
-* Restrict deletion of record when using `delete_all` with `uniq`, `group`, `having`
- or `offset`.
+* Add `foreign_key_exists?` method.
- In these cases the generated query ignored them and that caused unintended
- records to be deleted.
+ *Tõnis Simo*
- Fixes #11985.
+* Use SQL COUNT and LIMIT 1 queries for `none?` and `one?` methods if no block or limit is given,
+ instead of loading the entire collection to memory.
+ This applies to relations (e.g. `User.all`) as well as associations (e.g. `account.users`)
- *Leandro Facchinetti*
+ # Before:
-* Floats with limit >= 25 that get turned into doubles in MySQL no longer have
- their limit dropped from the schema.
+ users.none?
+ # SELECT "users".* FROM "users"
- Fixes #14135.
+ users.one?
+ # SELECT "users".* FROM "users"
- *Aaron Nelson*
+ # After:
-* Fix how to calculate associated class name when using namespaced has_and_belongs_to_many
- association.
+ users.none?
+ # SELECT 1 AS one FROM "users" LIMIT 1
- Fixes #14709.
+ users.one?
+ # SELECT COUNT(*) FROM "users"
- *Kassio Borges*
+ *Eugene Gilburg*
-* `ActiveRecord::Relation::Merger#filter_binds` now compares equivalent symbols and
- strings in column names as equal.
+* Have `enum` perform type casting consistently with the rest of Active
+ Record, such as `where`.
- 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.
+ *Sean Griffin*
- *Nat Budin*
+* `scoping` no longer pollutes the current scope of sibling classes when using
+ STI. e.x.
-* Fix `stored_attributes` to correctly merge the details of stored
- attributes defined in parent classes.
+ StiOne.none.scoping do
+ StiTwo.all
+ end
- Fixes #14672.
+ Fixes #18806.
- *Brad Bennett*, *Jessica Yao*, *Lakshmi Parthasarathy*
+ *Sean Griffin*
-* `change_column_default` allows `[]` as argument to `change_column_default`.
+* `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.
- Fixes #11586.
+ Fixes #18664.
*Yves Senn*
-* Handle `name` and `"char"` column types in the PostgreSQL adapter.
-
- `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.
+* `find_in_batches` now accepts an `:end_at` parameter that complements the `:start`
+ parameter to specify where to stop batch processing.
- *J Smith*, *Yves Senn*
+ *Vipul A M*
-* Fix `PostgreSQLAdapter::OID::Float#type_cast` to convert Infinity and
- NaN PostgreSQL values into a native Ruby `Float::INFINITY` and `Float::NAN`
+* Fix rounding problem for PostgreSQL timestamp column.
- Before:
+ If timestamp column have the precision, it need to format according to
+ the precision of timestamp column.
- Point.create(value: 1.0/0)
- Point.last.value # => 0.0
-
- After:
-
- Point.create(value: 1.0/0)
- Point.last.value # => Infinity
+ *Ryuta Kamizono*
- *Innokenty Mikhailov*
+* Respect the database default charset for `schema_migrations` table.
-* Allow the PostgreSQL adapter to handle bigserial primary key types again.
+ 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.
- Fixes #10410.
+ *Ryuta Kamizono*
- *Patrick Robertson*
+* Raise `ArgumentError` when passing `nil` or `false` to `Relation#merge`.
-* 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.
+ These are not valid values to merge in a relation so it should warn the users
+ early.
- Fixes #15024.
+ *Rafael Mendonça França*
- *Yves Senn*
+* Use `SCHEMA` instead of `DB_STRUCTURE` for specifying structure file.
-* Fixed has_and_belongs_to_many's CollectionAssociation size calculation.
+ This makes the db:structure tasks consistent with test:load_structure.
- has_and_belongs_to_many should fall back to using the normal CollectionAssociation's
- size calculation if the collection is not cached or loaded.
+ *Dieter Komendera*
- Fixes #14913, #14914.
+* Respect custom primary keys for associations when calling `Relation#where`
- *Fred Wu*
+ Fixes #18813.
-* Return a non zero status when running `rake db:migrate:status` and migration table does
- not exist.
+ *Sean Griffin*
- *Paul B.*
+* 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`.
-* Add support for module-level `table_name_suffix` in models.
+ Fixes #10865.
- This makes `table_name_suffix` work the same way as `table_name_prefix` when
- using namespaced models.
+ *Sean Griffin*
- *Jenner LaFave*
+* 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.
-* Revert the behaviour of `ActiveRecord::Relation#join` changed through 4.0 => 4.1 to 4.0.
+ 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.
- In 4.1.0 `Relation#join` is delegated to `Arel#SelectManager`.
- In 4.0 series it is delegated to `Array#join`.
+ *Chris Sinjakli*
- *Bogdan Gusiev*
+* 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.
-* Log nil binary column values correctly.
+ This fixes the issue by skipping validations if the parent record is
+ persisted, not changed, and not marked for destruction.
- 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.
+ Fixes #17621.
- *James Coleman*
+ *Eileen M. Uchitelle, Aaron Patterson*
-* Rails will now pass a custom validation context through to autosave associations
- in order to validate child associations with the same context.
+* Fix n+1 query problem when eager loading nil associations (fixes #18312)
- Fixes #13854.
+ *Sammy Larbi*
- *Eric Chahin*, *Aaron Nelson*, *Kevin Casey*
+* 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.
-* Stringify all variables keys of MySQL connection configuration.
+ *Henrik Nygren*
- When `sql_mode` variable for MySQL adapters set in configuration as `String`
- was ignored and overwritten by strict mode option.
+* Fixed ActiveRecord::Relation#group method when argument is SQL reserved key word:
- Fixes #14895.
+ Example:
- *Paul Nikitochkin*
+ SplitTest.group(:key).count
+ Property.group(:value).count
-* Ensure SQLite3 statements are closed on errors.
+ *Bogdan Gusiev*
- Fixes #13631.
+* Added the `#or` method on ActiveRecord::Relation, allowing use of the OR
+ operator to combine WHERE or HAVING clauses.
- *Timur Alperovich*
+ Example:
-* Give ActiveRecord::PredicateBuilder private methods the privacy they deserve.
+ Post.where('id = 1').or(Post.where('id = 2'))
+ # => SELECT * FROM posts WHERE (id = 1) OR (id = 2)
- *Hector Satre*
+ *Sean Griffin*, *Matthew Draper*, *Gael Muller*, *Olivier El Mekki*
-* 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.
+* Don't define autosave association callbacks twice from
+ `accepts_nested_attributes_for`.
- Fixes #14845.
+ Fixes #18704.
- *Kassio Borges*
+ *Sean Griffin*
-* Reset the cache when modifying a Relation with cached Arel.
- Additionally display a warning message to make the user aware.
+* Integer types will no longer raise a `RangeError` when assigning an
+ attribute, but will instead raise when going to the database.
- *Yves Senn*
+ Fixes several vague issues which were never reported directly. See the
+ commit message from the commit which added this line for some examples.
-* PostgreSQL should internally use `:datetime` consistently for TimeStamp. Assures
- different spellings of timestamps are treated the same.
+ *Sean Griffin*
- Example:
+* 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.
- mytimestamp.simplified_type('timestamp without time zone')
- # => :datetime
- mytimestamp.simplified_type('timestamp(6) without time zone')
- # => also :datetime (previously would be :timestamp)
+ Fixes #18580.
- See #14513.
+ *Sean Griffin*
- *Jefferson Lai*
+* Don't remove join dependencies in `Relation#exists?`
-* `ActiveRecord::Base.no_touching` no longer triggers callbacks or start empty transactions.
+ Fixes #18632.
- Fixes #14841.
+ *Sean Griffin*
- *Lucas Mazza*
+* Invalid values assigned to a JSON column are assumed to be `nil`.
-* Fix name collision with `Array#select!` with `Relation#select!`.
+ Fixes #18629.
- Fixes #14752.
+ *Sean Griffin*
- *Earl St Sauver*
+* 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.
-* Fixed unexpected behavior for `has_many :through` associations going through a scoped `has_many`.
+ *Sean Griffin*
- 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.
+* Introduce the `:if_exists` option for `drop_table`.
- Fixes #14537.
+ Example:
- *Jan Habermann*
+ drop_table(:posts, if_exists: true)
-* `@destroyed` should always be set to `false` when an object is duped.
+ That would execute:
- *Kuldeep Aggarwal*
+ DROP TABLE IF EXISTS posts
-* Fixed has_many association to make it support irregular inflections.
+ If the table doesn't exist, `if_exists: false` (the default) raises an
+ exception whereas `if_exists: true` does nothing.
- Fixes #8928.
+ *Cody Cutrer*, *Stefan Kanev*, *Ryuta Kamizono*
- *arthurnn*, *Javier Goizueta*
+* Don't run SQL if attribute value is not changed for update_attribute method.
-* Fixed a problem where count used with a grouping was not returning a Hash.
+ *Prathamesh Sonpatki*
- Fixes #14721.
+* `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
- *Eric Chahin*
+ ActiveRecord::Base.time_zone_aware_types = [:datetime]
-* `sanitize_sql_like` helper method to escape a string for safe use in a SQL
- LIKE statement.
+ A deprecation warning will be emitted if you have a `:time` column, and have
+ not explicitly opted out.
- Example:
+ Fixes #3145.
- class Article
- def self.search(term)
- where("title LIKE ?", sanitize_sql_like(term))
- end
- end
+ *Sean Griffin*
- Article.search("20% _reduction_")
- # => Query looks like "... title LIKE '20\% \_reduction\_' ..."
+* Tests now run after_commit callbacks. You no longer have to declare
+ `uses_transaction ‘test name’` to test the results of an after_commit.
- *Rob Gilson*, *Yves Senn*
+ 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`.
-* Do not quote uuid default value on `change_column`.
+ *arthurnn*, *Ravil Bayramgalin*, *Matthew Draper*
- Fixes #14604.
+* `nil` as a value for a binary column in a query no longer logs as
+ "<NULL binary data>", and instead logs as just "nil".
- *Eric Chahin*
+ *Sean Griffin*
-* The comparison between `Relation` and `CollectionProxy` should be consistent.
+* `attribute_will_change!` will no longer cause non-persistable attributes to
+ be sent to the database.
- Example:
+ Fixes #18407.
- author.posts == Post.where(author_id: author.id)
- # => true
- Post.where(author_id: author.id) == author.posts
- # => true
+ *Sean Griffin*
- Fixes #13506.
+* Remove support for the `protected_attributes` gem.
- *Lauro Caetano*
+ *Carlos Antonio da Silva*, *Roberto Miranda*
-* Calling `delete_all` on an unloaded `CollectionProxy` no longer
- generates a SQL statement containing each id of the collection:
+* Fix accessing of fixtures having non-string labels like Fixnum.
- Before:
+ *Prathamesh Sonpatki*
- DELETE FROM `model` WHERE `model`.`parent_id` = 1
- AND `model`.`id` IN (1, 2, 3...)
+* Remove deprecated support to preload instance-dependent associations.
- After:
+ *Yves Senn*
- DELETE FROM `model` WHERE `model`.`parent_id` = 1
+* Remove deprecated support for PostgreSQL ranges with exclusive lower bounds.
- *Eileen M. Uchitelle*, *Aaron Patterson*
+ *Yves Senn*
-* Fixed error for aggregate methods (`empty?`, `any?`, `count`) with `select`
- which created invalid SQL.
+* Remove deprecation when modifying a relation with cached arel.
+ This raises an `ImmutableRelation` error instead.
- Fixes #13648.
+ *Yves Senn*
- *Simon Woker*
+* Added `ActiveRecord::SecureToken` in order to encapsulate generation of
+ unique tokens for attributes in a model using `SecureRandom`.
-* PostgreSQL adapter only warns once for every missing OID per connection.
+ *Roberto Miranda*
- Fixes #14275.
+* Change the behavior of boolean columns to be closer to Ruby's semantics.
- *Matthew Draper*, *Yves Senn*
+ Before this change we had a small set of "truthy", and all others are "falsy".
-* PostgreSQL adapter automatically reloads it's type map when encountering
- unknown OIDs.
+ Now, we have a small set of "falsy" values and all others are "truthy" matching
+ Ruby's semantics.
- Fixes #14678.
+ *Rafael Mendonça França*
- *Matthew Draper*, *Yves Senn*
+* Deprecate `ActiveRecord::Base.errors_in_transactional_callbacks=`.
-* Fix insertion of records via `has_many :through` association with scope.
+ *Rafael Mendonça França*
- Fixes #3548.
+* Change transaction callbacks to not swallow errors.
- *Ivan Antropov*
+ Before this change any errors raised inside a transaction callback
+ were getting rescued and printed in the logs.
-* Auto-generate stable fixture UUIDs on PostgreSQL.
+ Now these errors are not rescued anymore and just bubble up, as the other callbacks.
- Fixes #11524.
+ *Rafael Mendonça França*
- *Roderick van Domburg*
+* Remove deprecated `sanitize_sql_hash_for_conditions`.
-* Fixed a problem where an enum would overwrite values of another enum
- with the same name in an unrelated class.
+ *Rafael Mendonça França*
- Fixes #14607.
+* Remove deprecated `Reflection#source_macro`.
- *Evan Whalen*
+ *Rafael Mendonça França*
-* PostgreSQL and SQLite string columns no longer have a default limit of 255.
+* Remove deprecated `symbolized_base_class` and `symbolized_sti_name`.
- Fixes #13435, #9153.
+ *Rafael Mendonça França*
- *Vladimir Sazhin*, *Toms Mikoss*, *Yves Senn*
+* Remove deprecated `ActiveRecord::Base.disable_implicit_join_references=`.
-* Make possible to have an association called `records`.
+ *Rafael Mendonça França*
- Fixes #11645.
+* Remove deprecated access to connection specification using a string accessor.
- *prathamesh-sonpatki*
+ Now all strings will be handled as a URL.
-* `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.
+ *Rafael Mendonça França*
- Fixes #14003.
+* Change the default `null` value for `timestamps` to `false`.
- *Jefferson Lai*
+ *Rafael Mendonça França*
-* Block a few default Class methods as scope name.
+* Return an array of pools from `connection_pools`.
- For instance, this will raise:
+ *Rafael Mendonça França*
- scope :public, -> { where(status: 1) }
+* Return a null column from `column_for_attribute` when no column exists.
- *arthurnn*
+ *Rafael Mendonça França*
-* Fixed error when using `with_options` with lambda.
+* Remove deprecated `serialized_attributes`.
- Fixes #9805.
+ *Rafael Mendonça França*
- *Lauro Caetano*
+* Remove deprecated automatic counter caches on `has_many :through`.
-* Switch `sqlite3:///` URLs (which were temporarily
- deprecated in 4.1) from relative to absolute.
+ *Rafael Mendonça França*
- If you still want the previous interpretation, you should replace
- `sqlite3:///my/path` with `sqlite3:my/path`.
+* Change the way in which callback chains can be halted.
- *Matthew Draper*
+ 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.
-* Treat blank UUID values as `nil`.
+ *claudiob*
- Example:
+* Clear query cache on rollback.
- Sample.new(uuid_field: '') #=> <Sample id: nil, uuid_field: nil>
+ *Florian Weingarten*
- *Dmitry Lavrov*
+* Fixed setting of foreign_key for through associations while building of new record.
-* Enable support for materialized views on PostgreSQL >= 9.3.
+ Fixes #12698.
- *Dave Lee*
+ *Ivan Antropov*
-* The PostgreSQL adapter supports custom domains. Fixes #14305.
+* Improve a dump of the primary key support. If it is not a default primary key,
+ correctly dump the type and options.
- *Yves Senn*
+ Fixes #14169, #16599.
-* 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`.
+ *Ryuta Kamizono*
- See #7814.
+* Format the datetime string according to the precision of the datetime field.
- *Yves Senn*
+ Incompatible to rounding behavior between MySQL 5.6 and earlier.
-* Fixed error when specifying a non-empty default value on a PostgreSQL array column.
+ 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`:
- Fixes #10613.
+ http://bugs.mysql.com/bug.php?id=68760
- *Luke Steensen*
+ *Ryuta Kamizono*
-* Make possible to change `record_timestamps` inside Callbacks.
+* Allow precision option for MySQL datetimes.
- *Tieg Zaharia*
+ *Ryuta Kamizono*
-* Fixed error where .persisted? throws SystemStackError for an unsaved model with a
- custom primary key that didn't save due to validation error.
+* Fixed automatic inverse_of for models nested in module.
- Fixes #14393.
+ *Andrew McCloud*
- *Chris Finne*
+* Change `ActiveRecord::Relation#update` behavior so that it can
+ be called without passing ids of the records to be updated.
-* Introduce `validate` as an alias for `valid?`.
+ This change allows to update multiple records returned by
+ `ActiveRecord::Relation` with callbacks and validations.
- This is more intuitive when you want to run validations but don't care about the return value.
+ # Before
+ # ArgumentError: wrong number of arguments (1 for 2)
+ Comment.where(group: 'expert').update(body: "Group of Rails Experts")
- *Henrik Nyh*
+ # After
+ # Comments with group expert updated with body "Group of Rails Experts"
+ Comment.where(group: 'expert').update(body: "Group of Rails Experts")
-* Create indexes inline in CREATE TABLE for MySQL.
+ *Prathamesh Sonpatki*
- This is important, because adding an index on a temporary table after it has been created
- would commit the transaction.
+* Fix `reaping_frequency` option when the value is a string.
- It also allows creating and dropping indexed tables with fewer queries and fewer permissions
- required.
+ This usually happens when it is configured using `DATABASE_URL`.
- Example:
+ *korbin*
- 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
+* Fix error message when trying to create an associated record and the foreign
+ key is missing.
- *Cody Cutrer*, *Steve Rice*, *Rafael Mendonça Franca*
+ Before this fix the following exception was being raised:
-* Use singular table name in generated migrations when
- `ActiveRecord::Base.pluralize_table_names` is `false`.
+ NoMethodError: undefined method `val' for #<Arel::Nodes::BindParam:0x007fc64d19c218>
- Fixes #13426.
+ Now the message is:
- *Kuldeep Aggarwal*
+ ActiveRecord::UnknownAttributeError: unknown attribute 'foreign_key' for Model.
-* `touch` accepts many attributes to be touched at once.
+ *Rafael Mendonça França*
- Example:
+* 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.
- # touches :signed_at, :sealed_at, and :updated_at/on attributes.
- Photo.last.touch(:signed_at, :sealed_at)
+ Fixes #18070.
- *James Pinto*
+ *arthurnn*
-* `rake db:structure:dump` only dumps schema information if the schema
- migration table exists.
+* `validates_size_of` / `validates_length_of` do not count records,
+ which are `marked_for_destruction?`.
- Fixes #14217.
+ Fixes #7247.
*Yves Senn*
-* 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.
-
- *Matthew Draper*
-
-* `pk_and_sequence_for` now ensures that only the pg_depend entries
- pointing to pg_class, and thus only sequence objects, are considered.
-
- *Josh Williams*
+* Ensure `first!` and friends work on loaded associations.
-* `where.not` adds `references` for `includes` like normal `where` calls do.
+ Fixes #18237.
- Fixes #14406.
+ *Sean Griffin*
- *Yves Senn*
+* `eager_load` preserves readonly flag for associations.
-* Extend fixture `$LABEL` replacement to allow string interpolation.
+ Closes #15853.
- Example:
+ *Takashi Kokubun*
- martin:
- email: $LABEL@email.com
+* Provide `:touch` option to `save()` to accommodate saving without updating
+ timestamps.
- users(:martin).email # => martin@email.com
+ Fixes #18202.
- *Eric Steele*
+ *Dan Olson*
-* Add support for `Relation` be passed as parameter on `QueryCache#select_all`.
+* Provide a more helpful error message when an unsupported class is passed to
+ `serialize`.
- Fixes #14361.
+ Fixes #18224.
- *arthurnn*
+ *Sean Griffin*
-* Passing an Active Record object to `find` is now deprecated. Call `.id`
- on the object first.
+* Add bigint primary key support for MySQL.
-* Passing an Active Record object to `find` or `exists?` is now deprecated.
- Call `.id` on the object first.
+ Example:
-* Only use BINARY for MySQL case sensitive uniqueness check when column has a case insensitive collation.
+ create_table :foos, id: :bigint do |t|
+ end
*Ryuta Kamizono*
-* Support for MySQL 5.6 fractional seconds.
+* Support for any type primary key.
- *arthurnn*, *Tatsuhiko Miyagawa*
+ Fixes #14194.
-* Support for Postgres `citext` data type enabling case-insensitive where
- values without needing to wrap in UPPER/LOWER sql functions.
+ *Ryuta Kamizono*
- *Troy Kruthoff*, *Lachlan Sylvester*
+* Dump the default `nil` for PostgreSQL UUID primary key.
-* 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.
+ *Ryuta Kamizono*
- *Alan Kennedy*
+* 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.
-* Allow strings to specify the `#order` value.
+ *Sean Griffin*
- Example:
+* Don't raise when writing an attribute with an out-of-range datetime passed
+ by the user.
- Model.order(id: 'asc').to_sql == Model.order(id: :asc).to_sql
+ *Grey Baker*
- *Marcelo Casiraghi*, *Robin Dupret*
+* Replace deprecated `ActiveRecord::Tasks::DatabaseTasks#load_schema` with
+ `ActiveRecord::Tasks::DatabaseTasks#load_schema_for`.
-* Dynamically register PostgreSQL enum OIDs. This prevents "unknown OID"
- warnings on enum columns.
+ *Yves Senn*
- *Dieter Komendera*
+* Fixes bug with 'ActiveRecord::Type::Numeric' that causes negative values to
+ be marked as having changed when set to the same negative value.
-* `includes` is able to detect the right preloading strategy when string
- joins are involved.
+ Closes #18161.
- Fixes #14109.
+ *Daniel Fox*
- *Aaron Patterson*, *Yves Senn*
+* 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.
-* Fixed error with validation with enum fields for records where the
- value for any enum attribute is always evaluated as 0 during
- uniqueness validation.
+ *Matthew Draper*, *Yves Senn*
- Fixes #14172.
+* `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.
- *Vilius Luneckas* *Ahmed AbouElhamayed*
+ Closes #17945.
-* `before_add` callbacks are fired before the record is saved on
- `has_and_belongs_to_many` assocations *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.
+ *Yves Senn*
- Fixes #14144.
+* Fix undesirable RangeError by `Type::Integer`. Add `Type::UnsignedInteger`.
-* Fixed STI classes not defining an attribute method if there is a
- conflicting private method defined on its ancestors.
+ *Ryuta Kamizono*
- Fixes #11569.
+* 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.
-* Coerce strings when reading attributes. Fixes #10485.
+ *Ulisses Almeida*, *Kassio Borges*
- Example:
+* Remove deprecated behavior allowing nested arrays to be passed as query
+ values.
- book = Book.new(title: 12345)
- book.save!
- book.title # => "12345"
+ *Melanie Gilman*
- *Yves Senn*
+* Deprecate passing a class as a value in a query. Users should pass strings
+ instead.
-* 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.
+ *Melanie Gilman*
- 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.
+* `add_timestamps` and `remove_timestamps` now properly reversible with
+ options.
- *Yves Senn*
+ *Noam Gagliardi-Rabinovich*
-* Support for user created range types in PostgreSQL.
+* `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.
*Yves Senn*
-Please check [4-1-stable](https://github.com/rails/rails/blob/4-1-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.