diff options
Diffstat (limited to 'activerecord/CHANGELOG.md')
-rw-r--r-- | activerecord/CHANGELOG.md | 185 |
1 files changed, 148 insertions, 37 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index 8c99a3929e..756a0d7196 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -1,20 +1,76 @@ ## Rails 4.0.0 (unreleased) ## +* `ActiveModel::ForbiddenAttributesProtection` is included by default + in Active Record models. Check the docs of `ActiveModel::ForbiddenAttributesProtection` + for more details. + + *Guillermo Iguaran* + +* Remove integration between Active Record and + `ActiveModel::MassAssignmentSecurity`, `protected_attributes` gem + should be added to use `attr_accessible`/`attr_protected`. Mass + assignment options has been removed from all the AR methods that + used it (ex. AR::Base.new, AR::Base.create, AR::Base#update_attributes, etc) + + *Guillermo Iguaran* + +* Fix the return of querying with an empty hash. + Fix #6971. + + User.where(token: {}) + + Before: + + #=> SELECT * FROM users; + + After: + + #=> SELECT * FROM users WHERE 1 = 2; + + *Damien Mathieu* + +* Fix creation of through association models when using `collection=[]` + on a `has_many :through` association from an unsaved model. + Fix #7661. + + *Ernie Miller* + +* Explain only normal CRUD sql (select / update / insert / delete). + Fix problem that explains unexplainable sql. + Closes #7544 #6458. + + *kennyj* + +* Fix `find_in_batches` when primary_key is set other than id. + You can now use this method with the primary key which is not integer-based. + + Example: + + class Post < ActiveRecord::Base + self.primary_key = :title + end + + Post.find_in_batches(start: 'My First Post') do |batch| + batch.each { |post| post.author.greeting } + end + + *Toshiyuki Kawanishi* + * You can now override the generated accessor methods for stored attributes and reuse the original behavior with `read_store_attribute` and `write_store_attribute`, which are counterparts to `read_attribute` and `write_attribute`. *Matt Jones* -* Accept belongs_to (including polymorphic) association keys in queries +* Accept belongs_to (including polymorphic) association keys in queries. The following queries are now equivalent: - Post.where(:author => author) - Post.where(:author_id => author) + Post.where(author: author) + Post.where(author_id: author) - PriceEstimate.where(:estimate_of => treasure) - PriceEstimate.where(:estimate_of_type => 'Treasure', :estimate_of_id => treasure) + PriceEstimate.where(estimate_of: treasure) + PriceEstimate.where(estimate_of_type: 'Treasure', estimate_of_id: treasure) *Peter Brown* @@ -23,9 +79,41 @@ *kennyj* +* PostgreSQL inet and cidr types are converted to `IPAddr` objects. + + *Dan McClain* + +* PostgreSQL array type support. Any datatype can be used to create an + array column, with full migration and schema dumper support. + + To declare an array column, use the following syntax: + + create_table :table_with_arrays do |t| + t.integer :int_array, array: true + # integer[] + t.integer :int_array, array: true, :length => 2 + # smallint[] + t.string :string_array, array: true, length: 30 + # char varying(30)[] + end + + This respects any other migration detail (limits, defaults, etc). + Active Record will serialize and deserialize the array columns on + their way to and from the database. + + One thing to note: PostgreSQL does not enforce any limits on the + number of elements, and any array can be multi-dimensional. Any + array that is multi-dimensional must be rectangular (each sub array + must have the same number of elements as its siblings). + + If the `pg_array_parser` gem is available, it will be used when + parsing PostgreSQL's array representation. + + *Dan McClain* + * Attribute predicate methods, such as `article.title?`, will now raise `ActiveModel::MissingAttributeError` if the attribute being queried for - truthiness was not read from the database, instead of just returning false. + truthiness was not read from the database, instead of just returning `false`. *Ernie Miller* @@ -34,9 +122,13 @@ *Konstantin Shabanov* -* Map interval with precision to string datatype in PostgreSQL. Fixes #7518. *Yves Senn* +* Map interval with precision to string datatype in PostgreSQL. Fixes #7518. + + *Yves Senn* + +* Fix eagerly loading associations without primary keys. Fixes #4976. -* Fix eagerly loading associations without primary keys. Fixes #4976. *Kelley Reynolds* + *Kelley Reynolds* * Rails now raise an exception when you're trying to run a migration that has an invalid file name. Only lower case letters, numbers, and '_' are allowed in migration's file name. @@ -63,16 +155,18 @@ *Dickson S. Guedes* -* Fix time column type casting for invalid time string values to correctly return nil. +* Fix time column type casting for invalid time string values to correctly return `nil`. *Adam Meehan* -* Allow to pass Symbol or Proc into :limit option of #accepts_nested_attributes_for. +* Allow to pass Symbol or Proc into `:limit` option of #accepts_nested_attributes_for. *Mikhail Dieterle* * ActiveRecord::SessionStore has been extracted from Active Record as `activerecord-session_store` - gem. Please read the `README.md` file on the gem for the usage. *Prem Sichanugrist* + gem. Please read the `README.md` file on the gem for the usage. + + *Prem Sichanugrist* * Fix `reset_counters` when there are multiple `belongs_to` association with the same foreign key and one of them have a counter cache. @@ -208,6 +302,7 @@ * Add `add_reference` and `remove_reference` schema statements. Aliases, `add_belongs_to` and `remove_belongs_to` are acceptable. References are reversible. + Examples: # Create a user_id column @@ -229,10 +324,10 @@ * `ActiveRecord::Relation#inspect` now makes it clear that you are dealing with a `Relation` object rather than an array:. - User.where(:age => 30).inspect + User.where(age: 30).inspect # => <ActiveRecord::Relation [#<User ...>, #<User ...>, ...]> - User.where(:age => 30).to_a.inspect + User.where(age: 30).to_a.inspect # => [#<User ...>, #<User ...>] The number of records displayed will be limited to 10. @@ -343,10 +438,14 @@ *kennyj* -* Add uuid datatype support to PostgreSQL adapter. *Konstantin Shabanov* +* Add uuid datatype support to PostgreSQL adapter. + + *Konstantin Shabanov* * Added `ActiveRecord::Migration.check_pending!` that raises an error if - migrations are pending. *Richard Schneeman* + migrations are pending. + + *Richard Schneeman* * Added `#destroy!` which acts like `#destroy` but will raise an `ActiveRecord::RecordNotDestroyed` exception instead of returning `false`. @@ -396,7 +495,7 @@ methods which previously accepted "finder options" no longer do. For example this: - Post.find(:all, :conditions => { :comments_count => 10 }, :limit => 5) + Post.find(:all, conditions: { comments_count: 10 }, limit: 5) Should be rewritten in the new style which has existed since Rails 3: @@ -404,7 +503,7 @@ Note that as an interim step, it is possible to rewrite the above as: - Post.all.merge(: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. @@ -414,9 +513,9 @@ finder method. These are mostly identical to the old-style finder option names, except in the following cases: - * `:conditions` becomes `:where` - * `:include` becomes `:includes` - * `:extend` becomes `:extending` + * `:conditions` becomes `:where`. + * `:include` becomes `:includes`. + * `:extend` becomes `:extending`. The code to implement the deprecated features has been moved out to the `activerecord-deprecated_finders` gem. This gem is a dependency @@ -431,7 +530,7 @@ *Johannes Barre* -* Added ability to ActiveRecord::Relation#from to accept other ActiveRecord::Relation objects +* Added ability to ActiveRecord::Relation#from to accept other ActiveRecord::Relation objects. Record.from(subquery) Record.from(subquery, :a) @@ -457,7 +556,7 @@ *Marcelo Silveira* -* Added an :index option to automatically create indexes for references +* Added an `:index` option to automatically create indexes for references and belongs_to statements in migrations. The `references` and `belongs_to` methods now support an `index` @@ -465,7 +564,7 @@ that is identical to options available to the add_index method: create_table :messages do |t| - t.references :person, :index => true + t.references :person, index: true end Is the same as: @@ -477,7 +576,7 @@ Generators have also been updated to use the new syntax. - [Joshua Wood] + *Joshua Wood* * Added bang methods for mutating `ActiveRecord::Relation` objects. For example, while `foo.where(:bar)` will return a new object @@ -566,12 +665,12 @@ *kennyj* -* Added support for partial indices to PostgreSQL adapter +* Added support for partial indices to PostgreSQL adapter. 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 @@ -579,7 +678,7 @@ *Marcelo Silveira* -* Implemented ActiveRecord::Relation#none method +* Implemented ActiveRecord::Relation#none method. The `none` method returns a chainable relation with zero records (an instance of the NullRelation class). @@ -590,9 +689,11 @@ *Juanjo Bazán* * Added the `ActiveRecord::NullRelation` class implementing the null - object pattern for the Relation class. *Juanjo Bazán* + object pattern for the Relation class. + + *Juanjo Bazán* -* Added new `:dependent => :restrict_with_error` option. This will add +* Added new `dependent: :restrict_with_error` option. This will add an error to the model, rather than raising an exception. The `:restrict` option is renamed to `:restrict_with_exception` to @@ -600,20 +701,22 @@ *Manoj Kumar & Jon Leighton* -* Added `create_join_table` migration helper to create HABTM join tables +* Added `create_join_table` migration helper to create HABTM join tables. create_join_table :products, :categories # => - # create_table :categories_products, :id => false do |td| - # td.integer :product_id, :null => false - # td.integer :category_id, :null => false + # create_table :categories_products, id: false do |td| + # td.integer :product_id, null: false + # td.integer :category_id, null: false # end *Rafael Mendonça França* -* The primary key is always initialized in the @attributes hash to nil (unless +* The primary key is always initialized in the @attributes hash to `nil` (unless another value has been specified). + *Aaron Paterson* + * In previous releases, the following would generate a single query with an `OUTER JOIN comments`, rather than two separate queries: @@ -644,14 +747,18 @@ loading. Basically, don't worry unless you see a deprecation warning or (in future releases) an SQL error due to a missing JOIN. - [Jon Leighton] + *Jon Leighton* -* Support for the `schema_info` table has been dropped. Please +* Support for the `schema_info` table has been dropped. Please switch to `schema_migrations`. -* Connections *must* be closed at the end of a thread. If not, your + *Aaron Patterson* + +* Connections *must* be closed at the end of a thread. If not, your connection pool can fill and an exception will be raised. + *Aaron Patterson* + * Added the `ActiveRecord::Model` module which can be included in a class as an alternative to inheriting from `ActiveRecord::Base`: @@ -682,6 +789,10 @@ * PostgreSQL hstore records can be created. + *Aaron Patterson* + * PostgreSQL hstore types are automatically deserialized from the database. + *Aaron Patterson* + Please check [3-2-stable](https://github.com/rails/rails/blob/3-2-stable/activerecord/CHANGELOG.md) for previous changes. |