なるようになるブログ

読書感想文かrailsについてかrubyについてか

rails commit log流し読み(2021/03/28)

2021/03/28分のコミットです。

CHANGELOGへの追加はありませんでした。


Merge pull request #41765 from JasonBarnabe/patch-2

rails guideのActive Record Associationsの修正です。

associationのvalidateオプションは、新規に作成されたassociation objectでのみ実行される旨説明を追加しています。


Add test case for class level strict_loading_mode

activerecord/lib/active_record/core.rbactiverecord/test/cases/strict_loading_test.rbの修正です。

class levelのstrict_loading_modeについてのテストを追加しています。


Follow up to #41765 [ci skip] rails guideのActive Record Associationsの修正です。

has_and_belongs_to_manyのオプションについて説明している箇所にも、associationのvalidateオプションは、新規に作成されたassociation objectでのみ実行される旨説明を追加しています。


Call self.class only once in init_internals

activerecord/lib/active_record/core.rbの修正です。

init_internalsメソッドでself.classの呼び出しを一度だけで済ますよう修正しています。 self.classを複数回呼ぶのは多少遅い処理の為。


Add CHANGELOG entry for #41640

activerecord/CHANGELOG.mdの修正です。

Contains/Overlaps nodes で引数をquoteするよう修正した、Quote the arguments passed to the Contains/Overlaps Arel nodesの対応についてCHANGELOGにエントリーを追加しています。


Merge pull request #41764 from steventux/41763-return-argument-error-for-parseable-invalid-iso8601-values

activesupport/lib/active_support/values/time_zone.rbの修正です。

TimeZone.iso8601でparse errorになった場合に、KeyErrorがraiseされるケースがあったのを、ArgumentErrorをraiseするよう修正しています。

rails commit log流し読み(2021/03/27)

2021/03/27分のコミットです。

CHANGELOGへの追加はありませんでした。


Fix deprecation warning on Actionpack request test

actionpack/test/dispatch/request_test.rbの修正です。

ActionDispatch::RemoteIpに関するdeprecateメッセージが表示されていたのを修正しています。


Replace mimemagic with mini_mime

Active Storageの修正です。

mimeの取得にmimemagicを使用していたのを、mini_mimeを使用するよう修正しています。ライセンス周りの対応があった影響。


Upgrade to Marcel 1.0.0

activestorage/activestorage.gemspecの修正です。

marcel 1系を使用するようdependencyを更新しています。


Active Storage representations: respond with 404 given invalid variation key

Active Storagの修正です。

不正なvariation keyが指定された場合に、representations処理で404を返すよう修正しています。


Add frozen_string_literal pragma

activestorage/app/controllers/active_storage/representations/base_controller.rbの修正です。

ファイルにfrozen_string_literalの指定を追加しています。

rails commit log流し読み(2021/03/26)

2021/03/26分のコミットです。

CHANGELOGへの追加はありませんでした。


Merge pull request #41756 from c960657/patch-3

activerecord/lib/active_record/model_schema.rbの修正です。

deprecated typeかどうかをチェックする際にoidが定義されているかでチェックしていたのを、array?メソッドが定義されているかどうかでチェックするよう修正しています。

kwent/activerecord6-redshift-adapterでもチェック出来るようにする為。


Merge pull request #41760 from Shopify/register-task-precedence

activerecord/lib/active_record/tasks/database_tasks.rbの修正です。

custom adaptersでtaskを登録した際に、既存のtask名と名前が部分一致した際に、既存のtaskの方が優先されてしまっていたのを、custom adpapterで独自に登録したtaskが優先されるよう修正しています。

rails commit log流し読み(2021/03/25)

2021/03/25分のコミットです。

CHANGELOGにのったコミットは以下の通りです。

activerecord/CHANGELOG.md


Rename internal @saving state to @_saving

Active Recordの修正です。

内部用の変数に_ prefixを追加しています。同名の変数がユーザに定義されて処理が上書きされてしまうのを避ける為。


Simplify and memoize polymorphic?

activerecord/lib/active_record/associations/preloader/branch.rbの修正です。

polymorphicかどうかのチェック処理をメモ化するよう修正しています。


Fix handling of ParseError in controllers

actionpack/lib/action_controller/metal/params_wrapper.rbの修正です。

ActionDispatch::Http::Parameters::ParseErrorrescue_fromでcatch出来ないバグがあったのを修正しています。


Fix indentation

actionpack/lib/action_controller/metal/params_wrapper.rbの修正です。

先の対応でインデントがずれてしまっている箇所があったのを修正しています。


Add n_plus_one_only mode to Core#strict_loading!

activerecord/lib/active_record/associations/association.rbactiverecord/lib/active_record/core.rbの修正です。

strict_loading!に、associationに関するlazy loadでのみエラーをraiseするようにする為のオプションを追加しています。左記オプションを使用した場合、strict_loading!mode: :n_plus_one_onlyを指定すればOKです。

developer.strict_loading!(mode: :n_plus_one_only)

developer.projects.to_a # Does not raise
developer.projects.first.client # Raises StrictLoadingViolationError

ActiveRecord: Optimize cache_key computation (#41741)

activerecord/lib/active_record/relation.rbの修正です。

cache keyの生成の際に不要なqueryが実行されないよう修正しています。


[ci skip] Fix Grammatical Errors and Eliminate Ambiguous Wordings in Multiple Database Documents (#41670)

rails guideのMultiple Databases with Active Recordの修正です。

各箇所のグラマー、フォーマットの修正を行っています。


Revert "Prevent double save of cyclic associations"

associationの定義が循環している場合にauto saveでrecordが二重に保存されてしまうバグがあったのを修正した、Prevent double save of cyclic associationsをRevertしています。

associationの外部キーを正しく設定出来ておらず、associationの保存に失敗してしまうケースがあった為。

rails commit log流し読み(2021/03/24)

2021/03/24分のコミットです。

CHANGELOGにのったコミットは以下の通りです。

activerecord/CHANGELOG.md

actionpack/CHANGELOG.md


Fix SQL result of Book.joins(reviews: :customer) query example

rails guideのActive Record Query Interfaceの修正です。

Joining Nested Associations (Single Level)の項にあるexampleコードの実行結果が実際の結果と異なっていたのを修正しています。


Prevent double save of cyclic associations

Active Recordの修正です。

associationの定義が循環している場合に、auto saveでrecordが二重に保存されてしまうバグがあったのを修正しています。


Exclude #saving? from API docs

activerecord/lib/active_record/autosave_association.rbのdocの修正です。

内部APIであるAutosaveAssociation#saving?メソッドがAPI docに表示されないよう修正しています。


protected :can_save?

activerecord/lib/active_record/autosave_association.rbactiverecord/test/cases/autosave_association_test.rbの修正です。

can_save?メソッドの可視性をprotectedに変更、及び、テストから不要なグローバル変数の削除等を行っています。


Add _ prefix for the internal methods

activerecord/lib/active_record/autosave_association.rbの修正です。

内部用のメソッドに_ prefixを追加しています。同名のメソッドがユーザに定義されて処理が上書きされてしまうのを避ける為。


Merge pull request #41725 from okuramasafumi/add-more-examples-to-routes-shallow-doc

rails guideのRails Routing from the Outside Inの修正です。

Shallow Nestingの項に、サンプルのroutesで生成されるroutingの一覧を追加しています。


Document Destroy Async (#41680)

rails guideのActive Record Associationsの修正です。

dependentのオプションについて説明している箇所に、:destroy_asyncについての説明を追加しています。


Merge pull request #41745 from dylanahsmith/ar-class-inspection-filter

activerecord/lib/active_record/core.rbの修正です。

ActiveRecord::Base.filter_attributesにProcを指定している場合、Active Record objectのmarshal dump処理がエラーになってしまうバグがあったのを修正しています。


Merge pull request #40789 from csutter/deprecate-remote-ip-single-value

actionpack/lib/action_dispatch/middleware/remote_ip.rbの修正です。

config.action_dispatch.trusted_proxiesにsingle valueを指定するがdeprecateになりました。config.action_dispatch.trusted_proxiesにsingle valueを指定した場合とenumerableを指定した場合とで挙動が違う(デフォルトの値に追加する、とデフォルトの値を上書きする)のが混乱の元であり、single valueの方の挙動を維持する必要は無いだろう、との事でdeprecateになりました。

rails commit log流し読み(2021/03/23)

2021/03/23分のコミットです。

CHANGELOGにのったコミットは以下の通りです。

activesupport/CHANGELOG.md


Revert "Fix schema for members"

テスト用のデータの型が誤っているのを修正した、Fix schema for members をRevertしています。

型が違うのは意図的だった(foreign_keyがStringの場合もロード出来る事を確認するテストだった)為。


Fix the test case for #14855 to catch a future regression correctly

activerecord/test/cases/associations/belongs_to_associations_test.rbの修正です。

polymorphic associationでforeign_keyがStringの場合のテストが期待通りにテストされてなかったのを修正しています。


Fix typo in 6.1 release notes

rails guideのRuby on Rails 6.1 Release Notesの修正です。

I18n.default_localeI18n.default_localにタイポしていたのを修正しています。


Batch queries that are the same but are using different extension

activerecord/lib/active_record/associations/preloader/association.rbactiverecord/lib/active_record/relation.rbの修正です。

preload batche処理で、extendingskip_query_cachestrict_loadingが違うが生成されるqueryが同じ場合、batch処理でqueryがマージされるよう修正しています。


Merge pull request #41080 from ankurp/standardrb-fixes

railtiesの修正です。

generatorが生成するコードでシングルクオートを使用していた箇所を、ダブルクォートを使用するよう修正しています。


Remove non-project specific entry from gitignore

.gitignoreの修正です。

先のコミットで誤って.gitignore.DS_Storeが追加されてしまっていたのを削除しています。


More consistent quotes in template files

railtiesの修正です。

generatorが生成するコードでシングルクオートを使用していた箇所が残っていたのを、ダブルクォートを使用するよう修正しています。


Really make OrderedHash private to the framework

activesupport/lib/active_support/ordered_hash.rbのdocの修正です。

OrderedHash:nodoc:を指定して、API docに表示されないよう修正しています。


Fix test_from_trusted_xml_allows_symbol_and_yaml_types failure

activesupport/test/core_ext/hash_ext_test.rbの修正です。

不足していたactive_support/ordered_hashのrequireを追加しています。


Parsing type="yaml" node requires require "yaml"

activesupport/test/core_ext/hash_ext_test.rbの修正です。

不足していたのはactive_support/ordered_hashではなく、yamlだったようで、active_support/ordered_hashのrequireを削除し、代わりにyamlのrequireを追加しています。


to_yaml requires require "yaml"

activesupport/test/hash_with_indifferent_access_test.rbの修正です。

不足していたyamlのrequireを追加しています。


Fix WhereClause#extract_attributes to work it with a string where clause

activerecord/lib/active_record/relation/where_clause.rbの修正です。

where clauseにStringが指定された場合に、WhereClause#extract_attributesがエラーになってしまうバグがあったのを修正しています。


Merge pull request #41736 from lairtonmendes/6-1-stable

rails guideのAction Mailer Basicsの修正です。

Walkthrough to Generating a Mailerの項にあるgeneratorのexampleから、不要なsuffixの指定を削除しています。


Use triple-dot delegation in ForkTracker

activesupport/lib/active_support/fork_tracker.rbの修正です。

引数のdelegationに...を使用するよう修正しています。


Merge pull request #41713 from henrik/lookup

docの修正です。

lookup -> look upに修正しています。


Merge pull request #41684 from ricardotk002/disable-parallel-testing

Active Support、railtiesの修正です。

test runnerに個別のファイルを指定された場合(e.g. ./bin/rails test test/controllers/my_controller_test.rb)はparallelization処理を行わないよう修正しています。テスト対象が1つの場合、parallel test用のセットアップ処理の方が実行コストよりも高い(可能性がある)為。

rails commit log流し読み(2021/03/22)

2021/03/22分のコミットです。

CHANGELOGにのったコミットは以下の通りです。

activerecord/CHANGELOG.md


:scissors: [ci skip]

Active Recordのテストの修正です。

各テストファイルから不要な空行を削除しています。


Allow both current_page?(url_hash) and current_page?(**url_hash) on Ruby 2.7

actionview/lib/action_view/helpers/url_helper.rbの修正です。

current_page?に対して、Ruby 2.7でurl_hash**url_hashどちらの形式でも指定出来るよう対応しています。


Revert "Passing in a Hash instance as non-kwargs parameters has to be curly braced now"

actionview/test/template/url_helper_test.rbの修正です。

先の対応により不要になったcurrent_page?メソッドの引数へのcurly braceの指定を削除しています。


Merge pull request #41602 from intrip/40550-fix-throw-abort-on-belongs-to-third-level-rollback

activerecord/lib/active_record/associations/belongs_to_association.rbの修正です。

belongsdependent :destroyがnestしている場合に、親レコードの削除処理でabortthrowされた場合にも、レコードの削除処理が継続してしまうバグがあったのを修正しています。


Fix Float::INFINITY assignment to datetime attributes

activerecord/lib/active_record/attribute_methods/time_zone_conversion.rbの修正です。

datetime columsにFloat::INFINITYを指定した場合に、値がnilになってしまうバグがあったのを修正しています。


Make infinity handling symmetrical in cast and deserialize

activerecord/lib/active_record/attribute_methods/time_zone_conversion.rbの修正です。

castdeserializeメソッドで、infinityに対する処理が対になるよう修正しています。


Remove some references to OrderedHash

Active Supportの修正です。

deprecatedになっているOrderedHashについての説明を各docから削除、及び、使用していないactive_support/ordered_hashに関するrequireを削除しています。