2021/02/12分のコミットです。
CHANGELOGにのったコミットは以下の通りです。
- Add ability to apply
scopingtoall_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が実行されてしまう、というバグがあったのを修正しています。