From 94b4a7afdcda8884d896803ae568dc189885487b Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Tue, 10 Sep 2024 14:26:37 +0900 Subject: [PATCH 1/2] activerecord: Arel::Table.new takes table kwargs since v6.1 (#655) refs: * https://github.com/rails/rails/pull/39881 * https://github.com/rails/rails/blob/v6.1.7.8/activerecord/lib/arel/table.rb#L17 --- gems/activerecord/6.0/activerecord-6.0.rbs | 6 ++++++ gems/activerecord/6.0/activerecord-generated.rbs | 2 -- gems/activerecord/6.1/activerecord-6.1.rbs | 6 ++++++ gems/activerecord/7.0/activerecord-7.0.rbs | 8 +++++++- gems/activerecord/7.1/activerecord-7.1.rbs | 12 +++++++++--- 5 files changed, 28 insertions(+), 6 deletions(-) diff --git a/gems/activerecord/6.0/activerecord-6.0.rbs b/gems/activerecord/6.0/activerecord-6.0.rbs index b4ea946c..7383981a 100644 --- a/gems/activerecord/6.0/activerecord-6.0.rbs +++ b/gems/activerecord/6.0/activerecord-6.0.rbs @@ -52,3 +52,9 @@ module ActiveRecord def initialize: (untyped model, untyped inserts, on_duplicate: untyped, ?unique_by: untyped?, ?returning: untyped?) -> untyped end end + +module Arel + class Table + def initialize: (untyped name, ?type_caster: untyped? type_caster, ?as: untyped? as) -> untyped + end +end diff --git a/gems/activerecord/6.0/activerecord-generated.rbs b/gems/activerecord/6.0/activerecord-generated.rbs index 876f3db5..59921727 100644 --- a/gems/activerecord/6.0/activerecord-generated.rbs +++ b/gems/activerecord/6.0/activerecord-generated.rbs @@ -23508,8 +23508,6 @@ module Arel # TableAlias and Table both have a #table_name which is the name of the underlying table alias table_name name - def initialize: (untyped name, ?type_caster: untyped? type_caster, ?as: untyped? as) -> untyped - def alias: (?::String name) -> Nodes::TableAlias def from: () -> SelectManager diff --git a/gems/activerecord/6.1/activerecord-6.1.rbs b/gems/activerecord/6.1/activerecord-6.1.rbs index abf1bd20..9c15fea7 100644 --- a/gems/activerecord/6.1/activerecord-6.1.rbs +++ b/gems/activerecord/6.1/activerecord-6.1.rbs @@ -60,3 +60,9 @@ module ActiveRecord def initialize: (untyped model, untyped inserts, on_duplicate: untyped, ?unique_by: untyped?, ?returning: untyped?) -> untyped end end + +module Arel + class Table + def initialize: (untyped name, ?type_caster: untyped type_caster, ?as: untyped? as, ?klass: untyped?) -> void + end +end diff --git a/gems/activerecord/7.0/activerecord-7.0.rbs b/gems/activerecord/7.0/activerecord-7.0.rbs index e7d67b77..6d721abc 100644 --- a/gems/activerecord/7.0/activerecord-7.0.rbs +++ b/gems/activerecord/7.0/activerecord-7.0.rbs @@ -89,7 +89,7 @@ module ActiveRecord @record_timestamps: bool def initialize: (untyped model, untyped inserts, on_duplicate: untyped, ?unique_by: untyped?, ?returning: untyped?, ?record_timestamps: bool?) -> untyped - + def record_timestamps?: () -> bool def keys_including_timestamps: () -> Set[String] @@ -97,3 +97,9 @@ module ActiveRecord def timestamps_for_create: () -> Hash[String, String] end end + +module Arel + class Table + def initialize: (untyped name, ?type_caster: untyped type_caster, ?as: untyped? as, ?klass: untyped?) -> void + end +end diff --git a/gems/activerecord/7.1/activerecord-7.1.rbs b/gems/activerecord/7.1/activerecord-7.1.rbs index ca09f305..b0f47e83 100644 --- a/gems/activerecord/7.1/activerecord-7.1.rbs +++ b/gems/activerecord/7.1/activerecord-7.1.rbs @@ -83,8 +83,8 @@ module ActiveRecord class MismatchedForeignKey < StatementInvalid def initialize: (?message: untyped?, ?sql: untyped?, ?binds: untyped?, ?table: untyped?, - ?foreign_key: untyped?, ?target_table: untyped?, ?primary_key: untyped?, - ?primary_key_column: untyped?, ?query_parser: untyped?, + ?foreign_key: untyped?, ?target_table: untyped?, ?primary_key: untyped?, + ?primary_key_column: untyped?, ?query_parser: untyped?, ?connection_pool: ConnectionAdapters::ConnectionPool?) -> void end @@ -110,7 +110,7 @@ module ActiveRecord @record_timestamps: bool def initialize: (untyped model, untyped inserts, on_duplicate: untyped, ?unique_by: untyped?, ?returning: untyped?, ?record_timestamps: bool?) -> untyped - + def record_timestamps?: () -> bool def keys_including_timestamps: () -> Set[String] @@ -118,3 +118,9 @@ module ActiveRecord def timestamps_for_create: () -> Hash[String, String] end end + +module Arel + class Table + def initialize: (untyped name, ?type_caster: untyped type_caster, ?as: untyped? as, ?klass: untyped?) -> void + end +end From 1420c8041d121cb505aa178eda19369e6c4742cb Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Tue, 10 Sep 2024 14:28:14 +0900 Subject: [PATCH 2/2] activerecord: Add missing methods to mixin modules (#653) `#sum` and `#scope` were only added to interfaces, but not to mixin modules. It must be also added to the latter ones. refs: #412, #451 --- gems/activerecord/6.0/activerecord.rbs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gems/activerecord/6.0/activerecord.rbs b/gems/activerecord/6.0/activerecord.rbs index c6ceea3e..27e8d404 100644 --- a/gems/activerecord/6.0/activerecord.rbs +++ b/gems/activerecord/6.0/activerecord.rbs @@ -371,6 +371,7 @@ module ActiveRecord def find_each: (?batch_size: Integer, ?start: Integer, ?finish: Integer, ?error_on_ignore: bool) { (Model) -> void } -> nil def find_in_batches: (?batch_size: Integer, ?start: Integer, ?finish: Integer, ?error_on_ignore: bool) { (Array[Model]) -> void } -> nil def in_batches: (?of: Integer, ?start: Integer, ?finish: Integer, ?load: bool, ?error_on_ignore: bool, ?order: untyped) { (self) -> void } -> nil + def sum: (?untyped? column_name) -> Integer def destroy_all: () -> untyped def delete_all: () -> untyped def update_all: (*untyped) -> untyped @@ -457,6 +458,7 @@ module ActiveRecord def find_each: (?batch_size: Integer, ?start: Integer, ?finish: Integer, ?error_on_ignore: bool) { (Model) -> void } -> nil def find_in_batches: (?batch_size: Integer, ?start: Integer, ?finish: Integer, ?error_on_ignore: bool) { (Array[Model]) -> void } -> nil def in_batches: (?of: Integer, ?start: Integer, ?finish: Integer, ?load: bool, ?error_on_ignore: bool, ?order: untyped) { (Relation) -> void } -> nil + def sum: (?untyped? column_name) -> Integer def destroy_all: () -> untyped def delete_all: () -> untyped def update_all: (*untyped) -> untyped @@ -466,6 +468,7 @@ module ActiveRecord def select: (*Symbol | String) -> Relation | () { (Model) -> boolish } -> Array[Model] def reselect: (*Symbol | String) -> Relation + def scope: (Symbol, ^(*untyped, **untyped) [self: Relation] -> void) ?{ (Module extention) [self: Relation] -> void } -> void end end end