From 7352af2ce724eb52fe2242acf7593592bb2f7360 Mon Sep 17 00:00:00 2001 From: rhiroe Date: Fri, 30 Jan 2026 10:17:49 +0900 Subject: [PATCH] Change `load_async` return type to `self` Update `load_async` to return `self` instead of the explicit `ActiveRecord::Relation[Model]`. While both represent the same runtime object, RBS treats them as distinct types from `Model::ActiveRecord_Relation` (returned by methods like `where` or `all`). This discrepancy causes type mismatches and forces unnecessary type distinctions during method chaining or when defining signatures. Changing it to `self` ensures consistency with other relation methods. --- gems/activerecord/7.2/activerecord-7.2.rbs | 2 +- gems/activerecord/8.0/activerecord-8.0.rbs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gems/activerecord/7.2/activerecord-7.2.rbs b/gems/activerecord/7.2/activerecord-7.2.rbs index 0cf3d42f..dc84b3ca 100644 --- a/gems/activerecord/7.2/activerecord-7.2.rbs +++ b/gems/activerecord/7.2/activerecord-7.2.rbs @@ -32,7 +32,7 @@ module ActiveRecord def insert_all!: (untyped attributes, ?returning: untyped?, ?record_timestamps: bool?) -> untyped def upsert: (untyped attributes, ?unique_by: untyped?, ?returning: untyped?, ?record_timestamps: bool?) -> untyped def upsert_all: (untyped attributes, ?unique_by: untyped?, ?returning: untyped?, ?record_timestamps: bool?) -> untyped - def load_async: () -> Relation + def load_async: () -> self end module Inheritance diff --git a/gems/activerecord/8.0/activerecord-8.0.rbs b/gems/activerecord/8.0/activerecord-8.0.rbs index 0cf3d42f..dc84b3ca 100644 --- a/gems/activerecord/8.0/activerecord-8.0.rbs +++ b/gems/activerecord/8.0/activerecord-8.0.rbs @@ -32,7 +32,7 @@ module ActiveRecord def insert_all!: (untyped attributes, ?returning: untyped?, ?record_timestamps: bool?) -> untyped def upsert: (untyped attributes, ?unique_by: untyped?, ?returning: untyped?, ?record_timestamps: bool?) -> untyped def upsert_all: (untyped attributes, ?unique_by: untyped?, ?returning: untyped?, ?record_timestamps: bool?) -> untyped - def load_async: () -> Relation + def load_async: () -> self end module Inheritance