Hello community,

here is the log from the commit of package rubygem-activerecord-5.2 for 
openSUSE:Factory checked in at 2019-01-21 10:26:22
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/rubygem-activerecord-5.2 (Old)
 and      /work/SRC/openSUSE:Factory/.rubygem-activerecord-5.2.new.28833 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "rubygem-activerecord-5.2"

Mon Jan 21 10:26:22 2019 rev:4 rq:656391 version:5.2.2

Changes:
--------
--- 
/work/SRC/openSUSE:Factory/rubygem-activerecord-5.2/rubygem-activerecord-5.2.changes
        2018-12-06 12:17:49.821486727 +0100
+++ 
/work/SRC/openSUSE:Factory/.rubygem-activerecord-5.2.new.28833/rubygem-activerecord-5.2.changes
     2019-01-21 10:26:23.969681682 +0100
@@ -1,0 +2,107 @@
+Sat Dec  8 16:16:28 UTC 2018 - Stephan Kulow <[email protected]>
+
+- updated to version 5.2.2
+ see installed CHANGELOG.md
+
+  ## Rails 5.2.2 (December 04, 2018) ##
+  
+  *   Do not ignore the scoping with query methods in the scope block.
+  
+      *Ryuta Kamizono*
+  
+  *   Allow aliased attributes to be used in `#update_columns` and `#update`.
+  
+      *Gannon McGibbon*
+  
+  *   Allow spaces in postgres table names.
+  
+      Fixes issue where "user post" is misinterpreted as "\"user\".\"post\"" 
when quoting table names with the postgres
+      adapter.
+  
+      *Gannon McGibbon*
+  
+  *   Cached columns_hash fields should be excluded from ResultSet#column_types
+  
+      PR #34528 addresses the inconsistent behaviour when attribute is defined 
for an ignored column. The following test
+      was passing for SQLite and MySQL, but failed for PostgreSQL:
+  
+      ```ruby
+      class DeveloperName < ActiveRecord::Type::String
+        def deserialize(value)
+          "Developer: #{value}"
+        end
+      end
+  
+      class AttributedDeveloper < ActiveRecord::Base
+        self.table_name = "developers"
+  
+        attribute :name, DeveloperName.new
+  
+        self.ignored_columns += ["name"]
+      end
+  
+      developer = AttributedDeveloper.create
+      developer.update_column :name, "name"
+  
+      loaded_developer = AttributedDeveloper.where(id: 
developer.id).select("*").first
+      puts loaded_developer.name # should be "Developer: name" but it's just 
"name"
+      ```
+  
+      *Dmitry Tsepelev*
+  
+  *   Values of enum are frozen, raising an error when attempting to modify 
them.
+  
+      *Emmanuel Byrd*
+  
+  *   `update_columns` now correctly raises 
`ActiveModel::MissingAttributeError`
+      if the attribute does not exist.
+  
+      *Sean Griffin*
+  
+  *   Do not use prepared statement in queries that have a large number of 
binds.
+  
+      *Ryuta Kamizono*
+  
+  *   Fix query cache to load before first request.
+  
+      *Eileen M. Uchitelle*
+  
+  *   Fix collection cache key with limit and custom select to avoid ambiguous 
timestamp column error.
+  
+      Fixes #33056.
+  
+      *Federico Martinez*
+  
+  *   Fix duplicated record creation when using nested attributes with 
`create_with`.
+  
+      *Darwin Wu*
+  
+  *   Fix regression setting children record in parent `before_save` callback.
+  
+      *Guo Xiang Tan*
+  
+  *   Prevent leaking of user's DB credentials on `rails db:create` failure.
+  
+      *bogdanvlviv*
+  
+  *   Clear mutation tracker before continuing the around callbacks.
+  
+      *Yuya Tanaka*
+  
+  *   Prevent deadlocks when waiting for connection from pool.
+  
+      *Brent Wheeldon*
+  
+  *   Avoid extra scoping when using `Relation#update` that was causing this 
method to change the current scope.
+  
+      *Ryuta Kamizono*
+  
+  *   Fix numericality validator not to be affected by custom getter.
+  
+      *Ryuta Kamizono*
+  
+  *   Fix bulk change table ignores comment option on PostgreSQL.
+  
+      *Yoshiyuki Kinjo*
+
+-------------------------------------------------------------------

Old:
----
  activerecord-5.2.1.1.gem

New:
----
  activerecord-5.2.2.gem

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ rubygem-activerecord-5.2.spec ++++++
--- /var/tmp/diff_new_pack.6zKyhK/_old  2019-01-21 10:26:24.465681137 +0100
+++ /var/tmp/diff_new_pack.6zKyhK/_new  2019-01-21 10:26:24.469681132 +0100
@@ -12,7 +12,7 @@
 # license that conforms to the Open Source Definition (Version 1.9)
 # published by the Open Source Initiative.
 
-# Please submit bugfixes or comments via http://bugs.opensuse.org/
+# Please submit bugfixes or comments via https://bugs.opensuse.org/
 #
 
 
@@ -24,7 +24,7 @@
 #
 
 Name:           rubygem-activerecord-5.2
-Version:        5.2.1.1
+Version:        5.2.2
 Release:        0
 %define mod_name activerecord
 %define mod_full_name %{mod_name}-%{version}
@@ -36,10 +36,10 @@
 %endif
 # /MANUAL
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
-BuildRequires:  ruby-macros >= 5
 BuildRequires:  %{ruby >= 2.2.2}
 BuildRequires:  %{rubygem gem2rpm}
 BuildRequires:  %{rubygem rdoc > 3.10}
+BuildRequires:  ruby-macros >= 5
 Url:            http://rubyonrails.org
 Source:         https://rubygems.org/gems/%{mod_full_name}.gem
 Source1:        gem2rpm.yml

++++++ activerecord-5.2.1.1.gem -> activerecord-5.2.2.gem ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/CHANGELOG.md new/CHANGELOG.md
--- old/CHANGELOG.md    2018-11-27 21:12:14.000000000 +0100
+++ new/CHANGELOG.md    2018-12-04 19:12:01.000000000 +0100
@@ -1,3 +1,105 @@
+## Rails 5.2.2 (December 04, 2018) ##
+
+*   Do not ignore the scoping with query methods in the scope block.
+
+    *Ryuta Kamizono*
+
+*   Allow aliased attributes to be used in `#update_columns` and `#update`.
+
+    *Gannon McGibbon*
+
+*   Allow spaces in postgres table names.
+
+    Fixes issue where "user post" is misinterpreted as "\"user\".\"post\"" 
when quoting table names with the postgres
+    adapter.
+
+    *Gannon McGibbon*
+
+*   Cached columns_hash fields should be excluded from ResultSet#column_types
+
+    PR #34528 addresses the inconsistent behaviour when attribute is defined 
for an ignored column. The following test
+    was passing for SQLite and MySQL, but failed for PostgreSQL:
+
+    ```ruby
+    class DeveloperName < ActiveRecord::Type::String
+      def deserialize(value)
+        "Developer: #{value}"
+      end
+    end
+
+    class AttributedDeveloper < ActiveRecord::Base
+      self.table_name = "developers"
+
+      attribute :name, DeveloperName.new
+
+      self.ignored_columns += ["name"]
+    end
+
+    developer = AttributedDeveloper.create
+    developer.update_column :name, "name"
+
+    loaded_developer = AttributedDeveloper.where(id: 
developer.id).select("*").first
+    puts loaded_developer.name # should be "Developer: name" but it's just 
"name"
+    ```
+
+    *Dmitry Tsepelev*
+
+*   Values of enum are frozen, raising an error when attempting to modify them.
+
+    *Emmanuel Byrd*
+
+*   `update_columns` now correctly raises `ActiveModel::MissingAttributeError`
+    if the attribute does not exist.
+
+    *Sean Griffin*
+
+*   Do not use prepared statement in queries that have a large number of binds.
+
+    *Ryuta Kamizono*
+
+*   Fix query cache to load before first request.
+
+    *Eileen M. Uchitelle*
+
+*   Fix collection cache key with limit and custom select to avoid ambiguous 
timestamp column error.
+
+    Fixes #33056.
+
+    *Federico Martinez*
+
+*   Fix duplicated record creation when using nested attributes with 
`create_with`.
+
+    *Darwin Wu*
+
+*   Fix regression setting children record in parent `before_save` callback.
+
+    *Guo Xiang Tan*
+
+*   Prevent leaking of user's DB credentials on `rails db:create` failure.
+
+    *bogdanvlviv*
+
+*   Clear mutation tracker before continuing the around callbacks.
+
+    *Yuya Tanaka*
+
+*   Prevent deadlocks when waiting for connection from pool.
+
+    *Brent Wheeldon*
+
+*   Avoid extra scoping when using `Relation#update` that was causing this 
method to change the current scope.
+
+    *Ryuta Kamizono*
+
+*   Fix numericality validator not to be affected by custom getter.
+
+    *Ryuta Kamizono*
+
+*   Fix bulk change table ignores comment option on PostgreSQL.
+
+    *Yoshiyuki Kinjo*
+
+
 ## Rails 5.2.1.1 (November 27, 2018) ##
 
 *   No changes.
Binary files old/checksums.yaml.gz and new/checksums.yaml.gz differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/active_record/association_relation.rb 
new/lib/active_record/association_relation.rb
--- old/lib/active_record/association_relation.rb       2018-11-27 
21:12:14.000000000 +0100
+++ new/lib/active_record/association_relation.rb       2018-12-04 
19:12:01.000000000 +0100
@@ -31,9 +31,9 @@
     private
 
       def exec_queries
-        super do |r|
-          @association.set_inverse_instance r
-          yield r if block_given?
+        super do |record|
+          @association.set_inverse_instance_from_queries(record)
+          yield record if block_given?
         end
       end
   end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/active_record/associations/association.rb 
new/lib/active_record/associations/association.rb
--- old/lib/active_record/associations/association.rb   2018-11-27 
21:12:14.000000000 +0100
+++ new/lib/active_record/associations/association.rb   2018-12-04 
19:12:01.000000000 +0100
@@ -103,6 +103,13 @@
         record
       end
 
+      def set_inverse_instance_from_queries(record)
+        if inverse = inverse_association_for(record)
+          inverse.inversed_from_queries(owner)
+        end
+        record
+      end
+
       # Remove the inverse association, if possible
       def remove_inverse_instance(record)
         if inverse = inverse_association_for(record)
@@ -114,6 +121,7 @@
         self.target = record
         @inversed = !!record
       end
+      alias :inversed_from_queries :inversed_from
 
       # Returns the class of the target. belongs_to polymorphic overrides this 
to look at the
       # polymorphic_type field on the owner.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/lib/active_record/associations/collection_association.rb 
new/lib/active_record/associations/collection_association.rb
--- old/lib/active_record/associations/collection_association.rb        
2018-11-27 21:12:14.000000000 +0100
+++ new/lib/active_record/associations/collection_association.rb        
2018-12-04 19:12:01.000000000 +0100
@@ -45,6 +45,8 @@
       def ids_reader
         if loaded?
           target.pluck(reflection.association_primary_key)
+        elsif !target.empty?
+          load_target.pluck(reflection.association_primary_key)
         else
           @association_ids ||= scope.pluck(reflection.association_primary_key)
         end
@@ -409,9 +411,9 @@
         end
 
         def replace_records(new_target, original_target)
-          delete(target - new_target)
+          delete(difference(target, new_target))
 
-          unless concat(new_target - target)
+          unless concat(difference(new_target, target))
             @target = original_target
             raise RecordNotSaved, "Failed to replace #{reflection.name} 
because one or more of the " \
                                   "new records could not be saved."
@@ -421,7 +423,7 @@
         end
 
         def replace_common_records_in_memory(new_target, original_target)
-          common_records = new_target & original_target
+          common_records = intersection(new_target, original_target)
           common_records.each do |record|
             skip_callbacks = true
             replace_on_target(record, @target.index(record), skip_callbacks)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/lib/active_record/associations/has_many_association.rb 
new/lib/active_record/associations/has_many_association.rb
--- old/lib/active_record/associations/has_many_association.rb  2018-11-27 
21:12:14.000000000 +0100
+++ new/lib/active_record/associations/has_many_association.rb  2018-12-04 
19:12:01.000000000 +0100
@@ -130,6 +130,14 @@
           end
           saved_successfully
         end
+
+        def difference(a, b)
+          a - b
+        end
+
+        def intersection(a, b)
+          a & b
+        end
     end
   end
 end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/lib/active_record/associations/has_many_through_association.rb 
new/lib/active_record/associations/has_many_through_association.rb
--- old/lib/active_record/associations/has_many_through_association.rb  
2018-11-27 21:12:14.000000000 +0100
+++ new/lib/active_record/associations/has_many_through_association.rb  
2018-12-04 19:12:01.000000000 +0100
@@ -163,6 +163,28 @@
           end
         end
 
+        def difference(a, b)
+          distribution = distribution(b)
+
+          a.reject { |record| mark_occurrence(distribution, record) }
+        end
+
+        def intersection(a, b)
+          distribution = distribution(b)
+
+          a.select { |record| mark_occurrence(distribution, record) }
+        end
+
+        def mark_occurrence(distribution, record)
+          distribution[record] > 0 && distribution[record] -= 1
+        end
+
+        def distribution(array)
+          array.each_with_object(Hash.new(0)) do |record, distribution|
+            distribution[record] += 1
+          end
+        end
+
         def through_records_for(record)
           attributes = construct_join_attributes(record)
           candidates = Array.wrap(through_association.target)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/active_record/attribute_methods/dirty.rb 
new/lib/active_record/attribute_methods/dirty.rb
--- old/lib/active_record/attribute_methods/dirty.rb    2018-11-27 
21:12:14.000000000 +0100
+++ new/lib/active_record/attribute_methods/dirty.rb    2018-12-04 
19:12:01.000000000 +0100
@@ -16,9 +16,6 @@
 
         class_attribute :partial_writes, instance_writer: false, default: true
 
-        after_create { changes_applied }
-        after_update { changes_applied }
-
         # Attribute methods for "changed in last call to save?"
         attribute_method_affix(prefix: "saved_change_to_", suffix: "?")
         attribute_method_prefix("saved_change_to_")
@@ -123,18 +120,26 @@
       end
 
       private
-        def write_attribute_without_type_cast(attr_name, _)
-          result = super
-          clear_attribute_change(attr_name)
+        def write_attribute_without_type_cast(attr_name, value)
+          name = attr_name.to_s
+          if self.class.attribute_alias?(name)
+            name = self.class.attribute_alias(name)
+          end
+          result = super(name, value)
+          clear_attribute_change(name)
           result
         end
 
         def _update_record(*)
-          partial_writes? ? super(keys_for_partial_write) : super
+          affected_rows = partial_writes? ? super(keys_for_partial_write) : 
super
+          changes_applied
+          affected_rows
         end
 
         def _create_record(*)
-          partial_writes? ? super(keys_for_partial_write) : super
+          id = partial_writes? ? super(keys_for_partial_write) : super
+          changes_applied
+          id
         end
 
         def keys_for_partial_write
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/active_record/autosave_association.rb 
new/lib/active_record/autosave_association.rb
--- old/lib/active_record/autosave_association.rb       2018-11-27 
21:12:14.000000000 +0100
+++ new/lib/active_record/autosave_association.rb       2018-12-04 
19:12:01.000000000 +0100
@@ -392,7 +392,7 @@
               records -= records_to_destroy
             end
 
-            records.each_with_index do |record, index|
+            records.each do |record|
               next if record.destroyed?
 
               saved = true
@@ -401,11 +401,11 @@
                 if autosave
                   saved = association.insert_record(record, false)
                 elsif !reflection.nested?
+                  association_saved = association.insert_record(record)
+
                   if reflection.validate?
-                    valid = association_valid?(reflection, record, index)
-                    saved = valid ? association.insert_record(record, false) : 
false
-                  else
-                    association.insert_record(record)
+                    errors.add(reflection.name) unless association_saved
+                    saved = association_saved
                   end
                 end
               elsif autosave
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/active_record/callbacks.rb 
new/lib/active_record/callbacks.rb
--- old/lib/active_record/callbacks.rb  2018-11-27 21:12:14.000000000 +0100
+++ new/lib/active_record/callbacks.rb  2018-12-04 19:12:01.000000000 +0100
@@ -332,7 +332,7 @@
       _run_touch_callbacks { super }
     end
 
-    def increment!(*, touch: nil) # :nodoc:
+    def increment!(attribute, by = 1, touch: nil) # :nodoc:
       touch ? _run_touch_callbacks { super } : super
     end
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/active_record/collection_cache_key.rb 
new/lib/active_record/collection_cache_key.rb
--- old/lib/active_record/collection_cache_key.rb       2018-11-27 
21:12:14.000000000 +0100
+++ new/lib/active_record/collection_cache_key.rb       2018-12-04 
19:12:01.000000000 +0100
@@ -20,9 +20,9 @@
         select_values = "COUNT(*) AS #{connection.quote_column_name("size")}, 
MAX(%s) AS timestamp"
 
         if collection.has_limit_or_offset?
-          query = collection.select(column)
+          query = collection.select("#{column} AS 
collection_cache_key_timestamp")
           subquery_alias = "subquery_for_cache_key"
-          subquery_column = "#{subquery_alias}.#{timestamp_column}"
+          subquery_column = "#{subquery_alias}.collection_cache_key_timestamp"
           subquery = query.arel.as(subquery_alias)
           arel = Arel::SelectManager.new(subquery).project(select_values % 
subquery_column)
         else
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/lib/active_record/connection_adapters/abstract/connection_pool.rb 
new/lib/active_record/connection_adapters/abstract/connection_pool.rb
--- old/lib/active_record/connection_adapters/abstract/connection_pool.rb       
2018-11-27 21:12:14.000000000 +0100
+++ new/lib/active_record/connection_adapters/abstract/connection_pool.rb       
2018-12-04 19:12:01.000000000 +0100
@@ -188,7 +188,9 @@
             t0 = Time.now
             elapsed = 0
             loop do
-              @cond.wait(timeout - elapsed)
+              ActiveSupport::Dependencies.interlock.permit_concurrent_loads do
+                @cond.wait(timeout - elapsed)
+              end
 
               return remove if any?
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/lib/active_record/connection_adapters/abstract/database_limits.rb 
new/lib/active_record/connection_adapters/abstract/database_limits.rb
--- old/lib/active_record/connection_adapters/abstract/database_limits.rb       
2018-11-27 21:12:14.000000000 +0100
+++ new/lib/active_record/connection_adapters/abstract/database_limits.rb       
2018-12-04 19:12:01.000000000 +0100
@@ -62,6 +62,11 @@
       def joins_per_query
         256
       end
+
+      private
+        def bind_params_length
+          65535
+        end
     end
   end
 end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/lib/active_record/connection_adapters/abstract/database_statements.rb 
new/lib/active_record/connection_adapters/abstract/database_statements.rb
--- old/lib/active_record/connection_adapters/abstract/database_statements.rb   
2018-11-27 21:12:14.000000000 +0100
+++ new/lib/active_record/connection_adapters/abstract/database_statements.rb   
2018-12-04 19:12:01.000000000 +0100
@@ -46,11 +46,16 @@
       def select_all(arel, name = nil, binds = [], preparable: nil)
         arel = arel_from_relation(arel)
         sql, binds = to_sql_and_binds(arel, binds)
+
         if !prepared_statements || (arel.is_a?(String) && preparable.nil?)
           preparable = false
+        elsif binds.length > bind_params_length
+          sql, binds = unprepared_statement { to_sql_and_binds(arel) }
+          preparable = false
         else
           preparable = visitor.preparable
         end
+
         if prepared_statements && preparable
           select_prepared(sql, name, binds)
         else
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/lib/active_record/connection_adapters/connection_specification.rb 
new/lib/active_record/connection_adapters/connection_specification.rb
--- old/lib/active_record/connection_adapters/connection_specification.rb       
2018-11-27 21:12:14.000000000 +0100
+++ new/lib/active_record/connection_adapters/connection_specification.rb       
2018-12-04 19:12:01.000000000 +0100
@@ -195,12 +195,12 @@
             if e.path == path_to_adapter
               # We can assume that a non-builtin adapter was specified, so it's
               # either misspelled or missing from Gemfile.
-              raise e.class, "Could not load the '#{spec[:adapter]}' Active 
Record adapter. Ensure that the adapter is spelled correctly in 
config/database.yml and that you've added the necessary adapter gem to your 
Gemfile.", e.backtrace
+              raise LoadError, "Could not load the '#{spec[:adapter]}' Active 
Record adapter. Ensure that the adapter is spelled correctly in 
config/database.yml and that you've added the necessary adapter gem to your 
Gemfile.", e.backtrace
 
             # Bubbled up from the adapter require. Prefix the exception message
             # with some guidance about how to address it and reraise.
             else
-              raise e.class, "Error loading the '#{spec[:adapter]}' Active 
Record adapter. Missing a gem it depends on? #{e.message}", e.backtrace
+              raise LoadError, "Error loading the '#{spec[:adapter]}' Active 
Record adapter. Missing a gem it depends on? #{e.message}", e.backtrace
             end
           end
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/lib/active_record/connection_adapters/determine_if_preparable_visitor.rb 
new/lib/active_record/connection_adapters/determine_if_preparable_visitor.rb
--- 
old/lib/active_record/connection_adapters/determine_if_preparable_visitor.rb    
    2018-11-27 21:12:14.000000000 +0100
+++ 
new/lib/active_record/connection_adapters/determine_if_preparable_visitor.rb    
    2018-12-04 19:12:01.000000000 +0100
@@ -10,8 +10,17 @@
         super
       end
 
-      def visit_Arel_Nodes_In(*)
+      def visit_Arel_Nodes_In(o, collector)
         @preparable = false
+
+        if Array === o.right && !o.right.empty?
+          o.right.delete_if do |bind|
+            if Arel::Nodes::BindParam === bind && Relation::QueryAttribute === 
bind.value
+              !bind.value.boundable?
+            end
+          end
+        end
+
         super
       end
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/lib/active_record/connection_adapters/postgresql/oid/array.rb 
new/lib/active_record/connection_adapters/postgresql/oid/array.rb
--- old/lib/active_record/connection_adapters/postgresql/oid/array.rb   
2018-11-27 21:12:14.000000000 +0100
+++ new/lib/active_record/connection_adapters/postgresql/oid/array.rb   
2018-12-04 19:12:01.000000000 +0100
@@ -33,7 +33,13 @@
 
           def cast(value)
             if value.is_a?(::String)
-              value = @pg_decoder.decode(value)
+              value = begin
+                @pg_decoder.decode(value)
+              rescue TypeError
+                # malformed array string is treated as [], will raise in PG 
2.0 gem
+                # this keeps a consistent implementation
+                []
+              end
             end
             type_cast_array(value, :cast)
           end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/lib/active_record/connection_adapters/postgresql/schema_statements.rb 
new/lib/active_record/connection_adapters/postgresql/schema_statements.rb
--- old/lib/active_record/connection_adapters/postgresql/schema_statements.rb   
2018-11-27 21:12:14.000000000 +0100
+++ new/lib/active_record/connection_adapters/postgresql/schema_statements.rb   
2018-12-04 19:12:01.000000000 +0100
@@ -124,7 +124,7 @@
 
               # add info on sort order (only desc order is explicitly 
specified, asc is the default)
               # and non-default opclasses
-              
expressions.scan(/(?<column>\w+)\s?(?<opclass>\w+_ops)?\s?(?<desc>DESC)?\s?(?<nulls>NULLS
 (?:FIRST|LAST))?/).each do |column, opclass, desc, nulls|
+              
expressions.scan(/(?<column>\w+)"?\s?(?<opclass>\w+_ops)?\s?(?<desc>DESC)?\s?(?<nulls>NULLS
 (?:FIRST|LAST))?/).each do |column, opclass, desc, nulls|
                 opclasses[column] = opclass.to_sym if opclass
                 if nulls
                   orders[column] = [desc, nulls].compact.join(" ")
@@ -700,6 +700,11 @@
             sql
           end
 
+          def add_column_for_alter(table_name, column_name, type, options = {})
+            return super unless options.key?(:comment)
+            [super, Proc.new { change_column_comment(table_name, column_name, 
options[:comment]) }]
+          end
+
           def change_column_for_alter(table_name, column_name, type, options = 
{})
             sqls = [change_column_sql(table_name, column_name, type, options)]
             sqls << change_column_default_for_alter(table_name, column_name, 
options[:default]) if options.key?(:default)
@@ -708,7 +713,6 @@
             sqls
           end
 
-
           # Changes the default value of a table column.
           def change_column_default_for_alter(table_name, column_name, 
default_or_changes) # :nodoc:
             column = column_for(table_name, column_name)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/lib/active_record/connection_adapters/postgresql/utils.rb 
new/lib/active_record/connection_adapters/postgresql/utils.rb
--- old/lib/active_record/connection_adapters/postgresql/utils.rb       
2018-11-27 21:12:14.000000000 +0100
+++ new/lib/active_record/connection_adapters/postgresql/utils.rb       
2018-12-04 19:12:01.000000000 +0100
@@ -68,7 +68,7 @@
         # * <tt>"schema_name".table_name</tt>
         # * <tt>"schema.name"."table name"</tt>
         def extract_schema_qualified_name(string)
-          schema, table = string.scan(/[^".\s]+|"[^"]*"/)
+          schema, table = string.scan(/[^".]+|"[^"]*"/)
           if table.nil?
             table = schema
             schema = nil
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/lib/active_record/connection_adapters/postgresql_adapter.rb 
new/lib/active_record/connection_adapters/postgresql_adapter.rb
--- old/lib/active_record/connection_adapters/postgresql_adapter.rb     
2018-11-27 21:12:14.000000000 +0100
+++ new/lib/active_record/connection_adapters/postgresql_adapter.rb     
2018-12-04 19:12:01.000000000 +0100
@@ -4,6 +4,14 @@
 gem "pg", ">= 0.18", "< 2.0"
 require "pg"
 
+# Use async_exec instead of exec_params on pg versions before 1.1
+class ::PG::Connection
+  unless self.public_method_defined?(:async_exec_params)
+    remove_method :exec_params
+    alias exec_params async_exec
+  end
+end
+
 require "active_record/connection_adapters/abstract_adapter"
 require "active_record/connection_adapters/statement_pool"
 require "active_record/connection_adapters/postgresql/column"
@@ -600,7 +608,7 @@
           type_casted_binds = type_casted_binds(binds)
           log(sql, name, binds, type_casted_binds) do
             ActiveSupport::Dependencies.interlock.permit_concurrent_loads do
-              @connection.async_exec(sql, type_casted_binds)
+              @connection.exec_params(sql, type_casted_binds)
             end
           end
         end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/active_record/enum.rb 
new/lib/active_record/enum.rb
--- old/lib/active_record/enum.rb       2018-11-27 21:12:14.000000000 +0100
+++ new/lib/active_record/enum.rb       2018-12-04 19:12:01.000000000 +0100
@@ -201,6 +201,7 @@
             klass.scope value_method_name, -> { where(attr => value) }
           end
         end
+        enum_values.freeze
       end
     end
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/active_record/errors.rb 
new/lib/active_record/errors.rb
--- old/lib/active_record/errors.rb     2018-11-27 21:12:14.000000000 +0100
+++ new/lib/active_record/errors.rb     2018-12-04 19:12:01.000000000 +0100
@@ -126,7 +126,7 @@
           To resolve this issue, change the type of the `#{foreign_key}` 
column on `#{table}` to be :integer. (For example `t.integer #{foreign_key}`).
         EOM
       else
-        msg = <<-EOM
+        msg = <<-EOM.strip_heredoc
           There is a mismatch between the foreign key and primary key column 
types.
           Verify that the foreign key column type and the primary key of the 
associated table match types.
         EOM
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/active_record/gem_version.rb 
new/lib/active_record/gem_version.rb
--- old/lib/active_record/gem_version.rb        2018-11-27 21:12:14.000000000 
+0100
+++ new/lib/active_record/gem_version.rb        2018-12-04 19:12:01.000000000 
+0100
@@ -9,8 +9,8 @@
   module VERSION
     MAJOR = 5
     MINOR = 2
-    TINY  = 1
-    PRE   = "1"
+    TINY  = 2
+    PRE   = nil
 
     STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
   end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/active_record/migration.rb 
new/lib/active_record/migration.rb
--- old/lib/active_record/migration.rb  2018-11-27 21:12:14.000000000 +0100
+++ new/lib/active_record/migration.rb  2018-12-04 19:12:01.000000000 +0100
@@ -1163,7 +1163,7 @@
 
       def migrations_path=(path)
         ActiveSupport::Deprecation.warn \
-          "ActiveRecord::Migrator.migrations_paths= is now deprecated and will 
be removed in Rails 6.0." \
+          "`ActiveRecord::Migrator.migrations_path=` is now deprecated and 
will be removed in Rails 6.0. " \
           "You can set the `migrations_paths` on the `connection` instead 
through the `database.yml`."
         self.migrations_paths = [path]
       end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/active_record/model_schema.rb 
new/lib/active_record/model_schema.rb
--- old/lib/active_record/model_schema.rb       2018-11-27 21:12:14.000000000 
+0100
+++ new/lib/active_record/model_schema.rb       2018-12-04 19:12:01.000000000 
+0100
@@ -375,7 +375,7 @@
       # default values when instantiating the Active Record object for this 
table.
       def column_defaults
         load_schema
-        @column_defaults ||= _default_attributes.to_hash
+        @column_defaults ||= _default_attributes.deep_dup.to_hash
       end
 
       def _default_attributes # :nodoc:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/active_record/persistence.rb 
new/lib/active_record/persistence.rb
--- old/lib/active_record/persistence.rb        2018-11-27 21:12:14.000000000 
+0100
+++ new/lib/active_record/persistence.rb        2018-12-04 19:12:01.000000000 
+0100
@@ -97,13 +97,11 @@
       # When running callbacks is not needed for each record update,
       # it is preferred to use {update_all}[rdoc-ref:Relation#update_all]
       # for updating all records in a single query.
-      def update(id = :all, attributes)
+      def update(id, attributes)
         if id.is_a?(Array)
           id.map { |one_id| find(one_id) }.each_with_index { |object, idx|
             object.update(attributes[idx])
           }
-        elsif id == :all
-          all.each { |record| record.update(attributes) }
         else
           if ActiveRecord::Base === id
             raise ArgumentError,
@@ -473,15 +471,16 @@
         verify_readonly_attribute(key.to_s)
       end
 
+      id_in_database = self.id_in_database
+      attributes.each do |k, v|
+        write_attribute_without_type_cast(k, v)
+      end
+
       affected_rows = self.class._update_record(
         attributes,
         self.class.primary_key => id_in_database
       )
 
-      attributes.each do |k, v|
-        write_attribute_without_type_cast(k, v)
-      end
-
       affected_rows == 1
     end
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/active_record/querying.rb 
new/lib/active_record/querying.rb
--- old/lib/active_record/querying.rb   2018-11-27 21:12:14.000000000 +0100
+++ new/lib/active_record/querying.rb   2018-12-04 19:12:01.000000000 +0100
@@ -40,7 +40,8 @@
     def find_by_sql(sql, binds = [], preparable: nil, &block)
       result_set = connection.select_all(sanitize_sql(sql), "#{name} Load", 
binds, preparable: preparable)
       column_types = result_set.column_types.dup
-      columns_hash.each_key { |k| column_types.delete k }
+      cached_columns_hash = connection.schema_cache.columns_hash(table_name)
+      cached_columns_hash.each_key { |k| column_types.delete k }
       message_bus = ActiveSupport::Notifications.instrumenter
 
       payload = {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/active_record/railtie.rb 
new/lib/active_record/railtie.rb
--- old/lib/active_record/railtie.rb    2018-11-27 21:12:14.000000000 +0100
+++ new/lib/active_record/railtie.rb    2018-12-04 19:12:01.000000000 +0100
@@ -169,9 +169,7 @@
     end
 
     initializer "active_record.set_executor_hooks" do
-      ActiveSupport.on_load(:active_record) do
-        ActiveRecord::QueryCache.install_executor_hooks
-      end
+      ActiveRecord::QueryCache.install_executor_hooks
     end
 
     initializer "active_record.add_watchable_files" do |app|
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/active_record/relation/delegation.rb 
new/lib/active_record/relation/delegation.rb
--- old/lib/active_record/relation/delegation.rb        2018-11-27 
21:12:14.000000000 +0100
+++ new/lib/active_record/relation/delegation.rb        2018-12-04 
19:12:01.000000000 +0100
@@ -17,6 +17,7 @@
           delegate = Class.new(klass) {
             include ClassSpecificRelation
           }
+          include_relation_methods(delegate)
           mangled_name = klass.name.gsub("::".freeze, "_".freeze)
           const_set mangled_name, delegate
           private_constant mangled_name
@@ -29,6 +30,35 @@
         child_class.initialize_relation_delegate_cache
         super
       end
+
+      protected
+        def include_relation_methods(delegate)
+          superclass.include_relation_methods(delegate) unless base_class == 
self
+          delegate.include generated_relation_methods
+        end
+
+      private
+        def generated_relation_methods
+          @generated_relation_methods ||= Module.new.tap do |mod|
+            mod_name = "GeneratedRelationMethods"
+            const_set mod_name, mod
+            private_constant mod_name
+          end
+        end
+
+        def generate_relation_method(method)
+          if /\A[a-zA-Z_]\w*[!?]?\z/.match?(method)
+            generated_relation_methods.module_eval <<-RUBY, __FILE__, __LINE__ 
+ 1
+              def #{method}(*args, &block)
+                scoping { klass.#{method}(*args, &block) }
+              end
+            RUBY
+          else
+            generated_relation_methods.send(:define_method, method) do |*args, 
&block|
+              scoping { klass.public_send(method, *args, &block) }
+            end
+          end
+        end
     end
 
     extend ActiveSupport::Concern
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/active_record/relation/finder_methods.rb 
new/lib/active_record/relation/finder_methods.rb
--- old/lib/active_record/relation/finder_methods.rb    2018-11-27 
21:12:14.000000000 +0100
+++ new/lib/active_record/relation/finder_methods.rb    2018-12-04 
19:12:01.000000000 +0100
@@ -363,7 +363,7 @@
 
         case conditions
         when Array, Hash
-          relation.where!(conditions)
+          relation.where!(conditions) unless conditions.empty?
         else
           relation.where!(primary_key => conditions) unless conditions == :none
         end
@@ -417,7 +417,7 @@
         raise UnknownPrimaryKey.new(@klass) if primary_key.nil?
 
         expects_array = ids.first.kind_of?(Array)
-        return ids.first if expects_array && ids.first.empty?
+        return [] if expects_array && ids.first.empty?
 
         ids = ids.flatten.compact.uniq
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/active_record/relation/merger.rb 
new/lib/active_record/relation/merger.rb
--- old/lib/active_record/relation/merger.rb    2018-11-27 21:12:14.000000000 
+0100
+++ new/lib/active_record/relation/merger.rb    2018-12-04 19:12:01.000000000 
+0100
@@ -156,10 +156,10 @@
         def merge_multi_values
           if other.reordering_value
             # override any order specified in the original relation
-            relation.reorder! other.order_values
+            relation.reorder!(*other.order_values)
           elsif other.order_values.any?
             # merge in order_values from relation
-            relation.order! other.order_values
+            relation.order!(*other.order_values)
           end
 
           extensions = other.extensions - relation.extensions
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/lib/active_record/relation/predicate_builder/array_handler.rb 
new/lib/active_record/relation/predicate_builder/array_handler.rb
--- old/lib/active_record/relation/predicate_builder/array_handler.rb   
2018-11-27 21:12:14.000000000 +0100
+++ new/lib/active_record/relation/predicate_builder/array_handler.rb   
2018-12-04 19:12:01.000000000 +0100
@@ -19,10 +19,10 @@
           when 0 then NullPredicate
           when 1 then predicate_builder.build(attribute, values.first)
           else
-            bind_values = values.map do |v|
+            values.map! do |v|
               predicate_builder.build_bind_attribute(attribute.name, v)
             end
-            attribute.in(bind_values)
+            values.empty? ? NullPredicate : attribute.in(values)
           end
 
         unless nils.empty?
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/active_record/relation/spawn_methods.rb 
new/lib/active_record/relation/spawn_methods.rb
--- old/lib/active_record/relation/spawn_methods.rb     2018-11-27 
21:12:14.000000000 +0100
+++ new/lib/active_record/relation/spawn_methods.rb     2018-12-04 
19:12:01.000000000 +0100
@@ -8,7 +8,7 @@
   module SpawnMethods
     # This is overridden by Associations::CollectionProxy
     def spawn #:nodoc:
-      clone
+      @delegate_to_klass ? klass.all : clone
     end
 
     # Merges in the conditions from <tt>other</tt>, if <tt>other</tt> is an 
ActiveRecord::Relation.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/active_record/relation.rb 
new/lib/active_record/relation.rb
--- old/lib/active_record/relation.rb   2018-11-27 21:12:14.000000000 +0100
+++ new/lib/active_record/relation.rb   2018-12-04 19:12:01.000000000 +0100
@@ -54,7 +54,7 @@
     #   user = users.new { |user| user.name = 'Oscar' }
     #   user.name # => Oscar
     def new(attributes = nil, &block)
-      scoping { klass.new(scope_for_create(attributes), &block) }
+      scoping { klass.new(values_for_create(attributes), &block) }
     end
 
     alias build new
@@ -82,7 +82,7 @@
       if attributes.is_a?(Array)
         attributes.collect { |attr| create(attr, &block) }
       else
-        scoping { klass.create(scope_for_create(attributes), &block) }
+        scoping { klass.create(values_for_create(attributes), &block) }
       end
     end
 
@@ -96,7 +96,7 @@
       if attributes.is_a?(Array)
         attributes.collect { |attr| create!(attr, &block) }
       else
-        scoping { klass.create!(scope_for_create(attributes), &block) }
+        scoping { klass.create!(values_for_create(attributes), &block) }
       end
     end
 
@@ -337,6 +337,14 @@
       @klass.connection.update stmt, "#{@klass} Update All"
     end
 
+    def update(id = :all, attributes) # :nodoc:
+      if id == :all
+        each { |record| record.update(attributes) }
+      else
+        klass.update(id, attributes)
+      end
+    end
+
     # Destroys the records by instantiating each
     # record and calling its {#destroy}[rdoc-ref:Persistence#destroy] method.
     # Each object's callbacks are executed (including <tt>:dependent</tt> 
association options).
@@ -456,10 +464,8 @@
       where_clause.to_h(relation_table_name)
     end
 
-    def scope_for_create(attributes = nil)
-      scope = where_values_hash.merge!(create_with_value.stringify_keys)
-      scope.merge!(attributes) if attributes
-      scope
+    def scope_for_create
+      where_values_hash.merge!(create_with_value.stringify_keys)
     end
 
     # Returns true if relation needs eager loading.
@@ -606,5 +612,18 @@
         # ignore raw_sql_ that is used by Oracle adapter as alias for 
limit/offset subqueries
         string.scan(/([a-zA-Z_][.\w]+).?\./).flatten.map(&:downcase).uniq - 
["raw_sql_"]
       end
+
+      def values_for_create(attributes = nil)
+        result = attributes ? where_values_hash.merge!(attributes) : 
where_values_hash
+
+        # NOTE: if there are same keys in both create_with and result, 
create_with should be used.
+        # This is to make sure nested attributes don't get passed to the 
klass.new,
+        # while keeping the precedence of the duplicate keys in create_with.
+        create_with_value.stringify_keys.each do |k, v|
+          result[k] = v if result.key?(k)
+        end
+
+        result
+      end
   end
 end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/active_record/scoping/named.rb 
new/lib/active_record/scoping/named.rb
--- old/lib/active_record/scoping/named.rb      2018-11-27 21:12:14.000000000 
+0100
+++ new/lib/active_record/scoping/named.rb      2018-12-04 19:12:01.000000000 
+0100
@@ -195,6 +195,8 @@
               scope
             end
           end
+
+          generate_relation_method(name)
         end
 
         private
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/active_record/tasks/database_tasks.rb 
new/lib/active_record/tasks/database_tasks.rb
--- old/lib/active_record/tasks/database_tasks.rb       2018-11-27 
21:12:14.000000000 +0100
+++ new/lib/active_record/tasks/database_tasks.rb       2018-12-04 
19:12:01.000000000 +0100
@@ -122,7 +122,7 @@
         $stderr.puts "Database '#{configuration['database']}' already exists"
       rescue Exception => error
         $stderr.puts error
-        $stderr.puts "Couldn't create database for #{configuration.inspect}"
+        $stderr.puts "Couldn't create '#{configuration['database']}' database. 
Please check your configuration."
         raise
       end
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/metadata new/metadata
--- old/metadata        2018-11-27 21:12:14.000000000 +0100
+++ new/metadata        2018-12-04 19:12:01.000000000 +0100
@@ -1,14 +1,14 @@
 --- !ruby/object:Gem::Specification
 name: activerecord
 version: !ruby/object:Gem::Version
-  version: 5.2.1.1
+  version: 5.2.2
 platform: ruby
 authors:
 - David Heinemeier Hansson
 autorequire: 
 bindir: bin
 cert_chain: []
-date: 2018-11-27 00:00:00.000000000 Z
+date: 2018-12-04 00:00:00.000000000 Z
 dependencies:
 - !ruby/object:Gem::Dependency
   name: activesupport
@@ -16,28 +16,28 @@
     requirements:
     - - '='
       - !ruby/object:Gem::Version
-        version: 5.2.1.1
+        version: 5.2.2
   type: :runtime
   prerelease: false
   version_requirements: !ruby/object:Gem::Requirement
     requirements:
     - - '='
       - !ruby/object:Gem::Version
-        version: 5.2.1.1
+        version: 5.2.2
 - !ruby/object:Gem::Dependency
   name: activemodel
   requirement: !ruby/object:Gem::Requirement
     requirements:
     - - '='
       - !ruby/object:Gem::Version
-        version: 5.2.1.1
+        version: 5.2.2
   type: :runtime
   prerelease: false
   version_requirements: !ruby/object:Gem::Requirement
     requirements:
     - - '='
       - !ruby/object:Gem::Version
-        version: 5.2.1.1
+        version: 5.2.2
 - !ruby/object:Gem::Dependency
   name: arel
   requirement: !ruby/object:Gem::Requirement
@@ -307,8 +307,8 @@
 licenses:
 - MIT
 metadata:
-  source_code_uri: https://github.com/rails/rails/tree/v5.2.1.1/activerecord
-  changelog_uri: 
https://github.com/rails/rails/blob/v5.2.1.1/activerecord/CHANGELOG.md
+  source_code_uri: https://github.com/rails/rails/tree/v5.2.2/activerecord
+  changelog_uri: 
https://github.com/rails/rails/blob/v5.2.2/activerecord/CHANGELOG.md
 post_install_message: 
 rdoc_options:
 - "--main"


Reply via email to