なるようになるブログ

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

rails commit log流し読み(2018/10/30)

2018/10/30分のコミットです。

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

activerecord/CHANGELOG.md


Missing require "active_support/concern"

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

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


Missing require "core_ext/module/attribute_accessors"

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

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


Missing require "active_support/executor"

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

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


We don't want these internal methods as public methods in our controllers

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

内部用のメソッドの可視性をprivateに変更しています。


Exercise HABTM fixtures with foreign key constraints

activerecord/test/models/parrot.rbactiverecord/test/schema/schema.rbの修正です。

HABTM association用のテーブルに対して外部キー制約を追加し、外部キー制約がある状態でHABTM associationのfixtureに関する処理が正しく動作する事を確認するようにしています。


Restore encoding: utf8mb4 in database.yml

railties/lib/rails/generators/rails/app/templates/config/databases/mysql.yml.ttの修正です。

rails newで生成するMySQL用のdatabase.ymlで、encoding: utf8mb4を再度指定するよう修正しています。

MySQL 5.1のサポートを行わない事になり、値を指定しても問題無いバージョンしかサポートしない為。


Merge pull request #34196 from gmcgibbon/connection_switch_string_name

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

ActiveRecord::Base.connected_todatabaseオプションに、URL、及び、Hashを指定出来るよう修正しています。

User.connected_to(database: { writing: "postgres://foo" }) do
  User.create!(name: "Gannon")
end

config = { "adapter" => "sqlite3", "database" => "db/readonly.sqlite3" }
User.connected_to(database: { reading: config }) do
  User.count
end

Merge pull request #19388 from yakara-ltd/fix-habtm-fixture-order

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

HABTM associations用のfixutreをロードする際に、先に親tableをロードするよう修正しています。親tableを先にロードしておかないと、referential integrityの無効化処理でエラーになってしまう為。

rails commit log流し読み(2018/10/29)

2018/10/29分のコミットです。

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

activesupport/CHANGELOG.md


Improve the logic that detects non-autoloaded constants

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

autoload対象のファイルから、autoloadの対象になってないファイルをrequireした際に、そのファイル内に定義されている定数がautoloaded constantsと見なされてしまうバグがあったのを修正しています。


Fix grammar in changed? docs [ci skip]

activemodel/lib/active_model/dirty.rbのdocの修正です。

Dirty#changed?メソッドのdocのグラマーの修正を行っています。


Registers e302725 in the CHANGELOG [ci skip]

activesupport/CHANGELOG.mdの修正です。

先のautoloadの修正についてCHANGELOGにエントリーを追加しています。


Merge pull request #34334 from albertoalmagro/privatize-constants-activesupport-timezone

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

内部向け定数であるUTC_OFFSET_WITH_COLONUTC_OFFSET_WITHOUT_COLON:nodoc:を指定、及び、private_constantを使用して可視性をprivateにしています。


Merge pull request #34335 from robin850/update-bug-report-templates

bug report templatesの修正です。

bundler/inlineのrequireに失敗した場合のケア、及び、mintest 4向けのサポートを削除しています。

bundler/inlineは2015年にリリースされたbundler 1.10からがサポートされている、Rails 5.0がサポートしているRuby 2.2にはminitest 5.4.3がバンドルされている為、どちらのコードももう不要だろうという事で削除されています。


Document exception from restrict_with_exception [ci skip]

rails guideのActive Record Associations、及び、activerecord/lib/active_record/associations.rbのdocの修正です。

associationsのdependentオプションに:restrict_with_exceptionを指定した場合の説明に、associated recordがある場合exceptionをraiseする旨だけ記載していたのを、exceptionのクラス名(ActiveRecord::DeleteRestrictionError)を記載するよう修正しています。

rails commit log流し読み(2018/10/27)

2018/10/27分のコミットです。

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


Ignore empty condition on #construct_relation_for_exists

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

FinderMethods#construct_relation_for_existsメソッドで引数のconditionsが空の場合、何もrelationに対するwhere!を実行しないよう修正しています。

exists?に空のHashを指定した場合(e.g. Topic.exists?({}))の結果が元々はtrueだったのが、Merge pull request #28705 from kamipo/extract_construct_relation_for_…の対応以降falseになってしまい、再度trueを返すようにする為に上記対応を行っています。


create_table with :primary_key option has no effect if id: false is given

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

create_tableする際に、意味の無いオプション指定(id: false + primary_key)を指定していたのを削除し、代わりにカラム定義の箇所でprimary_keyオプションを指定するよう修正しています。


exists? with string argument is not invalid type

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

primary keyにString型が使用されているmodelに対して、exists?メソッドにStringの値を指定した場合に、結果が正しく取得出来る事を確認するテストを追加しています。

rails commit log流し読み(2018/10/26)

2018/10/26分のコミットです。

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


assert_called_with should require args argument

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

assert_called_withメソッドのargs引数を必須パラメータに変更しています。

argsが不要な場合はassert_calledを使えば良い、かつ、argsが指定されて無いとassert_called_withはassertを実行しない為。


Added maxlength example to text_field documentation

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

text_fieldメソッドのdocにmaxlengthオプションを指定した場合のexampleを追加しています。


Partly revert #31819

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

If association is a hash-like object preloading failsで追加されたテストを削除しています。

If association is a hash-like object preloading failsで追加された実装のコードは、ActiveRecord::Associations::Preloader should not fail to preload through missing recordsで削除されている、かつ、If association is a hash-like object preloading failsで追加されたテストが同じPRで行われた修正無しでも通ってしまうテストで、テストとして意味が無いと思われる為。


Merge pull request #34307 from kamipo/mysql_expression_support

activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rbactiverecord/lib/active_record/connection_adapters/mysql/schema_statements.rbの修正です。

MySQLのdefault expression(デフォルト値に関数または式を使用出来る機能)、及び、expression indexes(式の値をインデックスする機能)のサポートを追加しています。

どちらもMySQL 8.0.13で追加された機能です。

参考:


Merge pull request #34208 from yskkin/inspect_with_parameter_filter

Active Record、Active Supportの修正です。

Active Recordのpretty_print / inspectのparameter filter処理で、ActiveSupport::ParameterFilterを使用するよう修正しています。

これにより、filter_parametersにProcやRegexが指定された場合も、正しくfilter処理が行われるようになっています。


Merge pull request #34266 from esquith/improve-no-response-file-wording

.github/no-response.ymlの修正です。

probot/no-responsebotが記載するコメントの言い回しを修正しています。

rails commit log流し読み(2018/10/25)

2018/10/25分のコミットです。

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

activejob/CHANGELOG.md


Merge pull request #34034 from runephilosof/patch-2

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

ActiveSupport::Callbacks moduleのdocに、callbacksは:abortをthrowする事で停止させる事が出来る旨説明を追加しています。


Merge pull request #34303 from kamipo/lazy_checking_boundable

activerecord/lib/active_record/connection_adapters/determine_if_preparable_visitor.rbactiverecord/lib/active_record/relation/predicate_builder/array_handler.rbの修正です。

IN句の値がboundableかどうかのチェックを遅延するよう修正しています。

元々はArrayHandler#callでRelation構築時に行うようになっていました。が、boundableのチェックによりRelation構築時に型の評価が行われるようになってしまい、その影響で既存のコードが壊れる、という問題が発生してしまった為、Relation構築時にチェックを行わないよう修正しています。


Merge pull request #34204 from XrXr/aj-test-helper-args

activejob/lib/active_job/test_helper.rbの修正です。

assert_enqueued_withメソッド、及び、assert_performed_withメソッドが返すjobのインスタンスに、deserializeされた引数を含むよう修正しています。


Deterministic connection collation in tests

activerecord/test/config.example.ymlの修正です。

Active Record + MySQLのテストで使用するconfigでcollationを明示的に指定するよう修正しています。

MySQL 8.0ではutf8mb4 encodingのデフォルトcollationがutf8mb4_0900_ai_ciに変更になっているのですが、テスト内でcollationがutf8mb4_general_ciである事を期待しているテストがある為、MySQL 8.0でテストが通るようにする為に明示的に指定するよう修正しています。


Document deep_interpolation parameter for bulk lookups

rails guideのRails Internationalization (I18n) APIn修正です。

Bulk and Namespace Lookupの項に、bulk lookupでinterpolationを行いたい場合、deep_interpolationオプションを指定する必要がある旨説明を追加しています。

rails commit log流し読み(2018/10/24)

2018/10/24分のコミットです。

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


Fix typo of duplicated the [ci skip]

docの修正です。

theが重複している箇所があったのを修正しています。


Fully remove duplicated upgrade information [ci skip]

rails guideのThe Asset Pipelineの修正です。

Rails 3から4へのupgrade時の注意事項がまだ残っていたのを削除しています。


Merge pull request #34275 from bogdanvlviv/skip_yarn-to-skip_javascript

railtiesの修正です。

generatorのオプションから--skip-yarnオプションを削除しています。代わりに、--skip-javascriptオプションが指定された場合、yarn stub及び関連処理を生成しないよう修正しています。


Do not need to mention the method that is being called in the exception

railties/lib/rails/application/configuration.rbの修正です。

Rails.application.database_configurationメソッドで、database configurationのロードに失敗した場合のエラーメッセージにエラーが発生した箇所のメソッド名(Rails.application.database_configuration)が含まれていたのを削除しています。エラーが発生したメソッド名は必要ではない為。


Merge pull request #34080 from baerjam/add-email-observer-to-guides

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

Observing Emailsの項を追加し、observer処理を追加する場合についての説明を追加しています。


update activestorage attachment model documentation reflect recent behavior changes

activestorage/app/models/active_storage/attachment.rbのdocの修正です。

ActiveStorage::Attachment classのdocにある、同じblobに複数のattachmentsを関連付けた場合の挙動について説明している箇所に、blobがレコードと関連付けられている場合、外部キー制約によりbloblはpurge出来ない旨説明を修正してます。