diff options
Diffstat (limited to 'activerecord/CHANGELOG.md')
-rw-r--r-- | activerecord/CHANGELOG.md | 200 |
1 files changed, 159 insertions, 41 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index 4489ca1aff..3fbf043c7c 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -1,4 +1,144 @@ -## Rails 4.0.0 (unreleased) ## +## Rails 4.0.0.beta1 (February 25, 2013) ## + +* Fix overriding of attributes by default_scope on `ActiveRecord::Base#dup`. + + *Hiroshige UMINO* + +* Fix when performing an ordered join query. The bug only + affected queries where the order was given with a symbol. + Fixes #9275. + + Example: + + # This will expand the order :name to "authors".name. + Author.joins(:books).where('books.published = 1').order(:name) + +* Fixing issue #8345. Now throwing an error when one attempts to touch a + new object that has not yet been persisted. For instance: + + Example: + + ball = Ball.new + ball.touch :updated_at # => raises error + + It is not until the ball object has been persisted that it can be touched. + This follows the behavior of update_column. + + *John Wang* + +* Preloading ordered `has_many :through` associations no longer applies + invalid ordering to the `:through` association. + Fixes #8663. + + *Yves Senn* + +* The auto explain feature has been removed. This feature was + activated by configuring `config.active_record.auto_explain_threshold_in_seconds`. + The configuration option was deprecated and has no more effect. + + You can still use `ActiveRecord::Relation#explain` to see the EXPLAIN output for + any given relation. + + *Yves Senn* + +* The `:on` option for `after_commit` and `after_rollback` now + accepts an Array of actions. + Fixes #988. + + Example: + + after_commit :update_cache on: [:create, :update] + + *Yves Senn* + +* Rename related indexes on `rename_table` and `rename_column`. This + does not affect indexes with custom names. + + *Yves Senn* + +* Prevent the creation of indices with too long names, which cause + internal operations to fail (sqlite3 adapter only). The method + `allowed_index_name_length` defines the length limit enforced by + rails. It's value defaults to `index_name_length` but can vary per adapter. + Fixes #8264. + + *Yves Senn* + +* Fixing issue #776. + + Memory bloat in transactions is handled by having the transaction hold only + the AR objects which it absolutely needs to know about. These are the AR + objects with callbacks (they need to be updated as soon as something in the + transaction occurs). + + All other AR objects can be updated lazily by keeping a reference to a + TransactionState object. If an AR object gets inside a transaction, then + the transaction will add its TransactionState to the AR object. When the + user makes a call to some attribute on an AR object (which has no + callbacks) associated with a transaction, the AR object will call the + sync_with_transaction_state method and make sure it is up to date with the + transaction. After it has synced with the transaction state, the AR object + will return the attribute that was requested. + + Most of the logic in the changes are used to handle multiple transactions, + in which case the AR object has to recursively follow parent pointers of + TransactionState objects. + + *John Wang* + +* Descriptive error message when the necessary AR adapter gem was not found. + Fixes #7313. + + *Yves Senn* + +* Active Record now raises an error when blank arguments are passed to query + methods for which blank arguments do not make sense. + + Example: + + Post.includes() # => raises error + + *John Wang* + +* Simplified type casting code for timezone aware attributes to use the + `in_time_zone` method if it is available. This introduces a subtle change + of behavior when using `Date` instances as they are directly converted to + `ActiveSupport::TimeWithZone` instances without first being converted to + `Time` instances. For example: + + # Rails 3.2 behavior + >> Date.today.to_time.in_time_zone + => Wed, 13 Feb 2013 07:00:00 UTC +00:00 + + # Rails 4.0 behavior + >> Date.today.in_time_zone + => Wed, 13 Feb 2013 00:00:00 UTC +00:00 + + On the plus side it now behaves the same whether you pass a `String` date + or an actual `Date` instance. For example: + + # Rails 3.2 behavior + >> Date.civil(2013, 2, 13).to_time.in_time_zone + => Wed, 13 Feb 2013 07:00:00 UTC +00:00 + >> Time.zone.parse("2013-02-13") + => Wed, 13 Feb 2013 00:00:00 UTC +00:00 + + # Rails 4.0 behavior + >> Date.civil(2013, 2, 13).in_time_zone + => Wed, 13 Feb 2013 00:00:00 UTC +00:00 + >> "2013-02-13".in_time_zone + => Wed, 13 Feb 2013 00:00:00 UTC +00:00 + + If you need the old behavior you can convert the dates to times manually. + For example: + + >> Post.new(created_at: Date.today).created_at + => Wed, 13 Feb 2013 00:00:00 UTC +00:00 + + >> Post.new(created_at: Date.today.to_time).created_at + => Wed, 13 Feb 2013 07:00:00 UTC +00:00 + + *Andrew White* * Preloading `has_many :through` associations with conditions won't cache the `:through` association. This will prevent invalid @@ -14,18 +154,18 @@ a_user = User.includes(:recent_comments).first - # this is preloaded + # This is preloaded. a_user.recent_comments - # fetching the recent_comments through the posts association won't preload it. + # This is not preloaded, fetched now. a_user.posts *Yves Senn* -* Don't run after_commit callback when creating through an association +* Don't run `after_commit` callbacks when creating through an association if saving the record fails. - *James Miller * + *James Miller* * Allow store accessors to be overrided like other attribute methods, e.g.: @@ -54,8 +194,8 @@ *Justin George* -* The `DATABASE_URL` environment variable now converts ints, floats, and - the strings true and false to Ruby types. For example, SQLite requires +* The database adpters now converts the options passed thought `DATABASE_URL` + environment variable to the proper Ruby types before using. For example, SQLite requires that the timeout value is an integer, and PostgreSQL requires that the prepared_statements option is a boolean. These now work as expected: @@ -64,7 +204,7 @@ DATABASE_URL=sqlite3://localhost/test_db?timeout=500 DATABASE_URL=postgresql://localhost/test_db?prepared_statements=false - *Aaron Stone* + *Aaron Stone + Rafael Mendonça França* * `Relation#merge` now only overwrites where values on the LHS of the merge. Consider: @@ -121,7 +261,7 @@ *Lilibeth De La Cruz* * When `#count` is used in conjunction with `#uniq` we perform `count(:distinct => true)`. - Fix #6865. + Fixes #6865. Example: @@ -154,7 +294,7 @@ *John Wang* * Collection associations `#empty?` always respects builded records. - Fix #8879. + Fixes #8879. Example: @@ -164,10 +304,6 @@ *Yves Senn* -* Remove support for parsing YAML parameters from request. - - *Aaron Patterson* - * Support for PostgreSQL's `ltree` data type. *Rob Worley* @@ -193,7 +329,7 @@ * Improve ways to write `change` migrations, making the old `up` & `down` methods no longer necessary. * The methods `drop_table` and `remove_column` are now reversible, as long as the necessary information is given. - The method `remove_column` used to accept multiple column names; instead use `remove_columns` (which is not revertible). + The method `remove_column` used to accept multiple column names; instead use `remove_columns` (which is not reversible). The method `change_table` is also reversible, as long as its block doesn't call `remove`, `change` or `change_default` * New method `reversible` makes it possible to specify code to be run when migrating up or down. @@ -247,18 +383,13 @@ *Yves Senn* * Add `ActiveRecord::Base.cache_timestamp_format` class attribute to control - the format of the timestamp value in the cache key. - This allows users to improve the precision of the cache key. + the format of the timestamp value in the cache key. Defaults to `:nsec`. Fixes #8195. *Rafael Mendonça França* -* Add `:nsec` date format. This can be used to improve the precision of cache key. - - *Jamie Gaskins* - * Session variables can be set for the `mysql`, `mysql2`, and `postgresql` adapters - in the `variables: <hash>` parameter in `database.yml`. The key-value pairs of this + in the `variables: <hash>` parameter in `config/database.yml`. The key-value pairs of this hash will be sent in a `SET key = value` query on new database connections. See also: http://dev.mysql.com/doc/refman/5.0/en/set-statement.html http://www.postgresql.org/docs/8.3/static/sql-set.html @@ -281,7 +412,7 @@ to the update query. class User < ActiveRecord::Base - default_scope where(active: true) + default_scope -> { where(active: true) } end user = User.first @@ -418,11 +549,6 @@ *kennyj* -* Added `#none!` method for mutating `ActiveRecord::Relation` objects to a NullRelation. - It acts like `#none` but modifies relation in place. - - *Juanjo Bazán* - * Fix bug where `update_columns` and `update_column` would not let you update the primary key column. *Henrik Nyh* @@ -1139,12 +1265,11 @@ * `:conditions` becomes `:where`. * `:include` becomes `:includes`. - The code to implement the deprecated features has been moved out to - the `activerecord-deprecated_finders` gem. This gem is a dependency - of Active Record in Rails 4.0. It will no longer be a dependency - from Rails 4.1, but if your app relies on the deprecated features - then you can add it to your own Gemfile. It will be maintained by - the Rails core team until Rails 5.0 is released. + The code to implement the deprecated features has been moved out to the + `activerecord-deprecated_finders` gem. This gem is a dependency of Active + Record in Rails 4.0, so the interface works out of the box. It will no + longer be a dependency from Rails 4.1 (you'll need to add it to the + `Gemfile` in 4.1), and will be maintained until Rails 5.0. *Jon Leighton* @@ -1200,13 +1325,6 @@ *Joshua Wood* -* Added bang methods for mutating `ActiveRecord::Relation` objects. - For example, while `foo.where(:bar)` will return a new object - leaving `foo` unchanged, `foo.where!(:bar)` will mutate the foo - object - - *Jon Leighton* - * Added `#find_by` and `#find_by!` to mirror the functionality provided by dynamic finders in a way that allows dynamic input more easily: |