2014/05/10分のコミットです。
インスタンスに依存しているassociationをjoin, preload, eager loadするのはdeprecateになりました。
.travis.yml
の修正です。travisで2.1.2を使うように修正しています。早い。
[ci skip] doc Http::Headers methods
ActionDispatch::Http::Headers
にdocを追加しています。
[ci skip] doc ActiveSupport::TimeWithZone#to_s
ActiveSupport::TimeWithZone#to_s
メソッドのdocを修正しています。
to_s
メソッドって引数にフォーマット指定出来たんですね。知らなかった。
Reverts "Fix bugs with changed attributes tracking when transaction gets rollback"
一昨日にあったActiveRecord::Transactions
の修正をrevertしてます。
rollbackした時に、dirtyな値は保存スべきではない、との事です。
個人的にも、変わらないのが良い気がします。このコミットについてのPRはこちら。
just call the method and assert the return value
actionpack/test/controller/routing_test.rb
の修正です。
内部メソッドを使ってテストをしていた処理を、assert_equal
に修正しています。
Only need MINOR version level to test Ruby 2.1.x on Travis
.travis.yml
の修正です。
バージョンの指定にTEENY
まで指定していたのですが、travisではMINORまで指定すれば良いらしいので、TEENY
を削除しています。
test, regression test for has_many with instance dependent scope.
activerecord/test/cases/associations/has_many_associations_test.rb
の修正です。
インスタンス経由のスコープのテストの追加、であってるかなあ。
Documentation, add examples of using an Enum scope
ActiveRecord::Enum
のdocの修正です。
生成されるscopeのexampleを追加しています。
use unless and || since these options are boolean
ActionDispatch::Http::URL#build_host_url
メソッドの修正です。
booleanの値が設定されているかのチェック処理で、if.. &&
を使用していのを、unless .. ||
に修正しています。
- if options[:host].blank? && options[:only_path].blank? + unless options[:host] || options[:only_path]
blank?
が削除されて、スッキリしましたね。
use fnmatch to test for case insensitive file systems
ActionView::Resolver::PathResolver#query
メソッドの修正です。
ファイル名のチェックにFile.fnmatch
を使うように修正しています。
File.fnmatchについてはこちらを参照。ファイル名のパターンマッチ用のメソッドですね。
[ci skip] add example to AR#assign_attributes
ActiveRecord::AttributeAssignment#assign_attributes
メソッドのdocの修正です。
exampleを追加しています。
don't mutate the options hash, so we don't have to dup
ActionDispatch::Http::URL#url_for
メソッドの修正です。
path
を作成する際、引数のoptionsのコピーを生成し、その値を操作して作成していたのを、コピーを作成しないように修正しています。
コミットログにavoids extra hash allocations on each call
ともあるので、繰り返し呼ばれる処理でhashの生成処理を避ける為かと。
skip dealing with params if none are provided
こちらもActionDispatch::Http::URL#url_for
メソッドの修正です。
options[:params]
が設定されてないとき、params
の操作処理をしないようにしています。
また、以下の4点を避けるよう修正しているとの事です。
- A slow call to Hash#slice
- An is_a? test
- Extra hash allocations (from slice)
- String allocations
Hash#slice
遅いんですね。なるほど。
Fix broken proc syntax for 1.9.3
activerecord/test/models/author.rb
の修正です。
1.9.3でproc処理が動かなくなっていたのを修正しています。
- has_many :posts_with_signature, -> (record) { where("posts.title LIKE ?", "%by #{record.name.downcase}%") }, class_name: "Post" + has_many :posts_with_signature, ->(record) { where("posts.title LIKE ?", "%by #{record.name.downcase}%") }, class_name: "Post"
解りづらいのですが、->
の後ろにスペースがある/なしの違いです。 これ、とても気付きづらいんですよね…。
deprecate, join, preload, eager load of instance dependent associations.
インスタンスに依存しているassociationを記載している場合のjoin, preload, eager load処理はdeprecateになる旨WARNINGを出すよう対応しています。 インスタンスに依存しているassociationをjoin, preload, eager loadした際に、WARNINGを出すよう対応しています。
issueからサンプルを。
class User < ActiveRecord::Base has_many :posts, ->(record) { where(title: record.name)} end class Post < ActiveRecord::Base belongs_to :user end
$ rails c irb(main):006:0> User.where(:name => 'zzz').includes(:posts) User Load (5.8ms) SELECT `users`.* FROM `users` WHERE `users`.`name` = 'zzz' (Object doesn't support #inspect)
:posts
でインスタンスを引数にしてwhere
を行っているのですが、このようなscopeに対してincldes
行うと下記のようなwarningが出力されるようになります。
DEPRECATION WARNING: The association scope 'posts' is instance dependent (the scope block takes an argument). Preloading happens before the individual instances are created. This means that there is no instance being passed to the association scope. This will most likely result in broken or incorrect behavior. Joining, Preloading and eager loading of these associations is deprecated and will be removed in the future.
そもそも、現状動いていない or 誤った振る舞いをしている為、deprecateにした、との事です。
ちゃんと考えると動かないだろうと思うのですが、ぱっと見ちゃんと動きそうに見えるんですよねえ。
ActionDispatch::Http::Headers
のdocの修正です。
改行、スペースの追加等細かい修正です。
minor change in AR readme [ci skip]
activerecord/README.rdoc
の修正です。
put on rails
をin Rails
に修正。