2019/04/04分のコミットです。
CHANGELOGにのったコミットは以下の通りです。
Cache database version in schema cache
Active Recordの修正です。
schema cacheのDBのバージョンを含むよう修正しています。これにより、schema cacheを使用している場合各処理のDBのバージョンチェック処理でqueryが実行されなくなります。
Always reject files external to app
Action Viewの修正です。
render file:
では、ファイルの指定に現在のディレクトリを基準とした相対パスだけでなく、任意のview pathを基準とした相対パスによる指定が出来るようになっていました(e.g. `render file: "../whatever"を指定すると"app/views/../whatever"を検索する)。
これはCVE-2016-0752の対応の際に互換性の為に追加された仕様なのですが、これが実際に必要になるケースは殆ど無いだろう、という事でその仕様を削除しています。
これにより、find_all_anywhere
等幾つかのメソッドが不要になった(既存のメソッドと挙動が完全に一致する)為、それらのメソッドをdeprecateにしています。
[skip ci] Add examples for has_{one,many} :through :source and :source_type (#35612)
rails guideのActive Record Associations
の修正です。
has_many through + source/source_typeオプションを指定した場合と、has_one throug + source/source_typeオプションを指定した場合のexampleを追加しています。
Use execute_batch2
rather than execute_batch
to fix performance regression for fixture loading
Active Recordの修正です。
fixtureのload時に使用するメソッドをexecute_batch
からexecute_batch2
に変更しています。
SQLite3: Make fixture loading to bulk statementsでexecute_batch
メソッドを使用してbulk statementsを使用するようになったのですが、それによりパフォーマンスリグレッションが発生していました。
で、そのリグレッションはexecute_batch2
メソッドを使用すると解決するというのがわかったので、そちらのメソッドを使用するようにしたとの事です。
参考:Add new execute_batch function
Respect table name prefix/suffix for truncate_all
Active Recordの修正です。
truncate_all
メソッドでtable_name_prefix
/ table_name_suffix
が指定された場合の考慮が不足していたのを修正しています。
activerecord/test/cases/tasks/database_tasks_test.rb
の修正です。
InternalMetadata
を参照する前にInternalMetadata
のcreateを実行し必ずテーブルがある状態にするよう修正しています。
Clear query cache when truncate table(s)
activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb
の修正です。
tableのtruncate処理を行った後にquery cacheをクリアーするよう修正しています。
Deduplicate strings held by the router
actionpack/lib/action_controller/renderer.rb
、
actionpack/lib/action_dispatch/routing/mapper.rb
の修正です。
String#-@
を使用して重複しているString objectを減らすよう修正しています。
Ensure reset_table_name
when table name prefix/suffix is changed
Active Recordのテストの修正です。
table_name_prefix
/ table_name_suffix
を変更したテストの後処理でtable nameのreset処理を必ずおこなうよう修正しています。
Merge pull request #30666 from urkle/fix-actionview-fixtureresolver
actionview/lib/action_view/testing/resolvers.rb
の修正です。
ActionView::FixtureResolver
がtemplateを検索する際にvariants
値を使用するよう修正しています。
これにより、render
に直接variants
オプションを指定する事が出来るようになっています。
class HomesController < ApplicationController def index render variants: [:mobile, :desktop] end end
とした場合、
`app/views/home/index.html+mobile.erb` `app/views/home/index.html+desktop.erb` `app/views/home/index.html.erb`
を探すようになります。
Don't drop internal metadata tables
activerecord/test/cases/tasks/database_tasks_test.rb
の修正です。
Respect table name prefix/suffix for truncate_all
の対応の際に、テストの後処理でRails内部のmetadataテーブルをdropするようにしたのですが、metadataテーブルがある事に依存しているテストがありその影響でテストがコケてるようになってしまっていました。そのため、テーブルをdropするのはやめて、代わりにdelete_all
でデータを削除するだけに修正しています。
railties/test/generators/app_generator_test.rb
の修正です。
テストの後処理を指定するのにbegin/ensure
を指定してしていたのから、begin
を削除しメソッド全体に対してensure
を指定するよう修正しています。
Fix partial caching ignore repeated items issue
actionview/lib/action_view/renderer/partial_renderer/collection_caching.rb
の修正です。
collectionをpartial + cacheで繰り返しrenderした際に、collectionが正しくrenderされないバグがあったのを修正しています。
<% same_sets = [ [1,2,3,4,5], [1,2,3,4,5], [1,2,3,4,4], [1,2,3,4,4], [1,2,3,4,6], ]%> <%= render partial: 'test_row', collection: same_sets, cached: true %>
# _test_row.html.erb <%= test_row.first %> | <%= test_row.second %> | <%= test_row.third %> | <%= test_row.fourth %> | <%= test_row.fifth %><br />
上記のようなrender処理を行った場合に、same_sets
の一部の値(cacheのkeyが一致しない値)だけ表示されていたのを、全ての値が表示されるようにしています。
Optimizer hints should be applied on Top level query as much as possible
Active Recordの修正です。
optimizer hintを可能な限りトップレベルのクエリーに適用するよう修正しています。
MAX_EXECUTION_TIME
等のhintは、トップレベルのクエリーでしか動作しない為。
Refactor Relation#cache_key
is moved from CollectionCacheKey#collection_cache_key
Active Recordの修正です。
cache keyの実装をCollectionCacheKey#collection_cache_key
からRelation
に移動しています。
cache keyの実装は元々relationメソッドに依存している部分があるのに、実装がmodel classにありました(relationメソッドを呼び出すのにsend
を使用していた)。relationのメソッドに依存しているならrelatinにあるのが適切だろうという事で移動しています。
Fix count(:all)
with eager loading and explicit select and order
activerecord/lib/active_record/relation/calculations.rb
の修正です。
count(:all)
+ eager load + 明示的にselectとorderを指定している場合に不正なSQLが生成されてしまうケースがあったのを修正しています。
Merge pull request #35698 from mtsmfm/output-test-report
Buildkiteでテストを実行した際に、テスト結果をJUnitのフォーマットで出力するよう修正しています。
テスト結果を分析する為との事です。参考:Analyze Rails CI
Fix deprecation warning about variants and formats
actionview/test/template/testing/fixture_resolver_test.rb
の修正です。
テストでdeprecateになったtemplateのformats
、variants
を使用している箇所があったのを修正しています。