Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions gems/activerecord/7.2/_test/activerecord-7.2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,18 @@ class Article < ApplicationRecord
User.order(id: :asc).reorder(id: :desc)

User.all.table_name

user = User.create(name: 'James')
user.articles
User.create(name: 'James') { |user| user.articles }
users = User.create([{name: 'James'}, {name: 'John'}])
users.first.articles
User.create([{name: 'James'}, {name: 'John'}]) { |user| user.articles }

user = User.create!(name: 'James')
user.articles
User.create!(name: 'James') { |user| user.articles }
users = User.create!([{name: 'James'}, {name: 'John'}])
users.first.articles
User.create!([{name: 'James'}, {name: 'John'}]) { |user| user.articles }
end
37 changes: 37 additions & 0 deletions gems/activerecord/7.2/activerecord-7.2.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,43 @@ module ActiveRecord

module Persistence
def previously_persisted?: () -> bool

module ClassMethods
# Creates an object (or multiple objects) and saves it to the database, if validations pass.
# The resulting object is returned whether the object was saved successfully to the database or not.
#
# The +attributes+ parameter can be either a Hash or an Array of Hashes. These Hashes describe the
# attributes on the objects that are to be created.
#
# ==== Examples
# # Create a single new object
# User.create(first_name: 'Jamie')
#
# # Create an Array of new objects
# User.create([{ first_name: 'Jamie' }, { first_name: 'Jeremy' }])
#
# # Create a single object and pass it into a block to set other attributes.
# User.create(first_name: 'Jamie') do |u|
# u.is_admin = false
# end
#
# # Creating an Array of new objects using a block, where the block is executed for each object:
# User.create([{ first_name: 'Jamie' }, { first_name: 'Jeremy' }]) do |u|
# u.is_admin = false
# end
def create: (Array[untyped] attributes) ?{ (instance) -> void } -> Array[instance]
| (?untyped? attributes) ?{ (instance) -> void } -> instance

# Creates an object (or multiple objects) and saves it to the database,
# if validations pass. Raises a RecordInvalid error if validations fail,
# unlike Base#create.
#
# The +attributes+ parameter can be either a Hash or an Array of Hashes.
# These describe which attributes to be created on the object, or
# multiple objects when given an Array of Hashes.
def create!: (Array[untyped] attributes) ?{ (instance) -> void } -> Array[instance]
| (?untyped? attributes) ?{ (instance) -> void } -> instance
end
end

class InsertAll
Expand Down
33 changes: 0 additions & 33 deletions gems/activerecord/7.2/activerecord-generated.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -16121,39 +16121,6 @@ module ActiveRecord
extend ActiveSupport::Concern

module ClassMethods
# Creates an object (or multiple objects) and saves it to the database, if validations pass.
# The resulting object is returned whether the object was saved successfully to the database or not.
#
# The +attributes+ parameter can be either a Hash or an Array of Hashes. These Hashes describe the
# attributes on the objects that are to be created.
#
# ==== Examples
# # Create a single new object
# User.create(first_name: 'Jamie')
#
# # Create an Array of new objects
# User.create([{ first_name: 'Jamie' }, { first_name: 'Jeremy' }])
#
# # Create a single object and pass it into a block to set other attributes.
# User.create(first_name: 'Jamie') do |u|
# u.is_admin = false
# end
#
# # Creating an Array of new objects using a block, where the block is executed for each object:
# User.create([{ first_name: 'Jamie' }, { first_name: 'Jeremy' }]) do |u|
# u.is_admin = false
# end
def create: (?untyped? attributes) ?{ () -> untyped } -> untyped

# Creates an object (or multiple objects) and saves it to the database,
# if validations pass. Raises a RecordInvalid error if validations fail,
# unlike Base#create.
#
# The +attributes+ parameter can be either a Hash or an Array of Hashes.
# These describe which attributes to be created on the object, or
# multiple objects when given an Array of Hashes.
def create!: (?untyped? attributes) ?{ () -> untyped } -> untyped

# Given an attributes hash, +instantiate+ returns a new instance of
# the appropriate class. Accepts only keys as strings.
#
Expand Down
2 changes: 0 additions & 2 deletions gems/activerecord/7.2/activerecord.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ module ActiveRecord
def self.has_one: (Symbol, ?untyped, **untyped) -> void
def self.has_and_belongs_to_many: (untyped name, ?untyped? scope, **untyped options) ?{ () -> untyped } -> untyped
def self.transaction: [T] (?requires_new: boolish, ?isolation: (:read_uncommitted | :read_committed | :repeatable_read | :serializable)?, ?joinable: boolish) { () -> T } -> T
def self.create: (**untyped) -> instance
def self.create!: (**untyped) -> instance
def self.validate: (*untyped, ?if: conditions[instance], ?unless: conditions[instance], **untyped) -> void
def self.validates: (*untyped, ?if: conditions[instance], ?unless: conditions[instance], **untyped) -> void

Expand Down
14 changes: 14 additions & 0 deletions gems/activerecord/8.0/_test/activerecord-8.0.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,18 @@ class Article < ApplicationRecord
User.order(id: :asc).reorder(id: :desc)

User.all.table_name

user = User.create(name: 'James')
user.articles
User.create(name: 'James') { |user| user.articles }
users = User.create([{name: 'James'}, {name: 'John'}])
users.first.articles
User.create([{name: 'James'}, {name: 'John'}]) { |user| user.articles }

user = User.create!(name: 'James')
user.articles
User.create!(name: 'James') { |user| user.articles }
users = User.create!([{name: 'James'}, {name: 'John'}])
users.first.articles
User.create!([{name: 'James'}, {name: 'John'}]) { |user| user.articles }
end
37 changes: 37 additions & 0 deletions gems/activerecord/8.0/activerecord-8.0.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,43 @@ module ActiveRecord

module Persistence
def previously_persisted?: () -> bool

module ClassMethods
# Creates an object (or multiple objects) and saves it to the database, if validations pass.
# The resulting object is returned whether the object was saved successfully to the database or not.
#
# The +attributes+ parameter can be either a Hash or an Array of Hashes. These Hashes describe the
# attributes on the objects that are to be created.
#
# ==== Examples
# # Create a single new object
# User.create(first_name: 'Jamie')
#
# # Create an Array of new objects
# User.create([{ first_name: 'Jamie' }, { first_name: 'Jeremy' }])
#
# # Create a single object and pass it into a block to set other attributes.
# User.create(first_name: 'Jamie') do |u|
# u.is_admin = false
# end
#
# # Creating an Array of new objects using a block, where the block is executed for each object:
# User.create([{ first_name: 'Jamie' }, { first_name: 'Jeremy' }]) do |u|
# u.is_admin = false
# end
def create: (Array[untyped] attributes) ?{ (instance) -> void } -> Array[instance]
| (?untyped? attributes) ?{ (instance) -> void } -> instance

# Creates an object (or multiple objects) and saves it to the database,
# if validations pass. Raises a RecordInvalid error if validations fail,
# unlike Base#create.
#
# The +attributes+ parameter can be either a Hash or an Array of Hashes.
# These describe which attributes to be created on the object, or
# multiple objects when given an Array of Hashes.
def create!: (Array[untyped] attributes) ?{ (instance) -> void } -> Array[instance]
| (?untyped? attributes) ?{ (instance) -> void } -> instance
end
end

class InsertAll
Expand Down
33 changes: 0 additions & 33 deletions gems/activerecord/8.0/activerecord-generated.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -16121,39 +16121,6 @@ module ActiveRecord
extend ActiveSupport::Concern

module ClassMethods
# Creates an object (or multiple objects) and saves it to the database, if validations pass.
# The resulting object is returned whether the object was saved successfully to the database or not.
#
# The +attributes+ parameter can be either a Hash or an Array of Hashes. These Hashes describe the
# attributes on the objects that are to be created.
#
# ==== Examples
# # Create a single new object
# User.create(first_name: 'Jamie')
#
# # Create an Array of new objects
# User.create([{ first_name: 'Jamie' }, { first_name: 'Jeremy' }])
#
# # Create a single object and pass it into a block to set other attributes.
# User.create(first_name: 'Jamie') do |u|
# u.is_admin = false
# end
#
# # Creating an Array of new objects using a block, where the block is executed for each object:
# User.create([{ first_name: 'Jamie' }, { first_name: 'Jeremy' }]) do |u|
# u.is_admin = false
# end
def create: (?untyped? attributes) ?{ () -> untyped } -> untyped

# Creates an object (or multiple objects) and saves it to the database,
# if validations pass. Raises a RecordInvalid error if validations fail,
# unlike Base#create.
#
# The +attributes+ parameter can be either a Hash or an Array of Hashes.
# These describe which attributes to be created on the object, or
# multiple objects when given an Array of Hashes.
def create!: (?untyped? attributes) ?{ () -> untyped } -> untyped

# Given an attributes hash, +instantiate+ returns a new instance of
# the appropriate class. Accepts only keys as strings.
#
Expand Down
2 changes: 0 additions & 2 deletions gems/activerecord/8.0/activerecord.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ module ActiveRecord
def self.has_one: (Symbol, ?untyped, **untyped) -> void
def self.has_and_belongs_to_many: (untyped name, ?untyped? scope, **untyped options) ?{ () -> untyped } -> untyped
def self.transaction: [T] (?requires_new: boolish, ?isolation: (:read_uncommitted | :read_committed | :repeatable_read | :serializable)?, ?joinable: boolish) { () -> T } -> T
def self.create: (**untyped) -> instance
def self.create!: (**untyped) -> instance
def self.validate: (*untyped, ?if: conditions[instance], ?unless: conditions[instance], **untyped) -> void
def self.validates: (*untyped, ?if: conditions[instance], ?unless: conditions[instance], **untyped) -> void

Expand Down