sequel 5.32.0 → 5.37.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG +84 -0
- data/README.rdoc +1 -1
- data/doc/association_basics.rdoc +7 -2
- data/doc/dataset_filtering.rdoc +2 -2
- data/doc/model_plugins.rdoc +1 -1
- data/doc/release_notes/5.33.0.txt +24 -0
- data/doc/release_notes/5.34.0.txt +40 -0
- data/doc/release_notes/5.35.0.txt +56 -0
- data/doc/release_notes/5.36.0.txt +60 -0
- data/doc/release_notes/5.37.0.txt +30 -0
- data/doc/transactions.rdoc +0 -8
- data/doc/validations.rdoc +1 -1
- data/lib/sequel/adapters/odbc.rb +4 -6
- data/lib/sequel/adapters/oracle.rb +2 -1
- data/lib/sequel/adapters/shared/mssql.rb +14 -4
- data/lib/sequel/adapters/shared/oracle.rb +12 -6
- data/lib/sequel/adapters/shared/postgres.rb +39 -1
- data/lib/sequel/adapters/shared/sqlite.rb +13 -3
- data/lib/sequel/adapters/tinytds.rb +1 -0
- data/lib/sequel/adapters/utils/mysql_mysql2.rb +1 -0
- data/lib/sequel/connection_pool/sharded_single.rb +4 -1
- data/lib/sequel/connection_pool/sharded_threaded.rb +10 -10
- data/lib/sequel/connection_pool/single.rb +1 -1
- data/lib/sequel/connection_pool/threaded.rb +1 -1
- data/lib/sequel/core.rb +5 -6
- data/lib/sequel/database/connecting.rb +1 -1
- data/lib/sequel/database/misc.rb +16 -10
- data/lib/sequel/database/query.rb +2 -0
- data/lib/sequel/database/schema_generator.rb +0 -1
- data/lib/sequel/database/schema_methods.rb +15 -16
- data/lib/sequel/database/transactions.rb +8 -5
- data/lib/sequel/dataset/actions.rb +10 -6
- data/lib/sequel/dataset/placeholder_literalizer.rb +3 -7
- data/lib/sequel/dataset/query.rb +5 -4
- data/lib/sequel/deprecated.rb +3 -1
- data/lib/sequel/exceptions.rb +2 -0
- data/lib/sequel/extensions/_pretty_table.rb +1 -2
- data/lib/sequel/extensions/columns_introspection.rb +1 -2
- data/lib/sequel/extensions/core_refinements.rb +2 -0
- data/lib/sequel/extensions/duplicate_columns_handler.rb +2 -0
- data/lib/sequel/extensions/migration.rb +8 -2
- data/lib/sequel/extensions/pg_array_ops.rb +4 -0
- data/lib/sequel/extensions/pg_enum.rb +2 -0
- data/lib/sequel/extensions/pg_extended_date_support.rb +1 -1
- data/lib/sequel/extensions/pg_hstore_ops.rb +2 -0
- data/lib/sequel/extensions/pg_inet.rb +2 -0
- data/lib/sequel/extensions/pg_json_ops.rb +46 -2
- data/lib/sequel/extensions/pg_range.rb +3 -7
- data/lib/sequel/extensions/pg_range_ops.rb +2 -0
- data/lib/sequel/extensions/pg_row.rb +0 -1
- data/lib/sequel/extensions/pg_row_ops.rb +24 -0
- data/lib/sequel/extensions/query.rb +1 -0
- data/lib/sequel/extensions/run_transaction_hooks.rb +1 -1
- data/lib/sequel/extensions/s.rb +2 -0
- data/lib/sequel/extensions/schema_dumper.rb +3 -3
- data/lib/sequel/extensions/symbol_aref_refinement.rb +2 -0
- data/lib/sequel/extensions/symbol_as_refinement.rb +2 -0
- data/lib/sequel/extensions/to_dot.rb +9 -3
- data/lib/sequel/model.rb +3 -1
- data/lib/sequel/model/associations.rb +54 -25
- data/lib/sequel/model/base.rb +13 -5
- data/lib/sequel/model/plugins.rb +3 -3
- data/lib/sequel/plugins/association_pks.rb +60 -18
- data/lib/sequel/plugins/association_proxies.rb +1 -0
- data/lib/sequel/plugins/blacklist_security.rb +1 -2
- data/lib/sequel/plugins/class_table_inheritance.rb +3 -3
- data/lib/sequel/plugins/csv_serializer.rb +2 -0
- data/lib/sequel/plugins/dirty.rb +45 -0
- data/lib/sequel/plugins/forbid_lazy_load.rb +2 -0
- data/lib/sequel/plugins/instance_specific_default.rb +113 -0
- data/lib/sequel/plugins/lazy_attributes.rb +1 -1
- data/lib/sequel/plugins/pg_array_associations.rb +2 -3
- data/lib/sequel/plugins/prepared_statements.rb +5 -11
- data/lib/sequel/plugins/prepared_statements_safe.rb +1 -3
- data/lib/sequel/plugins/rcte_tree.rb +10 -16
- data/lib/sequel/plugins/string_stripper.rb +1 -1
- data/lib/sequel/plugins/validation_class_methods.rb +5 -1
- data/lib/sequel/version.rb +1 -1
- metadata +13 -2
| @@ -58,8 +58,7 @@ module Sequel | |
| 58 58 | 
             
                    # restricted_columns.
         | 
| 59 59 | 
             
                    def get_setter_methods
         | 
| 60 60 | 
             
                      meths = super
         | 
| 61 | 
            -
                       | 
| 62 | 
            -
                      if (!defined?(::Sequel::Plugins::WhitelistSecurity) || !plugins.include?(::Sequel::Plugins::WhitelistSecurity) || !allowed_columns) && restricted_columns
         | 
| 61 | 
            +
                      if (!defined?(::Sequel::Plugins::WhitelistSecurity::ClassMethods) || !is_a?(::Sequel::Plugins::WhitelistSecurity::ClassMethods) || !allowed_columns) && restricted_columns
         | 
| 63 62 | 
             
                        meths -= restricted_columns.map{|x| "#{x}="}
         | 
| 64 63 | 
             
                      end
         | 
| 65 64 | 
             
                      meths
         | 
| @@ -289,7 +289,7 @@ module Sequel | |
| 289 289 |  | 
| 290 290 | 
             
                    # The name of the most recently joined table.
         | 
| 291 291 | 
             
                    def cti_table_name
         | 
| 292 | 
            -
                      cti_tables | 
| 292 | 
            +
                      cti_tables.last
         | 
| 293 293 | 
             
                    end
         | 
| 294 294 |  | 
| 295 295 | 
             
                    # The model class for the given key value.
         | 
| @@ -310,7 +310,7 @@ module Sequel | |
| 310 310 | 
             
                      # Set table if this is a class table inheritance
         | 
| 311 311 | 
             
                      table = nil
         | 
| 312 312 | 
             
                      columns = nil
         | 
| 313 | 
            -
                      if  | 
| 313 | 
            +
                      if n = subclass.name
         | 
| 314 314 | 
             
                        if table = cti_table_map[n.to_sym]
         | 
| 315 315 | 
             
                          columns = db.schema(table).map(&:first)
         | 
| 316 316 | 
             
                        else
         | 
| @@ -417,7 +417,7 @@ module Sequel | |
| 417 417 | 
             
                          @values[primary_key] ||= nid
         | 
| 418 418 | 
             
                        end
         | 
| 419 419 | 
             
                      end
         | 
| 420 | 
            -
                       | 
| 420 | 
            +
                      @values[primary_key]
         | 
| 421 421 | 
             
                    end
         | 
| 422 422 |  | 
| 423 423 | 
             
                    # Update rows in all backing tables, using the columns in each table.
         | 
    
        data/lib/sequel/plugins/dirty.rb
    CHANGED
    
    | @@ -41,6 +41,15 @@ module Sequel | |
| 41 41 | 
             
                #   artist.column_changes        # => {}
         | 
| 42 42 | 
             
                #   artist.previous_changes      # => {:name=>['Foo', 'Bar']}
         | 
| 43 43 | 
             
                #
         | 
| 44 | 
            +
                #   artist.column_previously_was(:name)
         | 
| 45 | 
            +
                #   # => 'Foo'
         | 
| 46 | 
            +
                #   artist.column_previously_changed?(:name)
         | 
| 47 | 
            +
                #   # => true
         | 
| 48 | 
            +
                #   artist.column_previously_changed?(:name, from: 'Foo', to: 'Bar')
         | 
| 49 | 
            +
                #   # => true
         | 
| 50 | 
            +
                #   artist.column_previously_changed?(:name, from: 'Foo', to: 'Baz')
         | 
| 51 | 
            +
                #   # => false
         | 
| 52 | 
            +
                #
         | 
| 44 53 | 
             
                # There is one caveat; when used with a column that also uses the
         | 
| 45 54 | 
             
                # serialization plugin, setting the column back to its original value
         | 
| 46 55 | 
             
                # after changing it is not correctly detected and will leave an entry
         | 
| @@ -105,6 +114,41 @@ module Sequel | |
| 105 114 | 
             
                      initial_values.has_key?(column)
         | 
| 106 115 | 
             
                    end
         | 
| 107 116 |  | 
| 117 | 
            +
                    # Whether the column was previously changed.
         | 
| 118 | 
            +
                    # Options:
         | 
| 119 | 
            +
                    # :from :: If given, the previous initial value of the column must match this
         | 
| 120 | 
            +
                    # :to :: If given, the previous changed value of the column must match this
         | 
| 121 | 
            +
                    #
         | 
| 122 | 
            +
                    #   update(name: 'Current')
         | 
| 123 | 
            +
                    #   previous_changes                  # => {:name=>['Initial', 'Current']}
         | 
| 124 | 
            +
                    #   column_previously_changed?(:name) # => true
         | 
| 125 | 
            +
                    #   column_previously_changed?(:id)   # => false
         | 
| 126 | 
            +
                    #   column_previously_changed?(:name, from: 'Initial', to: 'Current') # => true
         | 
| 127 | 
            +
                    #   column_previously_changed?(:name, from: 'Foo', to: 'Current')     # => false
         | 
| 128 | 
            +
                    def column_previously_changed?(column, opts=OPTS)
         | 
| 129 | 
            +
                      return false unless (pc = @previous_changes) && (val = pc[column])
         | 
| 130 | 
            +
             | 
| 131 | 
            +
                      if opts.has_key?(:from)
         | 
| 132 | 
            +
                        return false unless val[0] == opts[:from]
         | 
| 133 | 
            +
                      end
         | 
| 134 | 
            +
             | 
| 135 | 
            +
                      if opts.has_key?(:to)
         | 
| 136 | 
            +
                        return false unless val[1] == opts[:to]
         | 
| 137 | 
            +
                      end
         | 
| 138 | 
            +
             | 
| 139 | 
            +
                      true
         | 
| 140 | 
            +
                    end
         | 
| 141 | 
            +
             | 
| 142 | 
            +
                    # The previous value of the column, which is the initial value of
         | 
| 143 | 
            +
                    # the column before the object was previously saved.
         | 
| 144 | 
            +
                    #
         | 
| 145 | 
            +
                    #   initial_value(:name) # => 'Initial'
         | 
| 146 | 
            +
                    #   update(name: 'Current')
         | 
| 147 | 
            +
                    #   column_previously_was(:name) # => 'Initial'
         | 
| 148 | 
            +
                    def column_previously_was(column)
         | 
| 149 | 
            +
                      (pc = @previous_changes) && (val = pc[column]) && val[0]
         | 
| 150 | 
            +
                    end
         | 
| 151 | 
            +
             | 
| 108 152 | 
             
                    # Freeze internal data structures
         | 
| 109 153 | 
             
                    def freeze
         | 
| 110 154 | 
             
                      initial_values.freeze
         | 
| @@ -143,6 +187,7 @@ module Sequel | |
| 143 187 | 
             
                      end
         | 
| 144 188 | 
             
                    end
         | 
| 145 189 |  | 
| 190 | 
            +
                    # Manually specify that a column will change.  This should only be used
         | 
| 146 191 | 
             
                    # Manually specify that a column will change.  This should only be used
         | 
| 147 192 | 
             
                    # if you plan to modify a column value in place, which is not recommended.
         | 
| 148 193 | 
             
                    #
         | 
| @@ -111,7 +111,9 @@ module Sequel | |
| 111 111 | 
             
                    # an association, allow lazy loading that association, since the
         | 
| 112 112 | 
             
                    # lazy association load will use a hash table lookup and not a query.
         | 
| 113 113 | 
             
                    def allow_lazy_load_for_static_cache_associations
         | 
| 114 | 
            +
                      # :nocov:
         | 
| 114 115 | 
             
                      if defined?(::Sequel::Plugins::StaticCache::ClassMethods)
         | 
| 116 | 
            +
                      # :nocov:
         | 
| 115 117 | 
             
                        @association_reflections.each_value do |ref|
         | 
| 116 118 | 
             
                          if ref.associated_class.is_a?(::Sequel::Plugins::StaticCache::ClassMethods)
         | 
| 117 119 | 
             
                            ref[:forbid_lazy_load] = false
         | 
| @@ -0,0 +1,113 @@ | |
| 1 | 
            +
            # frozen-string-literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module Sequel
         | 
| 4 | 
            +
              module Plugins
         | 
| 5 | 
            +
                # The instance_specific_default plugin exists to make it easier to use a
         | 
| 6 | 
            +
                # global :instance_specific association option, or to warn or raise when Sequel
         | 
| 7 | 
            +
                # has to guess which value to use :instance_specific option (Sequel defaults to
         | 
| 8 | 
            +
                # guessing true as that is the conservative setting).  It is helpful to
         | 
| 9 | 
            +
                # use this plugin, particularly with the :warn or :raise settings, to determine
         | 
| 10 | 
            +
                # which associations should have :instance_specific set.  Setting the
         | 
| 11 | 
            +
                # :instance_specific to false for associations that are not instance specific
         | 
| 12 | 
            +
                # can improve performance.
         | 
| 13 | 
            +
                #
         | 
| 14 | 
            +
                # Associations are instance-specific if their block calls
         | 
| 15 | 
            +
                # a model instance method, or where the value of the block varies
         | 
| 16 | 
            +
                # based on runtime state, and the variance is outside of a delayed evaluation.
         | 
| 17 | 
            +
                # For example, with the following three associations:
         | 
| 18 | 
            +
                #
         | 
| 19 | 
            +
                #   Album.one_to_one :first_track, class: :Track do |ds|
         | 
| 20 | 
            +
                #     ds.where(number: 1)
         | 
| 21 | 
            +
                #   end
         | 
| 22 | 
            +
                #
         | 
| 23 | 
            +
                #   Album.one_to_one :last_track, class: :Track do |ds|
         | 
| 24 | 
            +
                #     ds.where(number: num_tracks)
         | 
| 25 | 
            +
                #   end
         | 
| 26 | 
            +
                #
         | 
| 27 | 
            +
                #   Album.one_to_many :recent_tracks, class: :Track do |ds|
         | 
| 28 | 
            +
                #     ds.where{date_updated > Date.today - 10}
         | 
| 29 | 
            +
                #   end
         | 
| 30 | 
            +
                #
         | 
| 31 | 
            +
                # +first_track+ is not instance specific, but +last_track+ and +recent_tracks+ are.
         | 
| 32 | 
            +
                # +last_trac+ is because the +num_tracks+ call in the block is calling
         | 
| 33 | 
            +
                # <tt>Album#num_tracks</tt>.  +recent_tracks+ is because the value will change over
         | 
| 34 | 
            +
                # time. This plugin allows you to find these cases, and set the :instance_specific
         | 
| 35 | 
            +
                # option appropriately for them:
         | 
| 36 | 
            +
                #
         | 
| 37 | 
            +
                #   Album.one_to_one :first_track, class: :Track, instance_specific: false do |ds|
         | 
| 38 | 
            +
                #     ds.where(number: 1)
         | 
| 39 | 
            +
                #   end
         | 
| 40 | 
            +
                #
         | 
| 41 | 
            +
                #   Album.one_to_one :last_track, class: :Track, instance_specific: true do |ds|
         | 
| 42 | 
            +
                #     ds.where(number: num_tracks)
         | 
| 43 | 
            +
                #   end
         | 
| 44 | 
            +
                #
         | 
| 45 | 
            +
                #   Album.one_to_many :recent_tracks, class: :Track, instance_specific: true do |ds|
         | 
| 46 | 
            +
                #     ds.where{date_updated > Date.today - 10}
         | 
| 47 | 
            +
                #   end
         | 
| 48 | 
            +
                #
         | 
| 49 | 
            +
                # For the +recent_tracks+ association, instead of marking it instance_specific, you
         | 
| 50 | 
            +
                # could also use a delayed evaluation, since it doesn't actually contain
         | 
| 51 | 
            +
                # instance-specific code:
         | 
| 52 | 
            +
                #
         | 
| 53 | 
            +
                #   Album.one_to_many :recent_tracks, class: :Track, instance_specific: false do |ds|
         | 
| 54 | 
            +
                #     ds.where{date_updated > Sequel.delay{Date.today - 10}}
         | 
| 55 | 
            +
                #   end
         | 
| 56 | 
            +
                #
         | 
| 57 | 
            +
                # Possible arguments to provide when loading the plugin:
         | 
| 58 | 
            +
                #
         | 
| 59 | 
            +
                # true :: Set the :instance_specific option to true
         | 
| 60 | 
            +
                # false :: Set the :instance_specific option to false
         | 
| 61 | 
            +
                # :default :: Call super to set the :instance_specific option
         | 
| 62 | 
            +
                # :warn :: Emit a warning before calling super to set the :instance_specific option
         | 
| 63 | 
            +
                # :raise :: Raise a Sequel::Error if an :instance_specific option is not provided and
         | 
| 64 | 
            +
                #           an association could be instance-specific.
         | 
| 65 | 
            +
                #
         | 
| 66 | 
            +
                # Note that this plugin only affects associations which could be instance
         | 
| 67 | 
            +
                # specific (those with blocks), where the :instance_specific option was not
         | 
| 68 | 
            +
                # specified when the association was created.
         | 
| 69 | 
            +
                #
         | 
| 70 | 
            +
                # Usage:
         | 
| 71 | 
            +
                #
         | 
| 72 | 
            +
                #   # Set how to handle associations that could be instance specific
         | 
| 73 | 
            +
                #   # but did not specify an :instance_specific option, for all subclasses
         | 
| 74 | 
            +
                #   # (set before creating subclasses).
         | 
| 75 | 
            +
                #   Sequel::Model.plugin :instance_specific_default, :warn
         | 
| 76 | 
            +
                #
         | 
| 77 | 
            +
                #   # Set how to handle associations that could be instance specific
         | 
| 78 | 
            +
                #   # but did not specify an :instance_specific option, for the Album class
         | 
| 79 | 
            +
                #   Album.plugin :instance_specific_default, :warn
         | 
| 80 | 
            +
                module InstanceSpecificDefault
         | 
| 81 | 
            +
                  # Set how to handle associations that could be instance specific but did
         | 
| 82 | 
            +
                  # not specify an :instance_specific value.
         | 
| 83 | 
            +
                  def self.configure(model, default)
         | 
| 84 | 
            +
                    model.instance_variable_set(:@instance_specific_default, default)
         | 
| 85 | 
            +
                  end
         | 
| 86 | 
            +
             | 
| 87 | 
            +
                  module ClassMethods
         | 
| 88 | 
            +
                    Plugins.inherited_instance_variables(self, :@instance_specific_default=>nil)
         | 
| 89 | 
            +
             | 
| 90 | 
            +
                    private
         | 
| 91 | 
            +
             | 
| 92 | 
            +
                    # Return the appropriate :instance_specific value, or warn or raise if
         | 
| 93 | 
            +
                    # configured.
         | 
| 94 | 
            +
                    def _association_instance_specific_default(name)
         | 
| 95 | 
            +
                      case @instance_specific_default
         | 
| 96 | 
            +
                      when true, false
         | 
| 97 | 
            +
                        return @instance_specific_default
         | 
| 98 | 
            +
                      when :default
         | 
| 99 | 
            +
                        # nothing
         | 
| 100 | 
            +
                      when :warn
         | 
| 101 | 
            +
                        warn("possibly instance-specific association without :instance_specific option (class: #{self}, association: #{name})", :uplevel => 3)
         | 
| 102 | 
            +
                      when :raise
         | 
| 103 | 
            +
                        raise Sequel::Error, "possibly instance-specific association without :instance_specific option (class: #{self}, association: #{name})"
         | 
| 104 | 
            +
                      else
         | 
| 105 | 
            +
                        raise Sequel::Error, "invalid value passed to instance_specific_default plugin: #{@instance_specific_default.inspect}"
         | 
| 106 | 
            +
                      end
         | 
| 107 | 
            +
             | 
| 108 | 
            +
                      super
         | 
| 109 | 
            +
                    end
         | 
| 110 | 
            +
                  end
         | 
| 111 | 
            +
                end
         | 
| 112 | 
            +
              end
         | 
| 113 | 
            +
            end
         | 
| @@ -98,7 +98,7 @@ module Sequel | |
| 98 98 | 
             
                      end
         | 
| 99 99 |  | 
| 100 100 | 
             
                      if retrieved_with
         | 
| 101 | 
            -
                         | 
| 101 | 
            +
                        primary_key = model.primary_key
         | 
| 102 102 | 
             
                        composite_pk = true if primary_key.is_a?(Array)
         | 
| 103 103 | 
             
                        id_map = {}
         | 
| 104 104 | 
             
                        retrieved_with.each{|o| id_map[o.pk] = o unless o.values.has_key?(a) || o.frozen?}
         | 
| @@ -341,10 +341,9 @@ module Sequel | |
| 341 341 | 
             
                        eo[:loader] = false
         | 
| 342 342 |  | 
| 343 343 | 
             
                        eager_load_results(opts, eo) do |assoc_record|
         | 
| 344 | 
            -
                          if pks  | 
| 344 | 
            +
                          if pks = assoc_record.get_column_value(key)
         | 
| 345 345 | 
             
                            pks.each do |pkv|
         | 
| 346 | 
            -
                               | 
| 347 | 
            -
                              objects.each do |object| 
         | 
| 346 | 
            +
                              id_map[pkv].each do |object| 
         | 
| 348 347 | 
             
                                object.associations[name].push(assoc_record)
         | 
| 349 348 | 
             
                              end
         | 
| 350 349 | 
             
                            end
         | 
| @@ -41,11 +41,9 @@ module Sequel | |
| 41 41 | 
             
                    # Create a prepared statement, but modify the SQL used so that the model's columns are explicitly
         | 
| 42 42 | 
             
                    # selected instead of using *, assuming that the dataset selects from a single table.
         | 
| 43 43 | 
             
                    def prepare_explicit_statement(ds, type, vals=OPTS)
         | 
| 44 | 
            -
                       | 
| 45 | 
            -
                       | 
| 46 | 
            -
             | 
| 47 | 
            -
                      if f && f.length == 1 && !ds.opts[:join] && (!s || s.empty?)
         | 
| 48 | 
            -
                        ds = ds.public_send(meth, *columns.map{|c| Sequel.identifier(c)})
         | 
| 44 | 
            +
                      s = ds.opts[:returning]
         | 
| 45 | 
            +
                      if !s || s.empty?
         | 
| 46 | 
            +
                        ds = ds.returning(*columns.map{|c| Sequel.identifier(c)})
         | 
| 49 47 | 
             
                      end 
         | 
| 50 48 |  | 
| 51 49 | 
             
                      prepare_statement(ds, type, vals)
         | 
| @@ -70,9 +68,7 @@ module Sequel | |
| 70 68 | 
             
                    # Return a prepared statement that can be used to insert a row using the given columns
         | 
| 71 69 | 
             
                    # and return that column values for the row created.
         | 
| 72 70 | 
             
                    def prepared_insert_select(cols)
         | 
| 73 | 
            -
                       | 
| 74 | 
            -
                        cached_prepared_statement(:insert_select, prepared_columns(cols)){prepare_explicit_statement(naked.clone(:server=>dataset.opts.fetch(:server, :default)), :insert_select, prepared_statement_key_hash(cols))}
         | 
| 75 | 
            -
                      end
         | 
| 71 | 
            +
                      cached_prepared_statement(:insert_select, prepared_columns(cols)){prepare_explicit_statement(naked.clone(:server=>dataset.opts.fetch(:server, :default)), :insert_select, prepared_statement_key_hash(cols))}
         | 
| 76 72 | 
             
                    end
         | 
| 77 73 |  | 
| 78 74 | 
             
                    # Return an array of two element arrays with the column symbol as the first entry and the
         | 
| @@ -138,9 +134,7 @@ module Sequel | |
| 138 134 | 
             
                    # and return the new column values.
         | 
| 139 135 | 
             
                    def _insert_select_raw(ds)
         | 
| 140 136 | 
             
                      if use_prepared_statements_for?(:insert_select)
         | 
| 141 | 
            -
                         | 
| 142 | 
            -
                          _set_prepared_statement_server(ps).call(@values)
         | 
| 143 | 
            -
                        end
         | 
| 137 | 
            +
                        _set_prepared_statement_server(model.send(:prepared_insert_select, @values.keys)).call(@values)
         | 
| 144 138 | 
             
                      else
         | 
| 145 139 | 
             
                        super
         | 
| 146 140 | 
             
                      end
         | 
| @@ -66,9 +66,7 @@ module Sequel | |
| 66 66 | 
             
                    # Merge the current values into the default values to reduce the number
         | 
| 67 67 | 
             
                    # of free columns.
         | 
| 68 68 | 
             
                    def before_create
         | 
| 69 | 
            -
                       | 
| 70 | 
            -
                        @values = v.merge(values)
         | 
| 71 | 
            -
                      end
         | 
| 69 | 
            +
                      @values = model.prepared_statements_column_defaults.merge(@values)
         | 
| 72 70 | 
             
                      super
         | 
| 73 71 | 
             
                    end
         | 
| 74 72 |  | 
| @@ -192,23 +192,19 @@ module Sequel | |
| 192 192 | 
             
                         :args=>((key_aliases + col_aliases) if col_aliases))
         | 
| 193 193 | 
             
                      ds = r.apply_eager_dataset_changes(ds)
         | 
| 194 194 | 
             
                      ds = ds.select_append(ka) unless ds.opts[:select] == nil
         | 
| 195 | 
            -
                      model.eager_load_results(r, eo.merge(:loader=>false, : | 
| 195 | 
            +
                      model.eager_load_results(r, eo.merge(:loader=>false, :initialize_rows=>false, :dataset=>ds, :id_map=>nil)) do |obj|
         | 
| 196 196 | 
             
                        opk = prkey_conv[obj]
         | 
| 197 | 
            -
                        if parent_map | 
| 198 | 
            -
                           | 
| 199 | 
            -
             | 
| 200 | 
            -
                            obj = idm_obj
         | 
| 201 | 
            -
                          end
         | 
| 197 | 
            +
                        if idm_obj = parent_map[opk]
         | 
| 198 | 
            +
                          key_aliases.each{|ka_| idm_obj.values[ka_] = obj.values[ka_]}
         | 
| 199 | 
            +
                          obj = idm_obj
         | 
| 202 200 | 
             
                        else
         | 
| 203 201 | 
             
                          obj.associations[parent] = nil
         | 
| 204 202 | 
             
                          parent_map[opk] = obj
         | 
| 205 203 | 
             
                          (children_map[key_conv[obj]] ||= []) << obj
         | 
| 206 204 | 
             
                        end
         | 
| 207 205 |  | 
| 208 | 
            -
                         | 
| 209 | 
            -
                           | 
| 210 | 
            -
                            root.associations[ancestors] << obj
         | 
| 211 | 
            -
                          end
         | 
| 206 | 
            +
                        id_map[extract_key_alias[obj]].each do |root|
         | 
| 207 | 
            +
                          root.associations[ancestors] << obj
         | 
| 212 208 | 
             
                        end
         | 
| 213 209 | 
             
                      end
         | 
| 214 210 | 
             
                      parent_map.each do |parent_id, obj|
         | 
| @@ -300,17 +296,15 @@ module Sequel | |
| 300 296 | 
             
                          :args=>((key_aliases + col_aliases + (level ? [la] : [])) if col_aliases))
         | 
| 301 297 | 
             
                      ds = r.apply_eager_dataset_changes(ds)
         | 
| 302 298 | 
             
                      ds = ds.select_append(ka) unless ds.opts[:select] == nil
         | 
| 303 | 
            -
                      model.eager_load_results(r, eo.merge(:loader=>false, : | 
| 299 | 
            +
                      model.eager_load_results(r, eo.merge(:loader=>false, :initialize_rows=>false, :dataset=>ds, :id_map=>nil, :associations=>OPTS)) do |obj|
         | 
| 304 300 | 
             
                        if level
         | 
| 305 301 | 
             
                          no_cache = no_cache_level == obj.values.delete(la)
         | 
| 306 302 | 
             
                        end
         | 
| 307 303 |  | 
| 308 304 | 
             
                        opk = prkey_conv[obj]
         | 
| 309 | 
            -
                        if parent_map | 
| 310 | 
            -
                           | 
| 311 | 
            -
             | 
| 312 | 
            -
                            obj = idm_obj
         | 
| 313 | 
            -
                          end
         | 
| 305 | 
            +
                        if idm_obj = parent_map[opk]
         | 
| 306 | 
            +
                          key_aliases.each{|ka_| idm_obj.values[ka_] = obj.values[ka_]}
         | 
| 307 | 
            +
                          obj = idm_obj
         | 
| 314 308 | 
             
                        else
         | 
| 315 309 | 
             
                          obj.associations[childrena] = [] unless no_cache
         | 
| 316 310 | 
             
                          parent_map[opk] = obj
         | 
| @@ -28,7 +28,7 @@ module Sequel | |
| 28 28 | 
             
                    model.plugin(:input_transformer, :string_stripper){|v| (v.is_a?(String) && !v.is_a?(SQL::Blob)) ? v.strip : v}
         | 
| 29 29 | 
             
                  end
         | 
| 30 30 | 
             
                  def self.configure(model)
         | 
| 31 | 
            -
                    model. | 
| 31 | 
            +
                    model.send(:set_skipped_string_stripping_columns)
         | 
| 32 32 | 
             
                  end
         | 
| 33 33 |  | 
| 34 34 | 
             
                  module ClassMethods
         | 
| @@ -194,7 +194,11 @@ module Sequel | |
| 194 194 | 
             
                    def validates_each(*atts, &block)
         | 
| 195 195 | 
             
                      opts = extract_options!(atts)
         | 
| 196 196 | 
             
                      blank_meth = db.method(:blank_object?).to_proc
         | 
| 197 | 
            -
                       | 
| 197 | 
            +
                      i = opts[:if]
         | 
| 198 | 
            +
                      am = opts[:allow_missing]
         | 
| 199 | 
            +
                      an = opts[:allow_nil]
         | 
| 200 | 
            +
                      ab = opts[:allow_blank]
         | 
| 201 | 
            +
                      blk = if i || am || an || ab
         | 
| 198 202 | 
             
                        if i.is_a?(Proc)
         | 
| 199 203 | 
             
                          i = Plugins.def_sequel_method(self, "validation_class_methods_if", 0, &i)
         | 
| 200 204 | 
             
                        end
         | 
    
        data/lib/sequel/version.rb
    CHANGED
    
    | @@ -6,7 +6,7 @@ module Sequel | |
| 6 6 |  | 
| 7 7 | 
             
              # The minor version of Sequel.  Bumped for every non-patch level
         | 
| 8 8 | 
             
              # release, generally around once a month.
         | 
| 9 | 
            -
              MINOR =  | 
| 9 | 
            +
              MINOR = 37
         | 
| 10 10 |  | 
| 11 11 | 
             
              # The tiny version of Sequel.  Usually 0, only bumped for bugfix
         | 
| 12 12 | 
             
              # releases that fix regressions from previous versions.
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: sequel
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 5. | 
| 4 | 
            +
              version: 5.37.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Jeremy Evans
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2020- | 
| 11 | 
            +
            date: 2020-10-01 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: minitest
         | 
| @@ -180,6 +180,11 @@ extra_rdoc_files: | |
| 180 180 | 
             
            - doc/release_notes/5.30.0.txt
         | 
| 181 181 | 
             
            - doc/release_notes/5.31.0.txt
         | 
| 182 182 | 
             
            - doc/release_notes/5.32.0.txt
         | 
| 183 | 
            +
            - doc/release_notes/5.33.0.txt
         | 
| 184 | 
            +
            - doc/release_notes/5.34.0.txt
         | 
| 185 | 
            +
            - doc/release_notes/5.35.0.txt
         | 
| 186 | 
            +
            - doc/release_notes/5.36.0.txt
         | 
| 187 | 
            +
            - doc/release_notes/5.37.0.txt
         | 
| 183 188 | 
             
            files:
         | 
| 184 189 | 
             
            - CHANGELOG
         | 
| 185 190 | 
             
            - MIT-LICENSE
         | 
| @@ -233,6 +238,11 @@ files: | |
| 233 238 | 
             
            - doc/release_notes/5.30.0.txt
         | 
| 234 239 | 
             
            - doc/release_notes/5.31.0.txt
         | 
| 235 240 | 
             
            - doc/release_notes/5.32.0.txt
         | 
| 241 | 
            +
            - doc/release_notes/5.33.0.txt
         | 
| 242 | 
            +
            - doc/release_notes/5.34.0.txt
         | 
| 243 | 
            +
            - doc/release_notes/5.35.0.txt
         | 
| 244 | 
            +
            - doc/release_notes/5.36.0.txt
         | 
| 245 | 
            +
            - doc/release_notes/5.37.0.txt
         | 
| 236 246 | 
             
            - doc/release_notes/5.4.0.txt
         | 
| 237 247 | 
             
            - doc/release_notes/5.5.0.txt
         | 
| 238 248 | 
             
            - doc/release_notes/5.6.0.txt
         | 
| @@ -458,6 +468,7 @@ files: | |
| 458 468 | 
             
            - lib/sequel/plugins/insert_returning_select.rb
         | 
| 459 469 | 
             
            - lib/sequel/plugins/instance_filters.rb
         | 
| 460 470 | 
             
            - lib/sequel/plugins/instance_hooks.rb
         | 
| 471 | 
            +
            - lib/sequel/plugins/instance_specific_default.rb
         | 
| 461 472 | 
             
            - lib/sequel/plugins/inverted_subsets.rb
         | 
| 462 473 | 
             
            - lib/sequel/plugins/json_serializer.rb
         | 
| 463 474 | 
             
            - lib/sequel/plugins/lazy_attributes.rb
         |