Skip to content

Commit

Permalink
activerecord: Allow to use array of Hashes to #preload
Browse files Browse the repository at this point in the history
  • Loading branch information
tk0miya committed Oct 27, 2024
1 parent 9b308db commit ad5dd9f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion gems/activerecord/6.0/_test/activerecord-generated.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Article < ActiveRecord::Base

User.eager_load(:address, friends: [:address, :followers])
User.includes(:address, :friends).to_a
User.preload(:address, friends: [:address, :followers])
User.preload(:address, friends: [:address, { followers: :users }]) # steep:ignore FallbackAny
User.in_order_of(:id, [1, 5, 3])
User.offset(5).limit(10)

Expand Down
26 changes: 14 additions & 12 deletions gems/activerecord/6.0/activerecord.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,8 @@ module ActiveRecord
end

module QueryMethods
type includee = String | Symbol | Array[includee] | Hash[untyped, untyped]

class WhereChain[Relation]
include ActiveModel::ForbiddenAttributesProtection

Expand Down Expand Up @@ -355,9 +357,9 @@ module ActiveRecord
def joins: (*String | Symbol | Hash[untyped, untyped]) -> self
def left_joins: (*String | Symbol | Hash[untyped, untyped]) -> self
def left_outer_joins: (*String | Symbol | Hash[untyped, untyped]) -> self
def includes: (*String | Symbol | Array[String | Symbol] | Hash[untyped, untyped], **(String | Symbol | Array[String | Symbol] | Hash[untyped, untyped])) -> self
def eager_load: (*String | Symbol | Array[String | Symbol] | Hash[untyped, untyped], **(String | Symbol | Array[String | Symbol] | Hash[untyped, untyped])) -> self
def preload: (*String | Symbol | Array[String | Symbol] | Hash[untyped, untyped], **(String | Symbol | Array[String | Symbol] | Hash[untyped, untyped])) -> self
def includes: (*ActiveRecord::QueryMethods::includee, **ActiveRecord::QueryMethods::includee) -> self
def eager_load: (*ActiveRecord::QueryMethods::includee, **ActiveRecord::QueryMethods::includee) -> self
def preload: (*ActiveRecord::QueryMethods::includee, **ActiveRecord::QueryMethods::includee) -> self
def find_by: (*untyped) -> Model?
def find_by!: (*untyped) -> Model
def find: (PrimaryKey id) -> Model
Expand Down Expand Up @@ -445,9 +447,9 @@ module ActiveRecord
def joins: (*String | Symbol | Hash[untyped, untyped]) -> Relation
def left_joins: (*String | Symbol | Hash[untyped, untyped]) -> Relation
def left_outer_joins: (*String | Symbol | Hash[untyped, untyped]) -> Relation
def includes: (*String | Symbol | Array[String | Symbol] | Hash[untyped, untyped], **(String | Symbol | Array[String | Symbol] | Hash[untyped, untyped])) -> Relation
def eager_load: (*String | Symbol | Array[String | Symbol] | Hash[untyped, untyped], **(String | Symbol | Array[String | Symbol] | Hash[untyped, untyped])) -> Relation
def preload: (*String | Symbol | Array[String | Symbol] | Hash[untyped, untyped], **(String | Symbol | Array[String | Symbol] | Hash[untyped, untyped])) -> Relation
def includes: (*ActiveRecord::QueryMethods::includee, **ActiveRecord::QueryMethods::includee) -> Relation
def eager_load: (*ActiveRecord::QueryMethods::includee, **ActiveRecord::QueryMethods::includee) -> Relation
def preload: (*ActiveRecord::QueryMethods::includee, **ActiveRecord::QueryMethods::includee) -> Relation
def find_by: (*untyped) -> Model?
def find_by!: (*untyped) -> Model
def find: (PrimaryKey id) -> Model
Expand Down Expand Up @@ -525,9 +527,9 @@ interface _ActiveRecord_Relation[Model, PrimaryKey]
def joins: (*String | Symbol | Hash[untyped, untyped]) -> self
def left_joins: (*String | Symbol | Hash[untyped, untyped]) -> self
def left_outer_joins: (*String | Symbol | Hash[untyped, untyped]) -> self
def includes: (*String | Symbol | Array[String | Symbol] | Hash[untyped, untyped], **(String | Symbol | Array[String | Symbol] | Hash[untyped, untyped])) -> self
def eager_load: (*String | Symbol | Array[String | Symbol] | Hash[untyped, untyped], **(String | Symbol | Array[String | Symbol] | Hash[untyped, untyped])) -> self
def preload: (*String | Symbol | Array[String | Symbol] | Hash[untyped, untyped], **(String | Symbol | Array[String | Symbol] | Hash[untyped, untyped])) -> self
def includes: (*ActiveRecord::QueryMethods::includee, **ActiveRecord::QueryMethods::includee) -> self
def eager_load: (*ActiveRecord::QueryMethods::includee, **ActiveRecord::QueryMethods::includee) -> self
def preload: (*ActiveRecord::QueryMethods::includee, **ActiveRecord::QueryMethods::includee) -> self
def find_by: (untyped, *untyped) -> Model?
def find_by!: (untyped, *untyped) -> Model
def find: (PrimaryKey id) -> Model
Expand Down Expand Up @@ -613,9 +615,9 @@ interface _ActiveRecord_Relation_ClassMethods[Model, Relation, PrimaryKey]
def joins: (*String | Symbol | Hash[untyped, untyped]) -> Relation
def left_joins: (*String | Symbol | Hash[untyped, untyped]) -> Relation
def left_outer_joins: (*String | Symbol | Hash[untyped, untyped]) -> Relation
def includes: (*String | Symbol | Array[String | Symbol] | Hash[untyped, untyped], **(String | Symbol | Array[String | Symbol] | Hash[untyped, untyped])) -> Relation
def eager_load: (*String | Symbol | Array[String | Symbol] | Hash[untyped, untyped], **(String | Symbol | Array[String | Symbol] | Hash[untyped, untyped])) -> Relation
def preload: (*String | Symbol | Array[String | Symbol] | Hash[untyped, untyped], **(String | Symbol | Array[String | Symbol] | Hash[untyped, untyped])) -> Relation
def includes: (*ActiveRecord::QueryMethods::includee, **ActiveRecord::QueryMethods::includee) -> Relation
def eager_load: (*ActiveRecord::QueryMethods::includee, **ActiveRecord::QueryMethods::includee) -> Relation
def preload: (*ActiveRecord::QueryMethods::includee, **ActiveRecord::QueryMethods::includee) -> Relation
def find_by: (untyped) -> Model?
def find_by!: (untyped) -> Model
def find: (PrimaryKey id) -> Model
Expand Down

0 comments on commit ad5dd9f

Please sign in to comment.