Skip to content

Commit

Permalink
activerecord: Add types for create_with to singleton that inherited a…
Browse files Browse the repository at this point in the history
  • Loading branch information
dak2 committed Jan 5, 2025
1 parent ccbd2bb commit 56a0e85
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions gems/activerecord/6.0/_test/activerecord-generated.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ class Article < ActiveRecord::Base
User.in_order_of(:id, [1, 5, 3])
User.offset(5).limit(10)
User.count
User.create_with(name: 'name', age: 1)
User.create_with(nil)

t = User.arel_table
User.limit(10).select(:id, "name", t[:age].as("years"), t[:email])
2 changes: 2 additions & 0 deletions gems/activerecord/6.0/activerecord.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,7 @@ module ActiveRecord
def count: () -> ::Integer
| () { (Model) -> boolish } -> ::Integer
| (Symbol | String column_name) -> ::Integer
def create_with: (nil | Hash[untyped, untyped]) -> Relation
end
end
end
Expand Down Expand Up @@ -755,6 +756,7 @@ interface _ActiveRecord_Relation_ClassMethods[Model, Relation, PrimaryKey]
def count: () -> ::Integer
| () { (Model) -> boolish } -> ::Integer
| (Symbol | String column_name) -> ::Integer
def create_with: (nil | Hash[untyped, untyped]) -> Relation
end

module Arel
Expand Down
2 changes: 2 additions & 0 deletions gems/activerecord/6.1/_test/activerecord-6.1.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@
User.strict_loading(false)
user.strict_loading!
user.strict_loading?
User.create_with(secret: 'secret', key: 'key')
User.create_with(nil)
2 changes: 2 additions & 0 deletions gems/activerecord/7.0/_test/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class Article < ActiveRecord::Base
User.upsert_all([{ id: 1, name: 'James' }], returning: %i[id name], unique_by: :id, record_timestamps: true)
User.strict_loading
User.strict_loading(false)
User.create_with(name: 'name', age: 1)
User.create_with(nil)
user = User.new(secret: 'dummy', key: 'dummy', token: 'dummy', phrase: 'dummy')
user.encrypt
user.encrypted_attribute?(:secret)
Expand Down
2 changes: 2 additions & 0 deletions gems/activerecord/7.1/_test/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ class Article < ActiveRecord::Base
User.with(admin_users: User.where(role: 0))
User.strict_loading
User.strict_loading(false)
User.create_with(name: 'name', age: 1)
User.create_with(nil)
user = User.new(secret: 'dummy', key: 'dummy', token: 'dummy', phrase: 'dummy')
user.encrypt
user.encrypted_attribute?(:secret)
Expand Down
2 changes: 2 additions & 0 deletions gems/activerecord/7.2/_test/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ class Article < ApplicationRecord
User.with(admin_users: User.where(role: 0))
User.strict_loading
User.strict_loading(false)
User.create_with(name: 'name', age: 1)
User.create_with(nil)
user = User.new(secret: 'dummy', key: 'dummy', token: 'dummy', phrase: 'dummy')
user.encrypt
user.encrypted_attribute?(:secret)
Expand Down

0 comments on commit 56a0e85

Please sign in to comment.