commit rubygem-activerecord-5.2 for openSUSE:Factory
Hello community, here is the log from the commit of package rubygem-activerecord-5.2 for openSUSE:Factory checked in at 2019-11-30 10:38:57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/rubygem-activerecord-5.2 (Old) and /work/SRC/openSUSE:Factory/.rubygem-activerecord-5.2.new.26869 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "rubygem-activerecord-5.2" Sat Nov 30 10:38:57 2019 rev:7 rq:751748 version:5.2.4 Changes: -------- --- /work/SRC/openSUSE:Factory/rubygem-activerecord-5.2/rubygem-activerecord-5.2.changes 2019-04-01 12:36:19.533855187 +0200 +++ /work/SRC/openSUSE:Factory/.rubygem-activerecord-5.2.new.26869/rubygem-activerecord-5.2.changes 2019-11-30 10:40:36.952148878 +0100 @@ -1,0 +2,42 @@ +Thu Nov 28 12:59:13 UTC 2019 - Manuel Schnitzer <mschnitzer@suse.com> + +- updated to version 5.2.4 + + * Fix circular `autosave: true` causes invalid records to be saved. + + Prior to the fix, when there was a circular series of `autosave: true` + associations, the callback for a `has_many` association was run while + another instance of the same callback on the same association hadn't + finished running. When control returned to the first instance of the + callback, the instance variable had changed, and subsequent associated + records weren't saved correctly. Specifically, the ID field for the + `belongs_to` corresponding to the `has_many` was `nil`. + + Fixes #28080. + + *Larry Reid* + + * PostgreSQL: Fix GROUP BY with ORDER BY virtual count attribute. + + Fixes #36022. + + *Ryuta Kamizono* + + * Fix sqlite3 collation parsing when using decimal columns. + + *Martin R. Schuster* + + * Make ActiveRecord `ConnectionPool.connections` method thread-safe. + + Fixes #36465. + + *Jeff Doering* + + * Assign all attributes before calling `build` to ensure the child record is visible in + `before_add` and `after_add` callbacks for `has_many :through` associations. + + Fixes #33249. + + *Ryan H. Kerr* + +------------------------------------------------------------------- Old: ---- activerecord-5.2.3.gem New: ---- activerecord-5.2.4.gem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ rubygem-activerecord-5.2.spec ++++++ --- /var/tmp/diff_new_pack.I5LLCd/_old 2019-11-30 10:40:37.424148821 +0100 +++ /var/tmp/diff_new_pack.I5LLCd/_new 2019-11-30 10:40:37.424148821 +0100 @@ -24,7 +24,7 @@ # Name: rubygem-activerecord-5.2 -Version: 5.2.3 +Version: 5.2.4 Release: 0 %define mod_name activerecord %define mod_full_name %{mod_name}-%{version} ++++++ activerecord-5.2.3.gem -> activerecord-5.2.4.gem ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/CHANGELOG.md new/CHANGELOG.md --- old/CHANGELOG.md 2019-03-28 03:59:25.000000000 +0100 +++ new/CHANGELOG.md 2019-11-27 16:39:57.000000000 +0100 @@ -1,3 +1,43 @@ +## Rails 5.2.4 (November 27, 2019) ## + +* Fix circular `autosave: true` causes invalid records to be saved. + + Prior to the fix, when there was a circular series of `autosave: true` + associations, the callback for a `has_many` association was run while + another instance of the same callback on the same association hadn't + finished running. When control returned to the first instance of the + callback, the instance variable had changed, and subsequent associated + records weren't saved correctly. Specifically, the ID field for the + `belongs_to` corresponding to the `has_many` was `nil`. + + Fixes #28080. + + *Larry Reid* + +* PostgreSQL: Fix GROUP BY with ORDER BY virtual count attribute. + + Fixes #36022. + + *Ryuta Kamizono* + +* Fix sqlite3 collation parsing when using decimal columns. + + *Martin R. Schuster* + +* Make ActiveRecord `ConnectionPool.connections` method thread-safe. + + Fixes #36465. + + *Jeff Doering* + +* Assign all attributes before calling `build` to ensure the child record is visible in + `before_add` and `after_add` callbacks for `has_many :through` associations. + + Fixes #33249. + + *Ryan H. Kerr* + + ## Rails 5.2.3 (March 27, 2019) ## * Fix different `count` calculation when using `size` with manual `select` with DISTINCT. 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/associations/builder/collection_association.rb new/lib/active_record/associations/builder/collection_association.rb --- old/lib/active_record/associations/builder/collection_association.rb 2019-03-28 03:59:25.000000000 +0100 +++ new/lib/active_record/associations/builder/collection_association.rb 2019-11-27 16:39:57.000000000 +0100 @@ -20,10 +20,10 @@ } end - def self.define_extensions(model, name) + def self.define_extensions(model, name, &block) if block_given? extension_module_name = "#{model.name.demodulize}#{name.to_s.camelize}AssociationExtension" - extension = Module.new(&Proc.new) + extension = Module.new(&block) model.parent.const_set(extension_module_name, extension) 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 2019-03-28 03:59:25.000000000 +0100 +++ new/lib/active_record/associations/has_many_through_association.rb 2019-11-27 16:39:57.000000000 +0100 @@ -57,21 +57,14 @@ @through_records[record.object_id] ||= begin ensure_mutable - through_record = through_association.build(*options_for_through_record) - through_record.send("#{source_reflection.name}=", record) + attributes = through_scope_attributes + attributes[source_reflection.name] = record + attributes[source_reflection.foreign_type] = options[:source_type] if options[:source_type] - if options[:source_type] - through_record.send("#{source_reflection.foreign_type}=", options[:source_type]) - end - - through_record + through_association.build(attributes) end end - def options_for_through_record - [through_scope_attributes] - end - def through_scope_attributes scope.where_values_hash(through_association.reflection.name.to_s). except!(through_association.reflection.foreign_key, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/active_record/associations/join_dependency/join_association.rb new/lib/active_record/associations/join_dependency/join_association.rb --- old/lib/active_record/associations/join_dependency/join_association.rb 2019-03-28 03:59:25.000000000 +0100 +++ new/lib/active_record/associations/join_dependency/join_association.rb 2019-11-27 16:39:57.000000000 +0100 @@ -30,17 +30,21 @@ table = tables[-i] klass = reflection.klass - constraint = reflection.build_join_constraint(table, foreign_table) + join_scope = reflection.join_scope(table, foreign_table, foreign_klass) - joins << table.create_join(table, table.create_on(constraint), join_type) - - join_scope = reflection.join_scope(table, foreign_klass) arel = join_scope.arel(alias_tracker.aliases) + nodes = arel.constraints.first + + others, children = nodes.children.partition do |node| + !fetch_arel_attribute(node) { |attr| attr.relation.name == table.name } + end + nodes = table.create_and(children) - if arel.constraints.any? + joins << table.create_join(table, table.create_on(nodes), join_type) + + unless others.empty? joins.concat arel.join_sources - right = joins.last.right - right.expr = right.expr.and(arel.constraints) + append_constraints(joins.last, others) end # The current table in this iteration becomes the foreign table in the next @@ -54,6 +58,23 @@ @tables = tables @table = tables.first end + + private + def fetch_arel_attribute(value) + case value + when Arel::Nodes::Between, Arel::Nodes::In, Arel::Nodes::NotIn, Arel::Nodes::Equality, Arel::Nodes::NotEqual, Arel::Nodes::LessThan, Arel::Nodes::LessThanOrEqual, Arel::Nodes::GreaterThan, Arel::Nodes::GreaterThanOrEqual + yield value.left.is_a?(Arel::Attributes::Attribute) ? value.left : value.right + end + end + + def append_constraints(join, constraints) + if join.is_a?(Arel::Nodes::StringJoin) + join_string = table.create_and(constraints.unshift(join.left)) + join.left = Arel.sql(base_klass.connection.visitor.compile(join_string)) + else + join.right.expr.children.concat(constraints) + end + end end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/active_record/associations/preloader.rb new/lib/active_record/associations/preloader.rb --- old/lib/active_record/associations/preloader.rb 2019-03-28 03:59:25.000000000 +0100 +++ new/lib/active_record/associations/preloader.rb 2019-11-27 16:39:57.000000000 +0100 @@ -177,7 +177,7 @@ # and attach it to a relation. The class returned implements a `run` method # that accepts a preloader. def preloader_for(reflection, owners) - if owners.first.association(reflection.name).loaded? + if owners.all? { |o| o.association(reflection.name).loaded? } return AlreadyLoaded end reflection.check_preloadable! 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 2019-03-28 03:59:25.000000000 +0100 +++ new/lib/active_record/autosave_association.rb 2019-11-27 16:39:57.000000000 +0100 @@ -272,7 +272,7 @@ # or saved. If +autosave+ is +false+ only new records will be returned, # unless the parent is/was a new record itself. def associated_records_to_validate_or_save(association, new_record, autosave) - if new_record + if new_record || custom_validation_context? association && association.target elsif autosave association.target.find_all(&:changed_for_autosave?) @@ -304,7 +304,7 @@ def validate_single_association(reflection) association = association_instance_get(reflection.name) record = association && association.reader - association_valid?(reflection, record) if record + association_valid?(reflection, record) if record && (record.changed_for_autosave? || custom_validation_context?) end # Validate the associated records if <tt>:validate</tt> or @@ -324,7 +324,7 @@ def association_valid?(reflection, record, index = nil) return true if record.destroyed? || (reflection.options[:autosave] && record.marked_for_destruction?) - context = validation_context unless [:create, :update].include?(validation_context) + context = validation_context if custom_validation_context? unless valid = record.valid?(context) if reflection.options[:autosave] @@ -382,10 +382,14 @@ if association = association_instance_get(reflection.name) autosave = reflection.options[:autosave] + # By saving the instance variable in a local variable, + # we make the whole callback re-entrant. + new_record_before_save = @new_record_before_save + # reconstruct the scope now that we know the owner's id association.reset_scope - if records = associated_records_to_validate_or_save(association, @new_record_before_save, autosave) + if records = associated_records_to_validate_or_save(association, new_record_before_save, autosave) if autosave records_to_destroy = records.select(&:marked_for_destruction?) records_to_destroy.each { |record| association.destroy(record) } @@ -397,7 +401,7 @@ saved = true - if autosave != false && (@new_record_before_save || record.new_record?) + if autosave != false && (new_record_before_save || record.new_record?) if autosave saved = association.insert_record(record, false) elsif !reflection.nested? @@ -457,10 +461,16 @@ # If the record is new or it has changed, returns true. def record_changed?(reflection, record, key) record.new_record? || - (record.has_attribute?(reflection.foreign_key) && record[reflection.foreign_key] != key) || + association_foreign_key_changed?(reflection, record, key) || record.will_save_change_to_attribute?(reflection.foreign_key) end + def association_foreign_key_changed?(reflection, record, key) + return false if reflection.through_reflection? + + record.has_attribute?(reflection.foreign_key) && record[reflection.foreign_key] != key + end + # Saves the associated record if it's new or <tt>:autosave</tt> is enabled. # # In addition, it will destroy the association if it was marked for destruction. @@ -489,6 +499,10 @@ end end + def custom_validation_context? + validation_context && [:create, :update].exclude?(validation_context) + end + def _ensure_no_duplicate_errors errors.messages.each_key do |attribute| errors[attribute].uniq! 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 2019-03-28 03:59:25.000000000 +0100 +++ new/lib/active_record/connection_adapters/abstract/connection_pool.rb 2019-11-27 16:39:58.000000000 +0100 @@ -310,7 +310,7 @@ include QueryCache::ConnectionPoolConfiguration attr_accessor :automatic_reconnect, :checkout_timeout, :schema_cache - attr_reader :spec, :connections, :size, :reaper + attr_reader :spec, :size, :reaper # Creates a new ConnectionPool object. +spec+ is a ConnectionSpecification # object which describes database connection information (e.g. adapter, @@ -379,7 +379,7 @@ # #connection can be called any number of times; the connection is # held in a cache keyed by a thread. def connection - @thread_cached_conns[connection_cache_key(@lock_thread || Thread.current)] ||= checkout + @thread_cached_conns[connection_cache_key(current_thread)] ||= checkout end # Returns true if there is an open connection being used for the current thread. @@ -388,7 +388,7 @@ # #connection or #with_connection methods. Connections obtained through # #checkout will not be detected by #active_connection? def active_connection? - @thread_cached_conns[connection_cache_key(Thread.current)] + @thread_cached_conns[connection_cache_key(current_thread)] end # Signal that the thread is finished with the current connection. @@ -423,6 +423,21 @@ synchronize { @connections.any? } end + # Returns an array containing the connections currently in the pool. + # Access to the array does not require synchronization on the pool because + # the array is newly created and not retained by the pool. + # + # However; this method bypasses the ConnectionPool's thread-safe connection + # access pattern. A returned connection may be owned by another thread, + # unowned, or by happen-stance owned by the calling thread. + # + # Calling methods on a connection without ownership is subject to the + # thread-safety guarantees of the underlying method. Many of the methods + # on connection adapter classes are inherently multi-thread unsafe. + def connections + synchronize { @connections.dup } + end + # Disconnects all connections in the pool, and clears the pool. # # Raises: @@ -668,6 +683,10 @@ thread end + def current_thread + @lock_thread || Thread.current + end + # Take control of all existing connections so a "group" action such as # reload/disconnect can be performed safely. It is no longer enough to # wrap it in +synchronize+ because some pool's actions are allowed diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/active_record/connection_adapters/abstract/query_cache.rb new/lib/active_record/connection_adapters/abstract/query_cache.rb --- old/lib/active_record/connection_adapters/abstract/query_cache.rb 2019-03-28 03:59:25.000000000 +0100 +++ new/lib/active_record/connection_adapters/abstract/query_cache.rb 2019-11-27 16:39:58.000000000 +0100 @@ -32,17 +32,17 @@ end def enable_query_cache! - @query_cache_enabled[connection_cache_key(Thread.current)] = true + @query_cache_enabled[connection_cache_key(current_thread)] = true connection.enable_query_cache! if active_connection? end def disable_query_cache! - @query_cache_enabled.delete connection_cache_key(Thread.current) + @query_cache_enabled.delete connection_cache_key(current_thread) connection.disable_query_cache! if active_connection? end def query_cache_enabled - @query_cache_enabled[connection_cache_key(Thread.current)] + @query_cache_enabled[connection_cache_key(current_thread)] end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/active_record/connection_adapters/abstract/schema_statements.rb new/lib/active_record/connection_adapters/abstract/schema_statements.rb --- old/lib/active_record/connection_adapters/abstract/schema_statements.rb 2019-03-28 03:59:25.000000000 +0100 +++ new/lib/active_record/connection_adapters/abstract/schema_statements.rb 2019-11-27 16:39:58.000000000 +0100 @@ -100,7 +100,7 @@ def index_exists?(table_name, column_name, options = {}) column_names = Array(column_name).map(&:to_s) checks = [] - checks << lambda { |i| i.columns == column_names } + checks << lambda { |i| Array(i.columns) == column_names } checks << lambda { |i| i.unique } if options[:unique] checks << lambda { |i| i.name == options[:name].to_s } if options[:name] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/active_record/connection_adapters/sqlite3_adapter.rb new/lib/active_record/connection_adapters/sqlite3_adapter.rb --- old/lib/active_record/connection_adapters/sqlite3_adapter.rb 2019-03-28 03:59:25.000000000 +0100 +++ new/lib/active_record/connection_adapters/sqlite3_adapter.rb 2019-11-27 16:39:58.000000000 +0100 @@ -525,9 +525,9 @@ result = exec_query(sql, "SCHEMA").first if result - # Splitting with left parentheses and picking up last will return all + # Splitting with left parentheses and discarding the first part will return all # columns separated with comma(,). - columns_string = result["sql"].split("(").last + columns_string = result["sql"].split("(", 2).last columns_string.split(",").each do |column_string| # This regex will match the column name and collation type and will save 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 2019-03-28 03:59:25.000000000 +0100 +++ new/lib/active_record/gem_version.rb 2019-11-27 16:39:58.000000000 +0100 @@ -9,7 +9,7 @@ module VERSION MAJOR = 5 MINOR = 2 - TINY = 3 + TINY = 4 PRE = nil STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/active_record/reflection.rb new/lib/active_record/reflection.rb --- old/lib/active_record/reflection.rb 2019-03-28 03:59:25.000000000 +0100 +++ new/lib/active_record/reflection.rb 2019-11-27 16:39:58.000000000 +0100 @@ -174,28 +174,24 @@ scope ? [scope] : [] end - def build_join_constraint(table, foreign_table) - key = join_keys.key - foreign_key = join_keys.foreign_key - - constraint = table[key].eq(foreign_table[foreign_key]) - - if klass.finder_needs_type_condition? - table.create_and([constraint, klass.send(:type_condition, table)]) - else - constraint - end - end - - def join_scope(table, foreign_klass) + def join_scope(table, foreign_table, foreign_klass) predicate_builder = predicate_builder(table) scope_chain_items = join_scopes(table, predicate_builder) klass_scope = klass_join_scope(table, predicate_builder) + key = join_keys.key + foreign_key = join_keys.foreign_key + + klass_scope.where!(table[key].eq(foreign_table[foreign_key])) + if type klass_scope.where!(type => foreign_klass.polymorphic_name) end + if klass.finder_needs_type_condition? + klass_scope.where!(klass.send(:type_condition, table)) + end + scope_chain_items.inject(klass_scope, &:merge!) end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/active_record/relation/calculations.rb new/lib/active_record/relation/calculations.rb --- old/lib/active_record/relation/calculations.rb 2019-03-28 03:59:25.000000000 +0100 +++ new/lib/active_record/relation/calculations.rb 2019-11-27 16:39:58.000000000 +0100 @@ -133,11 +133,12 @@ relation = apply_join_dependency if operation.to_s.downcase == "count" - relation.distinct! - # PostgreSQL: ORDER BY expressions must appear in SELECT list when using DISTINCT - if (column_name == :all || column_name.nil?) && select_values.empty? - relation.order_values = [] + unless distinct_value || distinct_select?(column_name || select_for_count) + relation.distinct! + relation.select_values = [ klass.primary_key || table[Arel.star] ] end + # PostgreSQL: ORDER BY expressions must appear in SELECT list when using DISTINCT + relation.order_values = [] end relation.calculate(operation, column_name) 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 2019-03-28 03:59:25.000000000 +0100 +++ new/lib/active_record/relation/finder_methods.rb 2019-11-27 16:39:58.000000000 +0100 @@ -360,7 +360,7 @@ def construct_relation_for_exists(conditions) if distinct_value && offset_value - relation = limit(1) + relation = except(:order).limit!(1) else relation = except(:select, :distinct, :order)._select!(ONE_AS_ONE).limit!(1) end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/active_record/relation/query_methods.rb new/lib/active_record/relation/query_methods.rb --- old/lib/active_record/relation/query_methods.rb 2019-03-28 03:59:25.000000000 +0100 +++ new/lib/active_record/relation/query_methods.rb 2019-11-27 16:39:58.000000000 +0100 @@ -232,9 +232,6 @@ def _select!(*fields) # :nodoc: fields.flatten! - fields.map! do |field| - klass.attribute_alias?(field) ? klass.attribute_alias(field).to_sym : field - end self.select_values += fields self end @@ -1053,10 +1050,11 @@ columns.flat_map do |field| case field when Symbol - field = field.to_s - arel_column(field) { connection.quote_table_name(field) } + arel_column(field.to_s) do |attr_name| + connection.quote_table_name(attr_name) + end when String - arel_column(field) { field } + arel_column(field, &:itself) when Proc field.call else @@ -1072,7 +1070,7 @@ if klass.columns_hash.key?(field) && (!from || table_name_matches?(from)) arel_attribute(field) else - yield + yield field end end @@ -1161,20 +1159,14 @@ order_args.map! do |arg| case arg when Symbol - arg = arg.to_s - arel_column(arg) { - Arel.sql(connection.quote_table_name(arg)) - }.asc + order_column(arg.to_s).asc when Hash arg.map { |field, dir| case field when Arel::Nodes::SqlLiteral field.send(dir.downcase) else - field = field.to_s - arel_column(field) { - Arel.sql(connection.quote_table_name(field)) - }.send(dir.downcase) + order_column(field.to_s).send(dir.downcase) end } else @@ -1183,6 +1175,16 @@ end.flatten! end + def order_column(field) + arel_column(field) do |attr_name| + if attr_name == "count" && !group_values.empty? + arel_attribute(attr_name) + else + Arel.sql(connection.quote_table_name(attr_name)) + end + end + end + # Checks to make sure that the arguments are not blank. Note that if some # blank-like object were initially passed into the query method, then this # method will not raise an error. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/active_record/scoping/default.rb new/lib/active_record/scoping/default.rb --- old/lib/active_record/scoping/default.rb 2019-03-28 03:59:25.000000000 +0100 +++ new/lib/active_record/scoping/default.rb 2019-11-27 16:39:58.000000000 +0100 @@ -86,8 +86,8 @@ # # Should return a scope, you can call 'super' here etc. # end # end - def default_scope(scope = nil) # :doc: - scope = Proc.new if block_given? + def default_scope(scope = nil, &block) # :doc: + scope = block if block_given? if scope.is_a?(Relation) || !scope.respond_to?(:call) raise ArgumentError, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/active_record/statement_cache.rb new/lib/active_record/statement_cache.rb --- old/lib/active_record/statement_cache.rb 2019-03-28 03:59:25.000000000 +0100 +++ new/lib/active_record/statement_cache.rb 2019-11-27 16:39:58.000000000 +0100 @@ -87,8 +87,8 @@ end end - def self.create(connection, block = Proc.new) - relation = block.call Params.new + def self.create(connection, callable = nil, &block) + relation = (callable || block).call Params.new query_builder, binds = connection.cacheable_query(self, relation.arel) bind_map = BindMap.new(binds) new(query_builder, bind_map, relation.klass) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/active_record/transactions.rb new/lib/active_record/transactions.rb --- old/lib/active_record/transactions.rb 2019-03-28 03:59:25.000000000 +0100 +++ new/lib/active_record/transactions.rb 2019-11-27 16:39:58.000000000 +0100 @@ -340,6 +340,7 @@ # Ensure that it is not called if the object was never persisted (failed create), # but call it after the commit of a destroyed object. def committed!(should_run_callbacks: true) #:nodoc: + force_clear_transaction_record_state if should_run_callbacks && (destroyed? || persisted?) @_committed_already_called = true _run_commit_without_transaction_enrollment_callbacks @@ -347,7 +348,6 @@ end ensure @_committed_already_called = false - force_clear_transaction_record_state end # Call the #after_rollback callbacks. The +force_restore_state+ argument indicates if the record diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/metadata new/metadata --- old/metadata 2019-03-28 03:59:25.000000000 +0100 +++ new/metadata 2019-11-27 16:39:57.000000000 +0100 @@ -1,14 +1,14 @@ --- !ruby/object:Gem::Specification name: activerecord version: !ruby/object:Gem::Version - version: 5.2.3 + version: 5.2.4 platform: ruby authors: - David Heinemeier Hansson autorequire: bindir: bin cert_chain: [] -date: 2019-03-28 00:00:00.000000000 Z +date: 2019-11-27 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: activesupport @@ -16,28 +16,28 @@ requirements: - - '=' - !ruby/object:Gem::Version - version: 5.2.3 + version: 5.2.4 type: :runtime prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - '=' - !ruby/object:Gem::Version - version: 5.2.3 + version: 5.2.4 - !ruby/object:Gem::Dependency name: activemodel requirement: !ruby/object:Gem::Requirement requirements: - - '=' - !ruby/object:Gem::Version - version: 5.2.3 + version: 5.2.4 type: :runtime prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - '=' - !ruby/object:Gem::Version - version: 5.2.3 + version: 5.2.4 - !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.3/activerecord - changelog_uri: https://github.com/rails/rails/blob/v5.2.3/activerecord/CHANGELOG.md + source_code_uri: https://github.com/rails/rails/tree/v5.2.4/activerecord + changelog_uri: https://github.com/rails/rails/blob/v5.2.4/activerecord/CHANGELOG.md post_install_message: rdoc_options: - "--main" @@ -326,7 +326,7 @@ - !ruby/object:Gem::Version version: '0' requirements: [] -rubygems_version: 3.0.1 +rubygems_version: 3.0.3 signing_key: specification_version: 4 summary: Object-relational mapper framework (part of Rails).
participants (1)
-
root