なるようになるブログ

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

rails commit log流し読み(2023/06/21)

2023/06/21分のコミットです。

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

activerecord/CHANGELOG.md


Move trilogy config closer to mysql2

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

Trilogy adapterに関する設定をmysql2 adapterの設定の近くに移動しています。


Update devcontainer.json to use Shopify.ruby-lsp extension

.devcontainer/devcontainer.jsonの修正です。

vscodeのextensionにShopify.ruby-lspを追加しています。


Fix devcontainer trilogy connection for tests

.devcontainer/devcontainer.jsonの修正です。

devcontainerでTrilogyのテストが通るようMYSQL_SOCKの設定を追加しています。


Revert "Merge pull request #48527 from ghiculescu/active-record-enum-id"

enumのkeyにprimary keyに指定しているattribute名を使用出来ないよう修正した、Disallow `id` as an enum value in Active RecordをRevertしています。この変更によりrailtiesのテストがコケるようになってしまった為。


Merge pull request #48487 from lazaronixon/scope-subqueries

activerecord/lib/active_record/relation/predicate_builder/association_query_value.rbactiverecord/lib/active_record/table_metadata.rbの修正です。

associationのsubqueriesにscopeを適応するよう修正しています。

class Author < ApplicationRecord
  has_many :welcome_posts, -> { where(title: "welcome") }
end

Before:

Author.where(welcome_posts: Post.all)
#=> SELECT (...) WHERE "authors"."id" IN (SELECT "posts"."author_id" FROM "posts")

After:

Author.where(welcome_posts: Post.all)
#=> SELECT (...) WHERE "authors"."id" IN (SELECT "posts"."author_id" FROM "posts" WHERE "posts"."title" = 'welcome')

Revert "Revert "Merge pull request #48527 from ghiculescu/active-record-enum-id""

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

enumのkeyにidという値を使用出来ないよう修正しています。enumidメソッドが定義されてしまうと予期せぬ挙動になることがある為。Disallow `id` as an enum value in Active Recordのリトライ。


Fix the name of delegated method for the records to Array#intersect?

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

intersect?intersects?にタイポしていたのを修正しています。


Merge pull request #48526 from ghiculescu/active-job-docs

rails guideのTesting Rails Applicationsの修正です。

Active Job のテストについて説明している箇所で、enqueueされたjobが実行される旨説明が記載されていたのですが、実際は実行はされる事は無いため、該当の説明を修正、及び、テストでenqueueしたjobを実行する方法についての説明を追加しています。


Test delegation of Relation to Array#intersect? only in Ruby >= 3.1.0

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

Ruby 3.1.0で追加されたArray#intersect?を使用するテストを、Ruby 3.1.0以上でのみ実行するよう修正しています。


Merge pull request #48471 from mdh/improve-naming-of-local-secret-generation

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

local environments (developmentとtest)で使用するsecretを生成するメソッド名、ファイル名がdevelopment_secretになっていたのをlocal_secretに変更しています。testでも使用する処理のため、localの方が適切だろう、という事で修正されています。


Fix a typo in CHANGELOG.md

activerecord/CHANGELOG.mdの修正です。

Array#intersect? -> Array#intersects?に修正しています。しかしこれは元の値(Array#intersect?)が正しいです。