2022/12/09分のコミットです。
CHANGELOGにのったコミットは以下の通りです。
actiontext/CHANGELOG.md
- Support
strict_loading:
option forhas_rich_text
declaration - Focus rich-text editor after calling
fill_in_rich_text_area
Ensure query_constraints_list
is empty if primary_key
is nil
activerecord/test/cases/persistence_test.rb
の修正です。
primary_key
がnilの場合、query_constraints_list
は空になっている事を確認するテストを追加しています。
Fixed form helper documentation [ci-skip]
rails guideのAction View Form Helpers
の修正です。
The fields_for Helper :index Option
の項の言い回しを修正しています。
Move calls on Base connection to methods for rake tasks
Active Recordの修正です。
rake task内のconnection取得処理(Base.connection
、及び、Base.establish_connection
)を専用のメソッドに切り出して、そちらを使用するよう修正しています。Base.connection
とBase.establish_connection
に依存しているのはshardingサポート対応で問題になっており、処理の修正を一箇所で済ませるようにする為に専用のメソッドに切り出したとの事です。
[Fix: #46455] ActiveRecord::Calculations#ids plucks included associations IDs
activerecord/lib/active_record/querying.rb
、
activerecord/lib/active_record/relation/calculations.rb
の修正です。
ActiveRecord::Calculations#ids
を、associationではなくbase modelのunique idsを返すよう修正しています。元々は単にpluck
を実行するだけの実装になっており、assocationをeager loadした場合にassociatinoのidも含むようになっていました。今回の修正で、associationのidは含まない、単純にbase modelのidを返すように変更になっています。
Post.find_by(id: 1).comments.count # => 5 Post.includes(:comments).where(id: 1).pluck(:id) # => [1, 1, 1, 1, 1] Post.includes(:comments).where(id: 1).ids # => [1]
Merge pull request #46661 from Shopify/clear-query-cache-deadlock
activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
の修正です。
Active Recordで使用する排他制御用のlock処理のインスタンスを、全てのconnectionで同じインスタンスを使用するよう修正しています。デッドロック回避の為。
Fix add_foreign_key
with if_not_exists
referencing the same table but via different columns
activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
の修正です。
add_foreign_key
メソッドで、if_not_exists
/if_exist
を指定、かつ、同メソッドでカラム名を複数している場合(e.g. add_foreign_key :friendships, :users, column: :friend_id, if_not_exists: true
)に正しくカラムのチェック処理が行われないバグがあったのを修正しています。
AS::Cache#fetch fully skip the read operation when force: true
activesupport/lib/active_support/cache.rb
の修正です。
ActiveSupport::Cache#fetch
にforce: true
オプションを指定された場合、read処理を全て行わないよう修正しています。
Merge pull request #46271 from seanpdoyle/has-rich-text-strict-loading
actiontext/lib/action_text/attribute.rb
の修正です。
has_rich_text
メソッドにstrict_loading
オプションを指定出来るよう修正しています。
Focus editor after calling fill_in_rich_text_area
actiontext/lib/action_text/system_test_helper.rb
の修正です。
fill_in_rich_text_area
メソッド実行時に、rich-text editorにフォーカスがあたるよう修正しています。実際にユーザがrich-text editorを操作した場合の挙動により近づける為。
#last
and #first
finders should use query_constraints
for ordering
activerecord/lib/active_record/relation/finder_methods.rb
の修正です。
query_constraints_list
が指定されている場合、#first
、#last
メソッドでorderする際にquery_constraints_list
で指定されているカラムを使用するよう修正しています。
class Developer < ActiveRecord::Base query_constraints :company_id, :id end developer = Developer.first # => SELECT "developers".* FROM "developers" ORDER BY "developers"."company_id" ASC, "developers"."id" ASC LIMIT 1