diff --git a/gems/activerecord/7.2/_test/test.rb b/gems/activerecord/7.2/_test/test.rb index c4533a8e..cb46fb9f 100644 --- a/gems/activerecord/7.2/_test/test.rb +++ b/gems/activerecord/7.2/_test/test.rb @@ -9,6 +9,9 @@ class ApplicationRecord < ActiveRecord::Base end class User < ApplicationRecord + # @dynamic articles + has_many :articles + enum status: { active: 0, inactive: 1 }, _suffix: true enum :role, { admin: 0, user: 1 }, _prefix: true enum :classify, %w[hoge fuga], _default: "hoge" @@ -24,6 +27,9 @@ class User < ApplicationRecord } end + class Article < ApplicationRecord + end + User.where.missing.to_sql User.deterministic_encrypted_attributes User.source_attribute_from_preserved_attribute(:phrase) @@ -38,6 +44,12 @@ class User < ApplicationRecord user.encrypted_attribute?(:secret) user.decrypt user.ciphertext_for(:token) + user.articles.insert({ id: 1, name: 'James' }, returning: %i[id name], unique_by: :id, record_timestamps: true) + user.articles.insert!({ id: 1, name: 'James' }, returning: %i[id name], record_timestamps: true) + user.articles.insert_all([{ id: 1, name: 'James' }], returning: %i[id name], unique_by: :id, record_timestamps: true) + user.articles.insert_all!([{ id: 1, name: 'James' }], returning: %i[id name], record_timestamps: true) + user.articles.upsert({ id: 1, name: 'James' }, returning: %i[id name], unique_by: :id, record_timestamps: true) + user.articles.upsert_all([{ id: 1, name: 'James' }], returning: %i[id name], unique_by: :id, record_timestamps: true) user = User.new user.normalize_attribute(:email) diff --git a/gems/activerecord/7.2/_test/test.rbs b/gems/activerecord/7.2/_test/test.rbs index 5b1ebf57..3379f461 100644 --- a/gems/activerecord/7.2/_test/test.rbs +++ b/gems/activerecord/7.2/_test/test.rbs @@ -7,5 +7,18 @@ module Test class ActiveRecord_Relation < ::ActiveRecord::Relation end + + def articles: () -> Article::ActiveRecord_Associations_CollectionProxy + end + + class Article < ApplicationRecord + extend ::ActiveRecord::Base::ClassMethods[Article, ActiveRecord_Relation, Integer] + + class ActiveRecord_Relation < ::ActiveRecord::Relation + end + + class ActiveRecord_Associations_CollectionProxy < ::ActiveRecord::Associations::CollectionProxy + include ::ActiveRecord::Relation::Methods[Article, Integer] + end end end diff --git a/gems/activerecord/7.2/activerecord-7.2.rbs b/gems/activerecord/7.2/activerecord-7.2.rbs index ca09f305..1c18c486 100644 --- a/gems/activerecord/7.2/activerecord-7.2.rbs +++ b/gems/activerecord/7.2/activerecord-7.2.rbs @@ -6,6 +6,15 @@ module ActiveRecord extend Normalization::ClassMethods end + class Relation + def insert: (untyped attributes, ?unique_by: untyped?, ?returning: untyped?, ?record_timestamps: bool?) -> untyped + def insert_all: (untyped attributes, ?unique_by: untyped?, ?returning: untyped?, ?record_timestamps: bool?) -> untyped + def insert!: (untyped attributes, ?returning: untyped?, ?record_timestamps: bool?) -> untyped + 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 + end + module Inheritance module ClassMethods def primary_abstract_class: () -> void @@ -83,34 +92,30 @@ 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 - module Persistence - extend ActiveSupport::Concern - - module ClassMethods - def insert: (untyped attributes, ?unique_by: untyped?, ?returning: untyped?, ?record_timestamps: bool?) -> untyped + module Querying + def insert: (untyped attributes, ?unique_by: untyped?, ?returning: untyped?, ?record_timestamps: bool?) -> untyped - def insert_all: (untyped attributes, ?unique_by: untyped?, ?returning: untyped?, ?record_timestamps: bool?) -> untyped + def insert_all: (untyped attributes, ?unique_by: untyped?, ?returning: untyped?, ?record_timestamps: bool?) -> untyped - def insert!: (untyped attributes, ?returning: untyped?, ?record_timestamps: bool?) -> untyped + def insert!: (untyped attributes, ?returning: untyped?, ?record_timestamps: bool?) -> untyped - def insert_all!: (untyped attributes, ?returning: untyped?, ?record_timestamps: bool?) -> untyped + 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: (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 - end + def upsert_all: (untyped attributes, ?unique_by: untyped?, ?returning: untyped?, ?record_timestamps: bool?) -> untyped end class InsertAll @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]