2021/02/12分のコミットです。
CHANGELOGにのったコミットは以下の通りです。
- Add ability to apply
scoping
toall_queries
. - Increment postgres prepared statement counter before making a prepared statement, so if the statement is aborted without Rails knowledge (e.g., if app gets kill -9d during long-running query or due to Rack::Timeout), app won't end up in perpetual crash state for being inconsistent with Postgres.
- Skip optimised #exist? query when #include? is called on a relation with a having clause
Improve AJAX example [ci skip]
rails guideのWorking with JavaScript in Rails
の修正です。
An Introduction to Ajax
の項にあるexampleコード、参照する変数を誤っていたのを修正しています。
Add ActiveRecord::Result.empty
Active Recordの修正です。
空のresultを表す為のActiveRecord::Result.empty
を追加しています。
Avoid stack level too deep in predicate builder
activerecord/lib/active_record/relation/predicate_builder.rb
の修正です。
associationと同じ名前の外部キーが指定されているような場合に、predicate builderでstack level too deepが発生してしまうバグがあったのを修正しています。
Enable scoping to apply to all queries
Active Recordの修正です。
scoping
methodで指定したscopeの影響範囲が、クラスメソッドだけだったのを、インスタンスメソッドにも影響するよう修正しています。 インスタンスメソッドにも影響するようにするには、scoping
にall_queries
オプションを指定する必要があります。
Post.where(blog_id: post.blog_id).scoping(all_queries: true) do post.update(title: "a post title") end
Fix formatting in highlight docs
actionview/lib/action_view/helpers/text_helper.rb
のdocの修正です。
highlight
メソッドのdocのフォーマットが崩れている箇所があったのを修正しています。
Make we always type cast TimeWithZone objects before passing to mysql2
activerecord/lib/active_record/connection_adapters/mysql/quoting.rb
の修正です。
MySQLのquote処理で、TimeWithZone objectに対するtype cast処理が正しく行われないバグがあったのを修正しています。
activerecord/test/cases/base_test.rb
の修正です。
rubocopの設定に違反している箇所があったのを修正しています。
activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
の修正です。
PostgreSQLのprepared statement counterを、prepared statementを作成する前にインクリメントするよう修正しています。
statementがRails外の処理で破棄されてしまった場合に、DBが不正な状態にならないようにする為。
Handle Relations with having clauses in #include?
activerecord/lib/active_record/relation/finder_methods.rb
の修正です。
実行したrelationにhaving caluseが指定されている場合、#include?
実行時に最適化された#exist?
メソッドを実行しないよう修正しています。aliased selectを保持している + having caluseでそのaliased selectを参照しているような場合に、エラーになってしまうのを避ける為。
Add missing ActionView helper number_to_human in guides
rails guideのAction View Helpers
の修正です。
NumberHelper
の項にnumber_to_human
メソッドの説明を追加しています。
Use +/ instead of ` in the rdoc [ci skip]
activerecord/lib/active_record/relation.rb
のdocの修正です。
scoping
メソッドのdocでmarkdow記法を使用していたのを、RDoc記法を使用するよう修正しています。
Fixes a typo and some cosmetic changes for migration documentation added in #40806 [ci skip]
activerecord/lib/active_record/migration.rb
のdocの修正です。
migrationのdocでmarkdow記法を使用していたのを、RDoc記法を使用するよう修正しています。
Harmonize average aggregation with minimum and maximum
activerecord/lib/active_record/relation/calculations.rb
の修正です。
Merge pull request #40351 from schmijos/avg-decimal-floatで、average
の結果が必ずBigDecimal
になっていたのを、average
の対象のカラムがFloatの場合Floatの値を返すよう修正したのですが、そもそもの問題はaverage
の結果を返す際にtype cast処理が行われていなかった事でした。そのため、average
の結果を返す際に、type cast処理を行うよう修正ですしています。なお、integerの結果については古いバージョン同様、BigDecimalの値を返すようになっています。
Refactor type_cast_calculated_value
to look up cast_type before
activerecord/lib/active_record/relation/calculations.rb
の修正です。
type_cast_calculated_value
メソッドでcast_typeを先にチェックするようリファクタリングしています。
Fix unprepared_statement
to work it when nesting
activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
の修正です。
unprepared_statement
blockをネストした場合に、block内でprepared statementsが実行されてしまう、というバグがあったのを修正しています。