Hello community,
here is the log from the commit of package rubygem-activerecord-5_1 for
openSUSE:Factory checked in at 2017-09-13 22:35:20
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/rubygem-activerecord-5_1 (Old)
and /work/SRC/openSUSE:Factory/.rubygem-activerecord-5_1.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "rubygem-activerecord-5_1"
Wed Sep 13 22:35:20 2017 rev:2 rq:523504 version:5.1.4
Changes:
--------
---
/work/SRC/openSUSE:Factory/rubygem-activerecord-5_1/rubygem-activerecord-5_1.changes
2017-09-04 12:36:17.623754820 +0200
+++
/work/SRC/openSUSE:Factory/.rubygem-activerecord-5_1.new/rubygem-activerecord-5_1.changes
2017-09-13 22:36:14.985647256 +0200
@@ -1,0 +2,5 @@
+Mon Sep 11 09:22:02 UTC 2017 - [email protected]
+
+- Update to version 5.1.4
+
+-------------------------------------------------------------------
Old:
----
activerecord-5.1.3.gem
New:
----
activerecord-5.1.4.gem
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ rubygem-activerecord-5_1.spec ++++++
--- /var/tmp/diff_new_pack.bFwBVL/_old 2017-09-13 22:36:15.737541391 +0200
+++ /var/tmp/diff_new_pack.bFwBVL/_new 2017-09-13 22:36:15.737541391 +0200
@@ -24,7 +24,7 @@
#
Name: rubygem-activerecord-5_1
-Version: 5.1.3
+Version: 5.1.4
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.1.3.gem -> activerecord-5.1.4.gem ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/CHANGELOG.md new/CHANGELOG.md
--- old/CHANGELOG.md 2017-08-03 21:13:00.000000000 +0200
+++ new/CHANGELOG.md 2017-09-08 02:48:53.000000000 +0200
@@ -1,3 +1,42 @@
+## Rails 5.1.4 (September 07, 2017) ##
+
+* No changes.
+
+
+## Rails 5.1.4.rc1 (August 24, 2017) ##
+
+* Ensure `sum` honors `distinct` on `has_many :through` associations
+
+ Fixes #16791
+
+ *Aaron Wortham
+
+* Fix `COUNT(DISTINCT ...)` with `ORDER BY` and `LIMIT` to keep the existing
select list.
+
+ *Ryuta Kamizono*
+
+* Fix `unscoped(where: [columns])` removing the wrong bind values
+
+ When the `where` is called on a relation after a `or`, unscoping the
column of that later `where`, it removed
+ bind values used by the `or` instead.
+
+ ```
+ Post.where(id: 1).or(Post.where(id: 2)).where(foo: 3).unscope(where:
:foo).to_sql
+ # Currently:
+ # SELECT "posts".* FROM "posts" WHERE ("posts"."id" = 2 OR
"posts"."id" = 3)
+ # With fix:
+ # SELECT "posts".* FROM "posts" WHERE ("posts"."id" = 1 OR
"posts"."id" = 2)
+ ```
+
+ *Maxime Handfield Lapointe*
+
+* When a `has_one` association is destroyed by `dependent: destroy`,
+ `destroyed_by_association` will now be set to the reflection, matching the
+ behaviour of `has_many` associations.
+
+ *Lisa Ugray*
+
+
## Rails 5.1.3 (August 03, 2017) ##
* 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/associations/association_scope.rb
new/lib/active_record/associations/association_scope.rb
--- old/lib/active_record/associations/association_scope.rb 2017-08-03
21:13:00.000000000 +0200
+++ new/lib/active_record/associations/association_scope.rb 2017-09-08
02:48:53.000000000 +0200
@@ -66,11 +66,11 @@
foreign_key = join_keys.foreign_key
value = transform_value(owner[foreign_key])
- scope = scope.where(table.name => { key => value })
+ scope = apply_scope(scope, table, key, value)
if reflection.type
polymorphic_type = transform_value(owner.class.base_class.name)
- scope = scope.where(table.name => { reflection.type =>
polymorphic_type })
+ scope = apply_scope(scope, table, reflection.type,
polymorphic_type)
end
scope
@@ -89,10 +89,10 @@
if reflection.type
value = transform_value(next_reflection.klass.base_class.name)
- scope = scope.where(table.name => { reflection.type => value })
+ scope = apply_scope(scope, table, reflection.type, value)
end
- scope = scope.joins(join(foreign_table, constraint))
+ scope.joins!(join(foreign_table, constraint))
end
class ReflectionProxy < SimpleDelegator # :nodoc:
@@ -163,6 +163,14 @@
scope
end
+ def apply_scope(scope, table, key, value)
+ if scope.table == table
+ scope.where!(key => value)
+ else
+ scope.where!(table.name => { key => value })
+ end
+ end
+
def eval_scope(klass, table, scope, owner)
predicate_builder = PredicateBuilder.new(TableMetadata.new(klass,
table))
ActiveRecord::Relation.create(klass, table,
predicate_builder).instance_exec(owner, &scope)
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
2017-08-03 21:13:00.000000000 +0200
+++ new/lib/active_record/associations/collection_association.rb
2017-09-08 02:48:53.000000000 +0200
@@ -53,11 +53,14 @@
pk_type = reflection.association_primary_key_type
ids = Array(ids).reject(&:blank?)
ids.map! { |i| pk_type.cast(i) }
- records = klass.where(reflection.association_primary_key =>
ids).index_by do |r|
- r.send(reflection.association_primary_key)
+
+ primary_key = reflection.association_primary_key
+ records = klass.where(primary_key => ids).index_by do |r|
+ r.public_send(primary_key)
end.values_at(*ids).compact
+
if records.size != ids.size
- klass.all.raise_record_not_found_exception!(ids, records.size,
ids.size, reflection.association_primary_key)
+ klass.all.raise_record_not_found_exception!(ids, records.size,
ids.size, primary_key)
else
replace(records)
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/lib/active_record/associations/has_one_association.rb
new/lib/active_record/associations/has_one_association.rb
--- old/lib/active_record/associations/has_one_association.rb 2017-08-03
21:13:00.000000000 +0200
+++ new/lib/active_record/associations/has_one_association.rb 2017-09-08
02:48:53.000000000 +0200
@@ -56,6 +56,7 @@
when :delete
target.delete
when :destroy
+ target.destroyed_by_association = reflection
target.destroy
when :nullify
target.update_columns(reflection.foreign_key => nil) if
target.persisted?
@@ -78,6 +79,7 @@
when :delete
target.delete
when :destroy
+ target.destroyed_by_association = reflection
target.destroy
else
nullify_owner_attributes(target)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/lib/active_record/associations/preloader/association.rb
new/lib/active_record/associations/preloader/association.rb
--- old/lib/active_record/associations/preloader/association.rb 2017-08-03
21:13:00.000000000 +0200
+++ new/lib/active_record/associations/preloader/association.rb 2017-09-08
02:48:53.000000000 +0200
@@ -162,7 +162,7 @@
end
scope.unscope_values = Array(values[:unscope]) +
Array(preload_values[:unscope])
- klass.default_scoped.merge(scope)
+ klass.scope_for_association.merge(scope)
end
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/lib/active_record/associations/through_association.rb
new/lib/active_record/associations/through_association.rb
--- old/lib/active_record/associations/through_association.rb 2017-08-03
21:13:00.000000000 +0200
+++ new/lib/active_record/associations/through_association.rb 2017-09-08
02:48:53.000000000 +0200
@@ -13,7 +13,7 @@
def target_scope
scope = super
reflection.chain.drop(1).each do |reflection|
- relation = reflection.klass.all
+ relation = reflection.klass.scope_for_association
scope.merge!(
relation.except(:select, :create_with, :includes, :preload,
:joins, :eager_load)
)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/active_record/associations.rb
new/lib/active_record/associations.rb
--- old/lib/active_record/associations.rb 2017-08-03 21:13:00.000000000
+0200
+++ new/lib/active_record/associations.rb 2017-09-08 02:48:53.000000000
+0200
@@ -222,13 +222,6 @@
autoload :CollectionAssociation
autoload :ForeignAssociation
autoload :CollectionProxy
-
- autoload :BelongsToAssociation
- autoload :BelongsToPolymorphicAssociation
- autoload :HasManyAssociation
- autoload :HasManyThroughAssociation
- autoload :HasOneAssociation
- autoload :HasOneThroughAssociation
autoload :ThroughAssociation
module Builder #:nodoc:
@@ -243,6 +236,13 @@
end
eager_autoload do
+ autoload :BelongsToAssociation
+ autoload :BelongsToPolymorphicAssociation
+ autoload :HasManyAssociation
+ autoload :HasManyThroughAssociation
+ autoload :HasOneAssociation
+ autoload :HasOneThroughAssociation
+
autoload :Preloader
autoload :JoinDependency
autoload :AssociationScope
@@ -342,17 +342,18 @@
# | | belongs_to |
# generated methods | belongs_to | :polymorphic |
has_one
#
----------------------------------+------------+--------------+---------
- # other(force_reload=false) | X | X | X
+ # other | X | X | X
# other=(other) | X | X | X
# build_other(attributes={}) | X | | X
# create_other(attributes={}) | X | | X
# create_other!(attributes={}) | X | | X
+ # reload_other | X | X | X
#
# === Collection associations (one-to-many / many-to-many)
# | | | has_many
# generated methods | habtm | has_many | :through
# ----------------------------------+-------+----------+----------
- # others(force_reload=false) | X | X | X
+ # others | X | X | X
# others=(other,other,...) | X | X | X
# other_ids | X | X | X
# other_ids=(id,id,...) | X | X | X
@@ -376,6 +377,7 @@
# others.exists? | X | X | X
# others.distinct | X | X | X
# others.reset | X | X | X
+ # others.reload | X | X | X
#
# === Overriding generated methods
#
@@ -1188,8 +1190,8 @@
# <tt>has_many :clients</tt> would add among others
<tt>clients.empty?</tt>.
#
# [collection(force_reload = false)]
- # Returns an array of all the associated objects.
- # An empty array is returned if none are found.
+ # Returns a Relation of all the associated objects.
+ # An empty Relation is returned if none are found.
# [collection<<(object, ...)]
# Adds one or more objects to the collection by setting their
foreign keys to the collection's primary key.
# Note that this operation instantly fires update SQL without
waiting for the save or update call on the
@@ -1246,6 +1248,9 @@
# [collection.create!(attributes = {})]
# Does the same as <tt>collection.create</tt>, but raises
ActiveRecord::RecordInvalid
# if the record is invalid.
+ # [collection.reload]
+ # Returns a Relation of all of the associated objects, forcing a
database read.
+ # An empty Relation is returned if none are found.
#
# === Example
#
@@ -1265,6 +1270,7 @@
# * <tt>Firm#clients.build</tt> (similar to <tt>Client.new("firm_id"
=> id)</tt>)
# * <tt>Firm#clients.create</tt> (similar to <tt>c =
Client.new("firm_id" => id); c.save; c</tt>)
# * <tt>Firm#clients.create!</tt> (similar to <tt>c =
Client.new("firm_id" => id); c.save!</tt>)
+ # * <tt>Firm#clients.reload</tt>
# The declaration can also include an +options+ hash to specialize the
behavior of the association.
#
# === Scopes
@@ -1407,7 +1413,7 @@
# +association+ is a placeholder for the symbol passed as the +name+
argument, so
# <tt>has_one :manager</tt> would add among others
<tt>manager.nil?</tt>.
#
- # [association(force_reload = false)]
+ # [association]
# Returns the associated object. +nil+ is returned if none is found.
# [association=(associate)]
# Assigns the associate object, extracts the primary key, sets it as
the foreign key,
@@ -1424,6 +1430,8 @@
# [create_association!(attributes = {})]
# Does the same as <tt>create_association</tt>, but raises
ActiveRecord::RecordInvalid
# if the record is invalid.
+ # [reload_association]
+ # Returns the associated object, forcing a database read.
#
# === Example
#
@@ -1433,6 +1441,7 @@
# * <tt>Account#build_beneficiary</tt> (similar to
<tt>Beneficiary.new("account_id" => id)</tt>)
# * <tt>Account#create_beneficiary</tt> (similar to <tt>b =
Beneficiary.new("account_id" => id); b.save; b</tt>)
# * <tt>Account#create_beneficiary!</tt> (similar to <tt>b =
Beneficiary.new("account_id" => id); b.save!; b</tt>)
+ # * <tt>Account#reload_beneficiary</tt>
#
# === Scopes
#
@@ -1539,7 +1548,7 @@
# +association+ is a placeholder for the symbol passed as the +name+
argument, so
# <tt>belongs_to :author</tt> would add among others
<tt>author.nil?</tt>.
#
- # [association(force_reload = false)]
+ # [association]
# Returns the associated object. +nil+ is returned if none is found.
# [association=(associate)]
# Assigns the associate object, extracts the primary key, and sets
it as the foreign key.
@@ -1553,6 +1562,8 @@
# [create_association!(attributes = {})]
# Does the same as <tt>create_association</tt>, but raises
ActiveRecord::RecordInvalid
# if the record is invalid.
+ # [reload_association]
+ # Returns the associated object, forcing a database read.
#
# === Example
#
@@ -1562,6 +1573,7 @@
# * <tt>Post#build_author</tt> (similar to <tt>post.author =
Author.new</tt>)
# * <tt>Post#create_author</tt> (similar to <tt>post.author =
Author.new; post.author.save; post.author</tt>)
# * <tt>Post#create_author!</tt> (similar to <tt>post.author =
Author.new; post.author.save!; post.author</tt>)
+ # * <tt>Post#reload_author</tt>
# The declaration can also include an +options+ hash to specialize the
behavior of the association.
#
# === Scopes
@@ -1701,9 +1713,9 @@
# +collection+ is a placeholder for the symbol passed as the +name+
argument, so
# <tt>has_and_belongs_to_many :categories</tt> would add among others
<tt>categories.empty?</tt>.
#
- # [collection(force_reload = false)]
- # Returns an array of all the associated objects.
- # An empty array is returned if none are found.
+ # [collection]
+ # Returns a Relation of all the associated objects.
+ # An empty Relation is returned if none are found.
# [collection<<(object, ...)]
# Adds one or more objects to the collection by creating
associations in the join table
# (<tt>collection.push</tt> and <tt>collection.concat</tt> are
aliases to this method).
@@ -1741,6 +1753,9 @@
# Returns a new object of the collection type that has been
instantiated
# with +attributes+, linked to this object through the join table,
and that has already been
# saved (if it passed the validation).
+ # [collection.reload]
+ # Returns a Relation of all of the associated objects, forcing a
database read.
+ # An empty Relation is returned if none are found.
#
# === Example
#
@@ -1759,6 +1774,7 @@
# * <tt>Developer#projects.exists?(...)</tt>
# * <tt>Developer#projects.build</tt> (similar to
<tt>Project.new("developer_id" => id)</tt>)
# * <tt>Developer#projects.create</tt> (similar to <tt>c =
Project.new("developer_id" => id); c.save; c</tt>)
+ # * <tt>Developer#projects.reload</tt>
# The declaration may include an +options+ hash to specialize the
behavior of the association.
#
# === Scopes
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/active_record/attribute.rb
new/lib/active_record/attribute.rb
--- old/lib/active_record/attribute.rb 2017-08-03 21:13:00.000000000 +0200
+++ new/lib/active_record/attribute.rb 2017-09-08 02:48:53.000000000 +0200
@@ -122,7 +122,7 @@
def encode_with(coder)
coder["name"] = name
- coder["value_before_type_cast"] = value_before_type_cast if
value_before_type_cast
+ coder["value_before_type_cast"] = value_before_type_cast unless
value_before_type_cast.nil?
coder["type"] = type if type
coder["original_attribute"] = original_attribute if original_attribute
coder["value"] = value if defined?(@value)
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 2017-08-03
21:13:00.000000000 +0200
+++ new/lib/active_record/attribute_methods/dirty.rb 2017-09-08
02:48:53.000000000 +0200
@@ -4,7 +4,7 @@
module ActiveRecord
module AttributeMethods
- module Dirty # :nodoc:
+ module Dirty
extend ActiveSupport::Concern
include ActiveModel::Dirty
@@ -68,33 +68,33 @@
@mutations_from_database = AttributeMutationTracker.new(@attributes)
end
- def changes_applied
+ def changes_applied # :nodoc:
@previous_mutation_tracker = mutation_tracker
@changed_attributes = ActiveSupport::HashWithIndifferentAccess.new
clear_mutation_trackers
end
- def clear_changes_information
+ def clear_changes_information # :nodoc:
@previous_mutation_tracker = nil
@changed_attributes = ActiveSupport::HashWithIndifferentAccess.new
forget_attribute_assignments
clear_mutation_trackers
end
- def raw_write_attribute(attr_name, *)
+ def raw_write_attribute(attr_name, *) # :nodoc:
result = super
clear_attribute_change(attr_name)
result
end
- def clear_attribute_changes(attr_names)
+ def clear_attribute_changes(attr_names) # :nodoc:
super
attr_names.each do |attr_name|
clear_attribute_change(attr_name)
end
end
- def changed_attributes
+ def changed_attributes # :nodoc:
# This should only be set by methods which will call changed_attributes
# multiple times when it is known that the computed value cannot
change.
if defined?(@cached_changed_attributes)
@@ -105,14 +105,14 @@
end
end
- def changes
+ def changes # :nodoc:
cache_changed_attributes do
emit_warning_if_needed("changes", "saved_changes")
super
end
end
- def previous_changes
+ def previous_changes # :nodoc:
unless previous_mutation_tracker.equal?(mutations_before_last_save)
ActiveSupport::Deprecation.warn(<<-EOW.strip_heredoc)
The behavior of `previous_changes` inside of after callbacks is
@@ -124,7 +124,7 @@
previous_mutation_tracker.changes
end
- def attribute_changed_in_place?(attr_name)
+ def attribute_changed_in_place?(attr_name) # :nodoc:
mutation_tracker.changed_in_place?(attr_name)
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 2017-08-03
21:13:00.000000000 +0200
+++ new/lib/active_record/collection_cache_key.rb 2017-09-08
02:48:53.000000000 +0200
@@ -14,7 +14,7 @@
column =
"#{connection.quote_table_name(collection.table_name)}.#{connection.quote_column_name(timestamp_column)}"
select_values = "COUNT(*) AS #{connection.quote_column_name("size")},
MAX(%s) AS timestamp"
- if collection.limit_value || collection.offset_value
+ if collection.has_limit_or_offset?
query = collection.spawn
query.select_values = [column]
subquery_alias = "subquery_for_cache_key"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
new/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
--- old/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
2017-08-03 21:13:00.000000000 +0200
+++ new/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
2017-09-08 02:48:53.000000000 +0200
@@ -71,12 +71,12 @@
@statements =
StatementPool.new(self.class.type_cast_config_to_integer(config[:statement_limit]))
if version < "5.1.10"
- raise "Your version of MySQL
(#{full_version.match(/^\d+\.\d+\.\d+/)[0]}) is too old. Active Record supports
MySQL >= 5.1.10."
+ raise "Your version of MySQL (#{version_string}) is too old. Active
Record supports MySQL >= 5.1.10."
end
end
def version #:nodoc:
- @version ||= Version.new(full_version.match(/^\d+\.\d+\.\d+/)[0])
+ @version ||= Version.new(version_string)
end
def mariadb? # :nodoc:
@@ -340,8 +340,8 @@
def new_column_from_field(table_name, field) # :nodoc:
type_metadata = fetch_type_metadata(field[:Type], field[:Extra])
- if type_metadata.type == :datetime && field[:Default] ==
"CURRENT_TIMESTAMP"
- default, default_function = nil, field[:Default]
+ if type_metadata.type == :datetime &&
/\ACURRENT_TIMESTAMP(?:\(\))?\z/i.match?(field[:Default])
+ default, default_function = nil, "CURRENT_TIMESTAMP"
else
default, default_function = field[:Default], nil
end
@@ -914,12 +914,11 @@
end
end
+ def version_string
+ full_version.match(/^(?:5\.5\.5-)?(\d+\.\d+\.\d+)/)[1]
+ end
+
class MysqlJson < Type::Internal::AbstractJson # :nodoc:
- def changed_in_place?(raw_old_value, new_value)
- # Normalization is required because MySQL JSON data format includes
- # the space between the elements.
- super(serialize(deserialize(raw_old_value)), new_value)
- end
end
class MysqlString < Type::String # :nodoc:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/lib/active_record/connection_adapters/mysql/schema_dumper.rb
new/lib/active_record/connection_adapters/mysql/schema_dumper.rb
--- old/lib/active_record/connection_adapters/mysql/schema_dumper.rb
2017-08-03 21:13:00.000000000 +0200
+++ new/lib/active_record/connection_adapters/mysql/schema_dumper.rb
2017-09-08 02:48:53.000000000 +0200
@@ -53,7 +53,7 @@
end
def extract_expression_for_virtual_column(column)
- if mariadb?
+ if mariadb? && version < "10.2.5"
create_table_info = create_table_info(column.table_name)
if %r/#{quote_column_name(column.name)}
#{Regexp.quote(column.sql_type)}(?: COLLATE \w+)? AS \((?<expression>.+?)\)
#{column.extra}/ =~ create_table_info
$~[:expression].inspect
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/lib/active_record/connection_adapters/postgresql/oid/jsonb.rb
new/lib/active_record/connection_adapters/postgresql/oid/jsonb.rb
--- old/lib/active_record/connection_adapters/postgresql/oid/jsonb.rb
2017-08-03 21:13:00.000000000 +0200
+++ new/lib/active_record/connection_adapters/postgresql/oid/jsonb.rb
2017-09-08 02:48:53.000000000 +0200
@@ -6,16 +6,6 @@
def type
:jsonb
end
-
- def changed_in_place?(raw_old_value, new_value)
- # Postgres does not preserve insignificant whitespaces when
- # round-tripping jsonb columns. This causes some false positives
for
- # the comparison here. Therefore, we need to parse and re-dump the
- # raw value here to ensure the insignificant whitespaces are
- # consistent with our encoder's output.
- raw_old_value = serialize(deserialize(raw_old_value))
- super(raw_old_value, new_value)
- end
end
end
end
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 2017-08-03 21:13:00.000000000
+0200
+++ new/lib/active_record/gem_version.rb 2017-09-08 02:48:53.000000000
+0200
@@ -7,7 +7,7 @@
module VERSION
MAJOR = 5
MINOR = 1
- 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 2017-08-03 21:13:00.000000000 +0200
+++ new/lib/active_record/reflection.rb 2017-09-08 02:48:53.000000000 +0200
@@ -197,16 +197,8 @@
end
def klass_join_scope(table, predicate_builder) # :nodoc:
- if klass.current_scope && klass.current_scope.values.empty?
- klass.unscoped
- else
- relation = ActiveRecord::Relation.create(
- klass,
- table,
- predicate_builder,
- )
- klass.send(:build_default_scope, relation)
- end
+ relation = ActiveRecord::Relation.create(klass, table,
predicate_builder)
+ klass.scope_for_association(relation)
end
def constraints
@@ -692,6 +684,10 @@
Associations::HasManyAssociation
end
end
+
+ def association_primary_key(klass = nil)
+ primary_key(klass || self.klass)
+ end
end
class HasOneReflection < AssociationReflection # :nodoc:
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 2017-08-03
21:13:00.000000000 +0200
+++ new/lib/active_record/relation/calculations.rb 2017-09-08
02:48:53.000000000 +0200
@@ -111,7 +111,7 @@
def calculate(operation, column_name)
if has_include?(column_name)
relation = construct_relation_for_association_calculations
- relation = relation.distinct if operation.to_s.downcase == "count"
+ relation.distinct! if operation.to_s.downcase == "count"
relation.calculate(operation, column_name)
else
@@ -194,8 +194,13 @@
if operation == "count"
column_name ||= select_for_count
- column_name = primary_key if column_name == :all && distinct
- distinct = nil if column_name =~ /\s*DISTINCT[\s(]+/i
+ if column_name == :all
+ if distinct && !(has_limit_or_offset? && order_values.any?)
+ column_name = primary_key
+ end
+ elsif column_name =~ /\s*DISTINCT[\s(]+/i
+ distinct = nil
+ end
end
if group_values.any?
@@ -222,7 +227,7 @@
def execute_simple_calculation(operation, column_name, distinct) #:nodoc:
column_alias = column_name
- if operation == "count" && (limit_value || offset_value)
+ if operation == "count" && has_limit_or_offset?
# Shortcut when limit is zero.
return 0 if limit_value == 0
@@ -234,6 +239,9 @@
column = aggregate_column(column_name)
select_value = operation_over_aggregate_column(column, operation,
distinct)
+ if operation == "sum" && distinct
+ select_value.distinct = true
+ end
column_alias = select_value.alias
column_alias ||=
@klass.connection.column_name_for_operation(operation, select_value)
@@ -361,16 +369,19 @@
end
def build_count_subquery(relation, column_name, distinct)
- column_alias = Arel.sql("count_column")
- subquery_alias = Arel.sql("subquery_for_count")
+ relation.select_values = [
+ if column_name == :all
+ distinct ? table[Arel.star] : Arel.sql("1")
+ else
+ column_alias = Arel.sql("count_column")
+ aggregate_column(column_name).as(column_alias)
+ end
+ ]
+
+ subquery = relation.arel.as(Arel.sql("subquery_for_count"))
+ select_value = operation_over_aggregate_column(column_alias ||
Arel.star, "count", false)
- aliased_column = aggregate_column(column_name == :all ? 1 :
column_name).as(column_alias)
- relation.select_values = [aliased_column]
- subquery = relation.arel.as(subquery_alias)
-
- sm = Arel::SelectManager.new relation.engine
- select_value = operation_over_aggregate_column(column_alias, "count",
distinct)
- sm.project(select_value).from(subquery)
+ Arel::SelectManager.new(subquery).project(select_value)
end
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/active_record/relation/where_clause.rb
new/lib/active_record/relation/where_clause.rb
--- old/lib/active_record/relation/where_clause.rb 2017-08-03
21:13:00.000000000 +0200
+++ new/lib/active_record/relation/where_clause.rb 2017-09-08
02:48:53.000000000 +0200
@@ -136,10 +136,11 @@
binds_index = 0
predicates = self.predicates.reject do |node|
+ binds_contains = node.grep(Arel::Nodes::BindParam).size if
node.is_a?(Arel::Nodes::Node)
+
except = \
case node
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
- binds_contains = node.grep(Arel::Nodes::BindParam).size
subrelation = (node.left.kind_of?(Arel::Attributes::Attribute)
? node.left : node.right)
columns.include?(subrelation.name.to_s)
end
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 2017-08-03 21:13:00.000000000 +0200
+++ new/lib/active_record/relation.rb 2017-09-08 02:48:53.000000000 +0200
@@ -642,6 +642,14 @@
"#<#{self.class.name} [#{entries.join(', ')}]>"
end
+ def empty_scope? # :nodoc:
+ @values == klass.unscoped.values
+ end
+
+ def has_limit_or_offset? # :nodoc:
+ limit_value || offset_value
+ end
+
protected
def load_records(records)
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 2017-08-03 21:13:00.000000000
+0200
+++ new/lib/active_record/scoping/named.rb 2017-09-08 02:48:53.000000000
+0200
@@ -29,8 +29,17 @@
end
end
- def default_scoped # :nodoc:
- scope = relation
+ def scope_for_association(scope = relation) # :nodoc:
+ current_scope = self.current_scope
+
+ if current_scope && current_scope.empty_scope?
+ scope
+ else
+ default_scoped(scope)
+ end
+ end
+
+ def default_scoped(scope = relation) # :nodoc:
build_default_scope(scope) || scope
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/active_record/tasks/postgresql_database_tasks.rb
new/lib/active_record/tasks/postgresql_database_tasks.rb
--- old/lib/active_record/tasks/postgresql_database_tasks.rb 2017-08-03
21:13:00.000000000 +0200
+++ new/lib/active_record/tasks/postgresql_database_tasks.rb 2017-09-08
02:48:53.000000000 +0200
@@ -20,7 +20,7 @@
configuration.merge("encoding" => encoding)
establish_connection configuration
rescue ActiveRecord::StatementInvalid => error
- if /database .* already exists/.match?(error.message)
+ if error.cause.is_a?(PG::DuplicateDatabase)
raise DatabaseAlreadyExists
else
raise
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/active_record/type/internal/abstract_json.rb
new/lib/active_record/type/internal/abstract_json.rb
--- old/lib/active_record/type/internal/abstract_json.rb 2017-08-03
21:13:00.000000000 +0200
+++ new/lib/active_record/type/internal/abstract_json.rb 2017-09-08
02:48:53.000000000 +0200
@@ -24,6 +24,10 @@
end
end
+ def changed_in_place?(raw_old_value, new_value)
+ deserialize(raw_old_value) != new_value
+ end
+
def accessor
ActiveRecord::Store::StringKeyedHashAccessor
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/metadata new/metadata
--- old/metadata 2017-08-03 21:13:00.000000000 +0200
+++ new/metadata 2017-09-08 02:48:53.000000000 +0200
@@ -1,14 +1,14 @@
--- !ruby/object:Gem::Specification
name: activerecord
version: !ruby/object:Gem::Version
- version: 5.1.3
+ version: 5.1.4
platform: ruby
authors:
- David Heinemeier Hansson
autorequire:
bindir: bin
cert_chain: []
-date: 2017-08-03 00:00:00.000000000 Z
+date: 2017-09-08 00:00:00.000000000 Z
dependencies:
- !ruby/object:Gem::Dependency
name: activesupport
@@ -16,28 +16,28 @@
requirements:
- - '='
- !ruby/object:Gem::Version
- version: 5.1.3
+ version: 5.1.4
type: :runtime
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - '='
- !ruby/object:Gem::Version
- version: 5.1.3
+ version: 5.1.4
- !ruby/object:Gem::Dependency
name: activemodel
requirement: !ruby/object:Gem::Requirement
requirements:
- - '='
- !ruby/object:Gem::Version
- version: 5.1.3
+ version: 5.1.4
type: :runtime
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - '='
- !ruby/object:Gem::Version
- version: 5.1.3
+ version: 5.1.4
- !ruby/object:Gem::Dependency
name: arel
requirement: !ruby/object:Gem::Requirement
@@ -338,7 +338,7 @@
version: '0'
requirements: []
rubyforge_project:
-rubygems_version: 2.6.12
+rubygems_version: 2.6.13
signing_key:
specification_version: 4
summary: Object-relational mapper framework (part of Rails).