diff options
Diffstat (limited to 'activerecord/CHANGELOG.md')
-rw-r--r-- | activerecord/CHANGELOG.md | 265 |
1 files changed, 201 insertions, 64 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index 5c7f992cde..2189340b47 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -1,12 +1,97 @@ ## Rails 4.0.0 (unreleased) ## -* Removed `:finder_sql` and `:counter_sql` collection association options. Please - use scopes instead. +* Fix AR#create to return an unsaved record when AR::RecordInvalid is + raised. Fixes #3217. + + *Dave Yeu* + +* Fixed table name prefix that is generated in engines for namespaced models + *Wojciech Wnętrzak* + +* Make sure `:environment` task is executed before `db:schema:load` or `db:structure:load` + Fixes #4772. + + *Seamus Abshere* + +* Allow Relation#merge to take a proc. + + This was requested by DHH to allow creating of one's own custom + association macros. + + For example: + + module Commentable + def has_many_comments(extra) + has_many :comments, -> { where(:foo).merge(extra) } + end + end + + class Post < ActiveRecord::Base + extend Commentable + has_many_comments -> { where(:bar) } + end + + *Jon Leighton* + +* Add CollectionProxy#scope + + This can be used to get a Relation from an association. + + Previously we had a #scoped method, but we're deprecating that for + AR::Base, so it doesn't make sense to have it here. + + This was requested by DHH, to facilitate code like this: + + Project.scope.order('created_at DESC').page(current_page).tagged_with(@tag).limit(5).scoping do + @topics = @project.topics.scope + @todolists = @project.todolists.scope + @attachments = @project.attachments.scope + @documents = @project.documents.scope + end + + *Jon Leighton* + +* Add `Relation#load` + + This method explicitly loads the records and then returns `self`. + + Rather than deciding between "do I want an array or a relation?", + most people are actually asking themselves "do I want to eager load + or lazy load?" Therefore, this method provides a way to explicitly + eager-load without having to switch from a `Relation` to an array. + + Example: + + @posts = Post.where(published: true).load + + *Jon Leighton* + +* `Model.all` now returns an `ActiveRecord::Relation`, rather than an + array of records. Use ``Relation#to_a` if you really want an array. + + In some specific cases, this may cause breakage when upgrading. + However in most cases the `ActiveRecord::Relation` will just act as a + lazy-loaded array and there will be no problems. + + Note that calling `Model.all` with options (e.g. + `Model.all(conditions: '...')` was already deprecated, but it will + still return an array in order to make the transition easier. + + `Model.scoped` is deprecated in favour of `Model.all`. + + `Relation#all` still returns an array, but is deprecated (since it + would serve no purpose if we made it return a `Relation`). + + *Jon Leighton* + +* `:finder_sql` and `:counter_sql` options on collection associations + are deprecated. Please transition to using scopes. *Jon Leighton* -* Removed `:insert_sql` and `:delete_sql` `has_and_belongs_to_many` - association options. Please use `has_many :through` instead. +* `:insert_sql` and `:delete_sql` options on `has_and_belongs_to_many` + associations are deprecated. Please transition to using `has_many + :through` *Jon Leighton* @@ -40,11 +125,11 @@ * `ActiveRecord::Relation#inspect` now makes it clear that you are dealing with a `Relation` object rather than an array:. - User.where(:age => 30).inspect - # => <ActiveRecord::Relation [#<User ...>, #<User ...>, ...]> + User.where(:age => 30).inspect + # => <ActiveRecord::Relation [#<User ...>, #<User ...>, ...]> - User.where(:age => 30).to_a.inspect - # => [#<User ...>, #<User ...>] + User.where(:age => 30).to_a.inspect + # => [#<User ...>, #<User ...>] The number of records displayed will be limited to 10. @@ -53,18 +138,25 @@ * Add `collation` and `ctype` support to PostgreSQL. These are available for PostgreSQL 8.4 or later. Example: - development: - adapter: postgresql - host: localhost - database: rails_development - username: foo - password: bar - encoding: UTF8 - collation: ja_JP.UTF8 - ctype: ja_JP.UTF8 + development: + adapter: postgresql + host: localhost + database: rails_development + username: foo + password: bar + encoding: UTF8 + collation: ja_JP.UTF8 + ctype: ja_JP.UTF8 *kennyj* +* Changed validates_presence_of on an association so that children objects + do not validate as being present if they are marked for destruction. This + prevents you from saving the parent successfully and thus putting the parent + in an invalid state. + + *Nick Monje & Brent Wheeldon* + * `FinderMethods#exists?` now returns `false` with the `false` argument. *Egor Lynko* @@ -141,29 +233,6 @@ *Joost Baaij & Carlos Antonio da Silva* -* `composed_of` was removed. You'll have to write your own accessor - and mutator methods if you'd like to use value objects to represent some - portion of your models. So, instead of: - - class Person < ActiveRecord::Base - composed_of :address, :mapping => [ %w(address_street street), %w(address_city city) ] - end - - you could write something like this: - - def address - @address ||= Address.new(address_street, address_city) - end - - def address=(address) - self[:address_street] = @address.street - self[:address_city] = @address.city - - @address = address - end - - *Steve Klabnik* - * PostgreSQL default log level is now 'warning', to bypass the noisy notice messages. You can change the log level using the `min_messages` option available in your config/database.yml. @@ -172,7 +241,7 @@ * Add uuid datatype support to PostgreSQL adapter. *Konstantin Shabanov* -* `update_attribute` has been removed. Use `update_column` if +* `update_attribute` has been removed. Use `update_columns` if you want to bypass mass-assignment protection, validations, callbacks, and touching of updated_at. Otherwise please use `update_attributes`. @@ -237,13 +306,12 @@ Note that as an interim step, it is possible to rewrite the above as: - Post.scoped(:where => { :comments_count => 10 }, :limit => 5) + Post.all.merge(:where => { :comments_count => 10 }, :limit => 5) This could save you a lot of work if there is a lot of old-style finder usage in your application. - Calling `Post.scoped(options)` is a shortcut for - `Post.scoped.merge(options)`. `Relation#merge` now accepts a hash of + `Relation#merge` now accepts a hash of options, but they must be identical to the names of the equivalent finder method. These are mostly identical to the old-style finder option names, except in the following cases: @@ -388,7 +456,7 @@ RAILS_ENV=production bundle exec rake db:schema:cache:dump => generate db/schema_cache.dump - 2) add config.use_schema_cache_dump = true in config/production.rb. BTW, true is default. + 2) add config.active_record.use_schema_cache_dump = true in config/production.rb. BTW, true is default. 3) boot rails. RAILS_ENV=production bundle exec rails server @@ -405,11 +473,11 @@ The `add_index` method now supports a `where` option that receives a string with the partial index criteria. - add_index(:accounts, :code, :where => "active") + add_index(:accounts, :code, :where => "active") - Generates + Generates - CREATE INDEX index_accounts_on_code ON accounts(code) WHERE active + CREATE INDEX index_accounts_on_code ON accounts(code) WHERE active *Marcelo Silveira* @@ -426,24 +494,13 @@ * Added the `ActiveRecord::NullRelation` class implementing the null object pattern for the Relation class. *Juanjo Bazán* -* Added deprecation for the `:dependent => :restrict` association option. - - Please note: - - * Up until now `has_many` and `has_one`, `:dependent => :restrict` - option raised a `DeleteRestrictionError` at the time of destroying - the object. Instead, it will add an error on the model. - - * To fix this warning, make sure your code isn't relying on a - `DeleteRestrictionError` and then add - `config.active_record.dependent_restrict_raises = false` to your - application config. +* Added new `:dependent => :restrict_with_error` option. This will add + an error to the model, rather than raising an exception. - * New rails application would be generated with the - `config.active_record.dependent_restrict_raises = false` in the - application config. + The `:restrict` option is renamed to `:restrict_with_exception` to + make this distinction explicit. - *Manoj Kumar* + *Manoj Kumar & Jon Leighton* * Added `create_join_table` migration helper to create HABTM join tables @@ -534,6 +591,86 @@ *Roman Shatsov* +## Rails 3.2.8 (Aug 9, 2012) ## + +* Do not consider the numeric attribute as changed if the old value is zero and the new value + is not a string. + Fixes #7237. + + *Rafael Mendonça França* + +* Do not consider the numeric attribute as changed if the old value is zero and the new value + is not a string. + Fixes #7237. + + *Rafael Mendonça França* + +* Removes the deprecation of `update_attribute`. *fxn* + +* Reverted the deprecation of `composed_of`. *Rafael Mendonça França* + +* Reverted the deprecation of `*_sql` association options. They will + be deprecated in 4.0 instead. *Jon Leighton* + +* Do not eager load AR session store. ActiveRecord::SessionStore depends on the abstract store + in Action Pack. Eager loading this class would break client code that eager loads Active Record + standalone. + Fixes #7160 + + *Xavier Noria* + +* Do not set RAILS_ENV to "development" when using `db:test:prepare` and related rake tasks. + This was causing the truncation of the development database data when using RSpec. + Fixes #7175. + + *Rafael Mendonça França* + + +## Rails 3.2.7 (Jul 26, 2012) ## + +* `:finder_sql` and `:counter_sql` options on collection associations + are deprecated. Please transition to using scopes. + + *Jon Leighton* + +* `:insert_sql` and `:delete_sql` options on `has_and_belongs_to_many` + associations are deprecated. Please transition to using `has_many + :through` + + *Jon Leighton* + +* `composed_of` has been deprecated. You'll have to write your own accessor + and mutator methods if you'd like to use value objects to represent some + portion of your models. + + *Steve Klabnik* + +* `update_attribute` has been deprecated. Use `update_column` if + you want to bypass mass-assignment protection, validations, callbacks, + and touching of updated_at. Otherwise please use `update_attributes`. + + *Steve Klabnik* + + +## Rails 3.2.6 (Jun 12, 2012) ## + +* protect against the nesting of hashes changing the + table context in the next call to build_from_hash. This fix + covers this case as well. + + CVE-2012-2695 + +* Revert earlier 'perf fix' (see 3.2.4 changelog / GH #6289). This + change introduced a regression (GH #6609). assoc.clear and + assoc.delete_all have loaded the association before doing the delete + since at least Rails 2.3. Doing the delete without loading the + records means that the `before_remove` and `after_remove` callbacks do + not get invoked. Therefore, this change was less a fix a more an + optimisation, which should only have gone into master. + + *Jon Leighton* + + ## Rails 3.2.5 (Jun 1, 2012) ## * Restore behavior of Active Record 3.2.3 scopes. |