activerecord 7.0.7.2 → 7.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of activerecord might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +59 -0
- data/lib/active_record/associations/collection_association.rb +1 -1
- data/lib/active_record/associations/collection_proxy.rb +5 -0
- data/lib/active_record/connection_adapters/mysql/database_statements.rb +1 -1
- data/lib/active_record/connection_adapters/sqlite3/schema_definitions.rb +6 -0
- data/lib/active_record/connection_adapters/sqlite3_adapter.rb +1 -4
- data/lib/active_record/gem_version.rb +2 -2
- data/lib/active_record/migration/compatibility.rb +12 -54
- data/lib/active_record/migration.rb +52 -3
- data/lib/active_record/table_metadata.rb +1 -1
- data/lib/arel/nodes/and.rb +4 -0
- metadata +10 -10
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: e993cf4751bc4f76be3f2a5aebe08051098416f154777a46e6056e6db5d7fe22
         | 
| 4 | 
            +
              data.tar.gz: fbe2892c8c8a7a14a41ae50f2a44615f045441538329980b7edddd5a66dee912
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 12e8c4a4c66a576c3abac30a03fbea7cd9830d259681daafddf93506a88ac6887375b8b6bbe3dd1c71faabfbd169d4f015e46e770db326300993a925eca00b20
         | 
| 7 | 
            +
              data.tar.gz: fd42f935a2b4edc536aa8bfe10e9368fda646b54374f6c336fee3b248ab77323fd7495a4c10c9dfef0173850cc0f5a604ff7417e5b2ecc2332b946ecb6d0f0db
         | 
    
        data/CHANGELOG.md
    CHANGED
    
    | @@ -1,3 +1,62 @@ | |
| 1 | 
            +
            ## Rails 7.0.8 (September 09, 2023) ##
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            *   Fix `change_column` not setting `precision: 6` on `datetime` columns when
         | 
| 4 | 
            +
                using 7.0+ Migrations and SQLite.
         | 
| 5 | 
            +
             | 
| 6 | 
            +
                *Hartley McGuire*
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            *   Fix unscope is not working in specific case
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                Before:
         | 
| 11 | 
            +
                ```ruby
         | 
| 12 | 
            +
                Post.where(id: 1...3).unscope(where: :id).to_sql # "SELECT `posts`.* FROM `posts` WHERE `posts`.`id` >= 1 AND `posts`.`id` < 3"
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                ```
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                After:
         | 
| 17 | 
            +
                ```ruby
         | 
| 18 | 
            +
                Post.where(id: 1...3).unscope(where: :id).to_sql # "SELECT `posts`.* FROM `posts`"
         | 
| 19 | 
            +
                ```
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                Fixes #48094.
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                *Kazuya Hatanaka*
         | 
| 24 | 
            +
             | 
| 25 | 
            +
            *   Fix associations to a STI model including a `class_name` parameter
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                ```ruby
         | 
| 28 | 
            +
                class Product < ApplicationRecord
         | 
| 29 | 
            +
                  has_many :requests, as: :requestable, class_name: "ProductRequest", dependent: :destroy
         | 
| 30 | 
            +
                end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                # STI tables
         | 
| 33 | 
            +
                class Request < ApplicationRecord
         | 
| 34 | 
            +
                  belongs_to :requestable, polymorphic: true
         | 
| 35 | 
            +
             | 
| 36 | 
            +
                  validate :request_type, presence: true
         | 
| 37 | 
            +
                end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                class ProductRequest < Request
         | 
| 40 | 
            +
                  belongs_to :user
         | 
| 41 | 
            +
                end
         | 
| 42 | 
            +
                ```
         | 
| 43 | 
            +
             | 
| 44 | 
            +
                Accessing such association would lead to:
         | 
| 45 | 
            +
             | 
| 46 | 
            +
                ```
         | 
| 47 | 
            +
                table_metadata.rb:22:in `has_column?': undefined method `key?' for nil:NilClass (NoMethodError)
         | 
| 48 | 
            +
                ```
         | 
| 49 | 
            +
             | 
| 50 | 
            +
                *Romain Filinto*
         | 
| 51 | 
            +
             | 
| 52 | 
            +
            *   Fix `change_table` setting datetime precision for 6.1 Migrations
         | 
| 53 | 
            +
             | 
| 54 | 
            +
                *Hartley McGuire*
         | 
| 55 | 
            +
             | 
| 56 | 
            +
            *   Fix change_column setting datetime precision for 6.1 Migrations
         | 
| 57 | 
            +
             | 
| 58 | 
            +
                *Hartley McGuire*
         | 
| 59 | 
            +
             | 
| 1 60 | 
             
            ## Rails 7.0.7.2 (August 22, 2023) ##
         | 
| 2 61 |  | 
| 3 62 | 
             
            *   No changes.
         | 
| @@ -4,6 +4,12 @@ module ActiveRecord | |
| 4 4 | 
             
              module ConnectionAdapters
         | 
| 5 5 | 
             
                module SQLite3
         | 
| 6 6 | 
             
                  class TableDefinition < ActiveRecord::ConnectionAdapters::TableDefinition
         | 
| 7 | 
            +
                    def change_column(column_name, type, **options)
         | 
| 8 | 
            +
                      name = column_name.to_s
         | 
| 9 | 
            +
                      @columns_hash[name] = nil
         | 
| 10 | 
            +
                      column(name, type, **options)
         | 
| 11 | 
            +
                    end
         | 
| 12 | 
            +
             | 
| 7 13 | 
             
                    def references(*args, **options)
         | 
| 8 14 | 
             
                      super(*args, type: :integer, **options)
         | 
| 9 15 | 
             
                    end
         | 
| @@ -287,10 +287,7 @@ module ActiveRecord | |
| 287 287 |  | 
| 288 288 | 
             
                  def change_column(table_name, column_name, type, **options) # :nodoc:
         | 
| 289 289 | 
             
                    alter_table(table_name) do |definition|
         | 
| 290 | 
            -
                      definition | 
| 291 | 
            -
                        self.type = aliased_types(type.to_s, type)
         | 
| 292 | 
            -
                        self.options.merge!(options)
         | 
| 293 | 
            -
                      end
         | 
| 290 | 
            +
                      definition.change_column(column_name, type, **options)
         | 
| 294 291 | 
             
                    end
         | 
| 295 292 | 
             
                  end
         | 
| 296 293 |  | 
| @@ -56,12 +56,13 @@ module ActiveRecord | |
| 56 56 | 
             
                      super
         | 
| 57 57 | 
             
                    end
         | 
| 58 58 |  | 
| 59 | 
            -
                    def  | 
| 60 | 
            -
                      if  | 
| 61 | 
            -
                         | 
| 62 | 
            -
                      else
         | 
| 63 | 
            -
                        super
         | 
| 59 | 
            +
                    def change_column(table_name, column_name, type, **options)
         | 
| 60 | 
            +
                      if type == :datetime
         | 
| 61 | 
            +
                        options[:precision] ||= nil
         | 
| 64 62 | 
             
                      end
         | 
| 63 | 
            +
             | 
| 64 | 
            +
                      type = PostgreSQLCompat.compatible_timestamp_type(type, connection)
         | 
| 65 | 
            +
                      super
         | 
| 65 66 | 
             
                    end
         | 
| 66 67 |  | 
| 67 68 | 
             
                    module TableDefinition
         | 
| @@ -70,6 +71,11 @@ module ActiveRecord | |
| 70 71 | 
             
                        super
         | 
| 71 72 | 
             
                      end
         | 
| 72 73 |  | 
| 74 | 
            +
                      def change(name, type, index: nil, **options)
         | 
| 75 | 
            +
                        options[:precision] ||= nil
         | 
| 76 | 
            +
                        super
         | 
| 77 | 
            +
                      end
         | 
| 78 | 
            +
             | 
| 73 79 | 
             
                      def column(name, type, index: nil, **options)
         | 
| 74 80 | 
             
                        options[:precision] ||= nil
         | 
| 75 81 | 
             
                        super
         | 
| @@ -81,7 +87,7 @@ module ActiveRecord | |
| 81 87 | 
             
                        class << t
         | 
| 82 88 | 
             
                          prepend TableDefinition
         | 
| 83 89 | 
             
                        end
         | 
| 84 | 
            -
                         | 
| 90 | 
            +
                        super
         | 
| 85 91 | 
             
                      end
         | 
| 86 92 | 
             
                  end
         | 
| 87 93 |  | 
| @@ -105,30 +111,6 @@ module ActiveRecord | |
| 105 111 | 
             
                      end
         | 
| 106 112 | 
             
                    end
         | 
| 107 113 |  | 
| 108 | 
            -
                    def create_table(table_name, **options)
         | 
| 109 | 
            -
                      if block_given?
         | 
| 110 | 
            -
                        super { |t| yield compatible_table_definition(t) }
         | 
| 111 | 
            -
                      else
         | 
| 112 | 
            -
                        super
         | 
| 113 | 
            -
                      end
         | 
| 114 | 
            -
                    end
         | 
| 115 | 
            -
             | 
| 116 | 
            -
                    def change_table(table_name, **options)
         | 
| 117 | 
            -
                      if block_given?
         | 
| 118 | 
            -
                        super { |t| yield compatible_table_definition(t) }
         | 
| 119 | 
            -
                      else
         | 
| 120 | 
            -
                        super
         | 
| 121 | 
            -
                      end
         | 
| 122 | 
            -
                    end
         | 
| 123 | 
            -
             | 
| 124 | 
            -
                    def create_join_table(table_1, table_2, **options)
         | 
| 125 | 
            -
                      if block_given?
         | 
| 126 | 
            -
                        super { |t| yield compatible_table_definition(t) }
         | 
| 127 | 
            -
                      else
         | 
| 128 | 
            -
                        super
         | 
| 129 | 
            -
                      end
         | 
| 130 | 
            -
                    end
         | 
| 131 | 
            -
             | 
| 132 114 | 
             
                    def add_reference(table_name, ref_name, **options)
         | 
| 133 115 | 
             
                      if connection.adapter_name == "SQLite"
         | 
| 134 116 | 
             
                        options[:type] = :integer
         | 
| @@ -182,30 +164,6 @@ module ActiveRecord | |
| 182 164 | 
             
                      end
         | 
| 183 165 | 
             
                    end
         | 
| 184 166 |  | 
| 185 | 
            -
                    def create_table(table_name, **options)
         | 
| 186 | 
            -
                      if block_given?
         | 
| 187 | 
            -
                        super { |t| yield compatible_table_definition(t) }
         | 
| 188 | 
            -
                      else
         | 
| 189 | 
            -
                        super
         | 
| 190 | 
            -
                      end
         | 
| 191 | 
            -
                    end
         | 
| 192 | 
            -
             | 
| 193 | 
            -
                    def change_table(table_name, **options)
         | 
| 194 | 
            -
                      if block_given?
         | 
| 195 | 
            -
                        super { |t| yield compatible_table_definition(t) }
         | 
| 196 | 
            -
                      else
         | 
| 197 | 
            -
                        super
         | 
| 198 | 
            -
                      end
         | 
| 199 | 
            -
                    end
         | 
| 200 | 
            -
             | 
| 201 | 
            -
                    def create_join_table(table_1, table_2, **options)
         | 
| 202 | 
            -
                      if block_given?
         | 
| 203 | 
            -
                        super { |t| yield compatible_table_definition(t) }
         | 
| 204 | 
            -
                      else
         | 
| 205 | 
            -
                        super
         | 
| 206 | 
            -
                      end
         | 
| 207 | 
            -
                    end
         | 
| 208 | 
            -
             | 
| 209 167 | 
             
                    def add_timestamps(table_name, **options)
         | 
| 210 168 | 
             
                      options[:precision] ||= nil
         | 
| 211 169 | 
             
                      super
         | 
| @@ -551,6 +551,41 @@ module ActiveRecord | |
| 551 551 |  | 
| 552 552 | 
             
                # This must be defined before the inherited hook, below
         | 
| 553 553 | 
             
                class Current < Migration # :nodoc:
         | 
| 554 | 
            +
                  def create_table(table_name, **options)
         | 
| 555 | 
            +
                    if block_given?
         | 
| 556 | 
            +
                      super { |t| yield compatible_table_definition(t) }
         | 
| 557 | 
            +
                    else
         | 
| 558 | 
            +
                      super
         | 
| 559 | 
            +
                    end
         | 
| 560 | 
            +
                  end
         | 
| 561 | 
            +
             | 
| 562 | 
            +
                  def change_table(table_name, **options)
         | 
| 563 | 
            +
                    if block_given?
         | 
| 564 | 
            +
                      super { |t| yield compatible_table_definition(t) }
         | 
| 565 | 
            +
                    else
         | 
| 566 | 
            +
                      super
         | 
| 567 | 
            +
                    end
         | 
| 568 | 
            +
                  end
         | 
| 569 | 
            +
             | 
| 570 | 
            +
                  def create_join_table(table_1, table_2, **options)
         | 
| 571 | 
            +
                    if block_given?
         | 
| 572 | 
            +
                      super { |t| yield compatible_table_definition(t) }
         | 
| 573 | 
            +
                    else
         | 
| 574 | 
            +
                      super
         | 
| 575 | 
            +
                    end
         | 
| 576 | 
            +
                  end
         | 
| 577 | 
            +
             | 
| 578 | 
            +
                  def drop_table(table_name, **options)
         | 
| 579 | 
            +
                    if block_given?
         | 
| 580 | 
            +
                      super { |t| yield compatible_table_definition(t) }
         | 
| 581 | 
            +
                    else
         | 
| 582 | 
            +
                      super
         | 
| 583 | 
            +
                    end
         | 
| 584 | 
            +
                  end
         | 
| 585 | 
            +
             | 
| 586 | 
            +
                  def compatible_table_definition(t)
         | 
| 587 | 
            +
                    t
         | 
| 588 | 
            +
                  end
         | 
| 554 589 | 
             
                end
         | 
| 555 590 |  | 
| 556 591 | 
             
                def self.inherited(subclass) # :nodoc:
         | 
| @@ -916,9 +951,7 @@ module ActiveRecord | |
| 916 951 | 
             
                end
         | 
| 917 952 |  | 
| 918 953 | 
             
                def method_missing(method, *arguments, &block)
         | 
| 919 | 
            -
                   | 
| 920 | 
            -
             | 
| 921 | 
            -
                  say_with_time "#{method}(#{arg_list})" do
         | 
| 954 | 
            +
                  say_with_time "#{method}(#{format_arguments(arguments)})" do
         | 
| 922 955 | 
             
                    unless connection.respond_to? :revert
         | 
| 923 956 | 
             
                      unless arguments.empty? || [:execute, :enable_extension, :disable_extension].include?(method)
         | 
| 924 957 | 
             
                        arguments[0] = proper_table_name(arguments.first, table_name_options)
         | 
| @@ -1026,6 +1059,22 @@ module ActiveRecord | |
| 1026 1059 | 
             
                    end
         | 
| 1027 1060 | 
             
                  end
         | 
| 1028 1061 |  | 
| 1062 | 
            +
                  def format_arguments(arguments)
         | 
| 1063 | 
            +
                    arg_list = arguments[0...-1].map(&:inspect)
         | 
| 1064 | 
            +
                    last_arg = arguments.last
         | 
| 1065 | 
            +
                    if last_arg.is_a?(Hash)
         | 
| 1066 | 
            +
                      last_arg = last_arg.reject { |k, _v| internal_option?(k) }
         | 
| 1067 | 
            +
                      arg_list << last_arg.inspect unless last_arg.empty?
         | 
| 1068 | 
            +
                    else
         | 
| 1069 | 
            +
                      arg_list << last_arg.inspect
         | 
| 1070 | 
            +
                    end
         | 
| 1071 | 
            +
                    arg_list.join(", ")
         | 
| 1072 | 
            +
                  end
         | 
| 1073 | 
            +
             | 
| 1074 | 
            +
                  def internal_option?(option_name)
         | 
| 1075 | 
            +
                    option_name.start_with?("_")
         | 
| 1076 | 
            +
                  end
         | 
| 1077 | 
            +
             | 
| 1029 1078 | 
             
                  def command_recorder
         | 
| 1030 1079 | 
             
                    CommandRecorder.new(connection)
         | 
| 1031 1080 | 
             
                  end
         | 
    
        data/lib/arel/nodes/and.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: activerecord
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 7.0. | 
| 4 | 
            +
              version: 7.0.8
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - David Heinemeier Hansson
         | 
| 8 8 | 
             
            autorequire:
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2023- | 
| 11 | 
            +
            date: 2023-09-09 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: activesupport
         | 
| @@ -16,28 +16,28 @@ dependencies: | |
| 16 16 | 
             
                requirements:
         | 
| 17 17 | 
             
                - - '='
         | 
| 18 18 | 
             
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            -
                    version: 7.0. | 
| 19 | 
            +
                    version: 7.0.8
         | 
| 20 20 | 
             
              type: :runtime
         | 
| 21 21 | 
             
              prerelease: false
         | 
| 22 22 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 23 | 
             
                requirements:
         | 
| 24 24 | 
             
                - - '='
         | 
| 25 25 | 
             
                  - !ruby/object:Gem::Version
         | 
| 26 | 
            -
                    version: 7.0. | 
| 26 | 
            +
                    version: 7.0.8
         | 
| 27 27 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 28 28 | 
             
              name: activemodel
         | 
| 29 29 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 30 30 | 
             
                requirements:
         | 
| 31 31 | 
             
                - - '='
         | 
| 32 32 | 
             
                  - !ruby/object:Gem::Version
         | 
| 33 | 
            -
                    version: 7.0. | 
| 33 | 
            +
                    version: 7.0.8
         | 
| 34 34 | 
             
              type: :runtime
         | 
| 35 35 | 
             
              prerelease: false
         | 
| 36 36 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 37 37 | 
             
                requirements:
         | 
| 38 38 | 
             
                - - '='
         | 
| 39 39 | 
             
                  - !ruby/object:Gem::Version
         | 
| 40 | 
            -
                    version: 7.0. | 
| 40 | 
            +
                    version: 7.0.8
         | 
| 41 41 | 
             
            description: Databases on Rails. Build a persistent domain model by mapping database
         | 
| 42 42 | 
             
              tables to Ruby classes. Strong conventions for associations, validations, aggregations,
         | 
| 43 43 | 
             
              migrations, and testing come baked-in.
         | 
| @@ -434,10 +434,10 @@ licenses: | |
| 434 434 | 
             
            - MIT
         | 
| 435 435 | 
             
            metadata:
         | 
| 436 436 | 
             
              bug_tracker_uri: https://github.com/rails/rails/issues
         | 
| 437 | 
            -
              changelog_uri: https://github.com/rails/rails/blob/v7.0. | 
| 438 | 
            -
              documentation_uri: https://api.rubyonrails.org/v7.0. | 
| 437 | 
            +
              changelog_uri: https://github.com/rails/rails/blob/v7.0.8/activerecord/CHANGELOG.md
         | 
| 438 | 
            +
              documentation_uri: https://api.rubyonrails.org/v7.0.8/
         | 
| 439 439 | 
             
              mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
         | 
| 440 | 
            -
              source_code_uri: https://github.com/rails/rails/tree/v7.0. | 
| 440 | 
            +
              source_code_uri: https://github.com/rails/rails/tree/v7.0.8/activerecord
         | 
| 441 441 | 
             
              rubygems_mfa_required: 'true'
         | 
| 442 442 | 
             
            post_install_message:
         | 
| 443 443 | 
             
            rdoc_options:
         | 
| @@ -456,7 +456,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 456 456 | 
             
                - !ruby/object:Gem::Version
         | 
| 457 457 | 
             
                  version: '0'
         | 
| 458 458 | 
             
            requirements: []
         | 
| 459 | 
            -
            rubygems_version: 3. | 
| 459 | 
            +
            rubygems_version: 3.4.18
         | 
| 460 460 | 
             
            signing_key:
         | 
| 461 461 | 
             
            specification_version: 4
         | 
| 462 462 | 
             
            summary: Object-relational mapper framework (part of Rails).
         |