2017/04/10分のコミットです。
CHANGELOGにのったコミットは以下の通りです。
Merge pull request #28713 from kamipo/expose_queries_for_association_queries
Active Recordの修正です。
AssociationQueryValue
、PolymorphicArrayValue
にqueries
メソッドを追加し、queryを外から取得出来るよう修正しています。
exclude ORDER BY clause for exists? (#28699)
activerecord/lib/active_record/relation/finder_methods.rb
の修正です。
exists?
メソッドで、ORDER BY句を除外するよう修正しています。
# before Model.order(status: :desc).any? # SELECT 1 AS one FROM `models` ORDER BY `models`.`status` DESC LIMIT 1 # after Model.order(status: :desc).any? # SELECT COUNT(*) FROM `models`
Merge pull request #26981 from kamipo/should_not_except_order_for_existsでORDER BY句を維持するよう修正したのですが、 下位互換を維持する為(ORDER BYが設定されている事によりSQLエラーになるのを防ぐ為)、修正されたようです。
なお、exists?
の挙動を変えたい場合は、construct_relation_for_exists
を上書きすれば出来るようになっています。参考:Extract construct_relation_for_exists
in FinderMethods
Implement fetch_values
for HashWithIndifferentAccess (#28316)
activesupport/lib/active_support/hash_with_indifferent_access.rb
の修正です。
HashWithIndifferentAccess
にfetch_values
メソッドを追加しています。挙動はRuby#fetch_values
と同じです。
hash = ActiveSupport::HashWithIndifferentAccess.new hash[:a] = 'x' hash[:b] = 'y' hash.fetch_values('a', 'b') # => ["x", "y"] hash.fetch_values('a', 'c') { |key| 'z' } # => ["x", "z"] hash.fetch_values('a', 'c') # => KeyError: key not found: "c"
[ci skip] documented issue related before_destroy
rails guideのActive Record Callbacks
の修正です。
Destroying an Object
の項に、associationのrecord削除時にcallbackを実行したい場合、before_destroy
callbackはdependent: :destroy
associationsより先に定義する必要がある(:dependent
はcallbackを使用しており、callbackは定義された順に実行される為)旨説明を追加しています
rails guideのActive Record Callbacks
の修正です。
callback
-> callbacks
に修正しています。