Script 'mail_helper' called by obssrc
Hello community,
here is the log from the commit of package rubygem-activerecord-7.0 for
openSUSE:Factory checked in at 2023-11-15 21:08:23
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/rubygem-activerecord-7.0 (Old)
and /work/SRC/openSUSE:Factory/.rubygem-activerecord-7.0.new.17445 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "rubygem-activerecord-7.0"
Wed Nov 15 21:08:23 2023 rev:10 rq:1126244 version:7.0.8
Changes:
--------
---
/work/SRC/openSUSE:Factory/rubygem-activerecord-7.0/rubygem-activerecord-7.0.changes
2023-07-03 17:43:16.300890348 +0200
+++
/work/SRC/openSUSE:Factory/.rubygem-activerecord-7.0.new.17445/rubygem-activerecord-7.0.changes
2023-11-15 21:09:44.674814215 +0100
@@ -1,0 +2,553 @@
+Tue Nov 14 14:45:36 UTC 2023 - Dan Äermák <[email protected]>
+
+- 7.0.8:
+
+
+## Active Support
+
+* Fix `TimeWithZone` still using deprecated `#to_s` when `ENV` or `config` to
+ disable it are set.
+
+ *Hartley McGuire*
+
+* Fix CacheStore#write_multi when using a distributed Redis cache with a
connection pool.
+
+ Fixes [#48938](https://github.com/rails/rails/issues/48938).
+
+ *Jonathan del Strother*
+
+
+
+## Active Model
+
+* No changes.
+
+
+
+## Active Record
+
+* Fix `change_column` not setting `precision: 6` on `datetime` columns when
+ using 7.0+ Migrations and SQLite.
+
+ *Hartley McGuire*
+
+* Fix unscope is not working in specific case
+
+ Before:
+ ```ruby
+ Post.where(id: 1...3).unscope(where: :id).to_sql # "SELECT `posts`.* FROM
`posts` WHERE `posts`.`id` >= 1 AND `posts`.`id` < 3"
+
+ ```
+
+ After:
+ ```ruby
+ Post.where(id: 1...3).unscope(where: :id).to_sql # "SELECT `posts`.* FROM
`posts`"
+ ```
+
+ Fixes #48094.
+
+ *Kazuya Hatanaka*
+
+* Fix associations to a STI model including a `class_name` parameter
+
+ ```ruby
+ class Product < ApplicationRecord
+ has_many :requests, as: :requestable, class_name: "ProductRequest",
dependent: :destroy
+ end
+
+ # STI tables
+ class Request < ApplicationRecord
+ belongs_to :requestable, polymorphic: true
+
+ validate :request_type, presence: true
+ end
+
+ class ProductRequest < Request
+ belongs_to :user
+ end
+ ```
+
+ Accessing such association would lead to:
+
+ ```
+ table_metadata.rb:22:in `has_column?': undefined method `key?' for
nil:NilClass (NoMethodError)
+ ```
+
+ *Romain Filinto*
+
+* Fix `change_table` setting datetime precision for 6.1 Migrations
+
+ *Hartley McGuire*
+
+* Fix change_column setting datetime precision for 6.1 Migrations
+
+ *Hartley McGuire*
+
+
+## Action View
+
+* Fix `form_for` missing the hidden `_method` input for models with a
+ namespaced route.
+
+ *Hartley McGuire*
+
+* Fix `render collection: @records, cache: true` inside `jbuilder` templates
+
+ The previous fix that shipped in `7.0.7` assumed template fragments are
always strings,
+ this isn't true with `jbuilder`.
+
+ *Jean Boussier*
+
+
+## Action Pack
+
+* Fix `HostAuthorization` potentially displaying the value of the
+ X_FORWARDED_HOST header when the HTTP_HOST header is being blocked.
+
+ *Hartley McGuire*, *Daniel Schlosser*
+
+
+
+## Active Job
+
+* Fix Active Job log message to correctly report a job failed to enqueue
+ when the adapter raises an `ActiveJob::EnqueueError`.
+
+ *Ben Sheldon*
+
+
+
+## Action Mailer
+
+* No changes.
+
+
+
+## Action Cable
+
+* No changes.
+
+
+
+## Active Storage
+
+* No changes.
+
+
+
+## Action Mailbox
+
+* No changes.
+
+
+
+## Action Text
+
+* No changes.
+
+
+
+## Railties
+
+* Omit `webdrivers` gem dependency from `Gemfile` template
+
+ *Sean Doyle*
+
+
+
+
+7.0.7.2:
+
+No changes between this and 7.0.7.2. This release was just to fix file
permissions in the previous release.
+
+7.0.7.1:
+
+
+## Active Support
+
+* Use a temporary file for storing unencrypted files while editing
+
+ [CVE-2023-38037]
+
+
+
+## Active Model
+
+* No changes.
+
+
+
+## Active Record
+
+* No changes.
+
+
+
+## Action View
+
+* No changes.
+
+
+
+## Action Pack
+
+* No changes.
+
+
+
+## Active Job
+
+* No changes.
+
+
+
+## Action Mailer
+
+* No changes.
+
+
+
+## Action Cable
+
+* No changes.
+
+
+
+## Active Storage
+
+* No changes.
+
+
+
+## Action Mailbox
+
+* No changes.
+
+
+
+## Action Text
+
+* No changes.
+
+
+
+## Railties
+
+* No changes.
+
+
+
+
+7.0.7:
+
+
+## Active Support
+
+* Fix `Cache::NullStore` with local caching for repeated reads.
+
+ *fatkodima*
+
+* Fix `to_s` with no arguments not respecting custom `:default` formats
+
+ *Hartley McGuire*
+
+* Fix `ActiveSupport::Inflector.humanize(nil)` raising ``NoMethodError:
undefined method `end_with?' for nil:NilClass``.
+
+ *James Robinson*
+
+* Fix `Enumerable#sum` for `Enumerator#lazy`.
+
+ *fatkodima*, *Matthew Draper*, *Jonathan Hefner*
+
+* Improve error message when EventedFileUpdateChecker is used without a
+ compatible version of the Listen gem
+
+ *Hartley McGuire*
+
+
+
+## Active Model
+
+* Error.full_message now strips ":base" from the message.
+
+ *zzak*
+
+* Add a load hook for `ActiveModel::Model` (named `active_model`) to match
the load hook for
+ `ActiveRecord::Base` and allow for overriding aspects of the
`ActiveModel::Model` class.
+
+
+
+## Active Record
+
+* Restores functionality to the missing method when using enums and fixes.
+
+ *paulreece*
+
+* Fix `StatementCache::Substitute` with serialized type.
+
+ *ywenc*
+
+* Fix `:db_runtime` on notification payload when application have multiple
databases.
+
+ *Eileen M. Uchitelle*
+
+* Correctly dump check constraints for MySQL 8.0.16+.
+
+ *Steve Hill*
+
++++ 256 more lines (skipped)
++++ between
/work/SRC/openSUSE:Factory/rubygem-activerecord-7.0/rubygem-activerecord-7.0.changes
++++ and
/work/SRC/openSUSE:Factory/.rubygem-activerecord-7.0.new.17445/rubygem-activerecord-7.0.changes
Old:
----
activerecord-7.0.5.1.gem
New:
----
activerecord-7.0.8.gem
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ rubygem-activerecord-7.0.spec ++++++
--- /var/tmp/diff_new_pack.DgVpGb/_old 2023-11-15 21:09:45.118830597 +0100
+++ /var/tmp/diff_new_pack.DgVpGb/_new 2023-11-15 21:09:45.118830597 +0100
@@ -24,12 +24,11 @@
#
Name: rubygem-activerecord-7.0
-Version: 7.0.5.1
+Version: 7.0.8
Release: 0
%define mod_name activerecord
%define mod_full_name %{mod_name}-%{version}
%define mod_version_suffix -7.0
-BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildRequires: %{ruby >= 2.7.0}
BuildRequires: %{rubygem gem2rpm}
BuildRequires: %{rubygem rdoc > 3.10}
@@ -39,7 +38,6 @@
Source1: gem2rpm.yml
Summary: Object-relational mapper framework (part of Rails)
License: MIT
-Group: Development/Languages/Ruby
%description
Databases on Rails. Build a persistent domain model by mapping database tables
++++++ activerecord-7.0.5.1.gem -> activerecord-7.0.8.gem ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/CHANGELOG.md new/CHANGELOG.md
--- old/CHANGELOG.md 2023-06-26 23:35:10.000000000 +0200
+++ new/CHANGELOG.md 2023-09-09 21:09:43.000000000 +0200
@@ -1,8 +1,187 @@
-## Rails 7.0.5.1 (June 26, 2023) ##
+## Rails 7.0.8 (September 09, 2023) ##
+
+* Fix `change_column` not setting `precision: 6` on `datetime` columns when
+ using 7.0+ Migrations and SQLite.
+
+ *Hartley McGuire*
+
+* Fix unscope is not working in specific case
+
+ Before:
+ ```ruby
+ Post.where(id: 1...3).unscope(where: :id).to_sql # "SELECT `posts`.* FROM
`posts` WHERE `posts`.`id` >= 1 AND `posts`.`id` < 3"
+
+ ```
+
+ After:
+ ```ruby
+ Post.where(id: 1...3).unscope(where: :id).to_sql # "SELECT `posts`.* FROM
`posts`"
+ ```
+
+ Fixes #48094.
+
+ *Kazuya Hatanaka*
+
+* Fix associations to a STI model including a `class_name` parameter
+
+ ```ruby
+ class Product < ApplicationRecord
+ has_many :requests, as: :requestable, class_name: "ProductRequest",
dependent: :destroy
+ end
+
+ # STI tables
+ class Request < ApplicationRecord
+ belongs_to :requestable, polymorphic: true
+
+ validate :request_type, presence: true
+ end
+
+ class ProductRequest < Request
+ belongs_to :user
+ end
+ ```
+
+ Accessing such association would lead to:
+
+ ```
+ table_metadata.rb:22:in `has_column?': undefined method `key?' for
nil:NilClass (NoMethodError)
+ ```
+
+ *Romain Filinto*
+
+* Fix `change_table` setting datetime precision for 6.1 Migrations
+
+ *Hartley McGuire*
+
+* Fix change_column setting datetime precision for 6.1 Migrations
+
+ *Hartley McGuire*
+
+## Rails 7.0.7.2 (August 22, 2023) ##
+
+* No changes.
+
+
+## Rails 7.0.7.1 (August 22, 2023) ##
* No changes.
+## Rails 7.0.7 (August 09, 2023) ##
+
+* Restores functionality to the missing method when using enums and fixes.
+
+ *paulreece*
+
+* Fix `StatementCache::Substitute` with serialized type.
+
+ *ywenc*
+
+* Fix `:db_runtime` on notification payload when application have multiple
databases.
+
+ *Eileen M. Uchitelle*
+
+* Correctly dump check constraints for MySQL 8.0.16+.
+
+ *Steve Hill*
+
+* Fix `ActiveRecord::QueryMethods#in_order_of` to include `nil`s, to match
the
+ behavior of `Enumerable#in_order_of`.
+
+ For example, `Post.in_order_of(:title, [nil, "foo"])` will now include
posts
+ with `nil` titles, the same as `Post.all.to_a.in_order_of(:title, [nil,
"foo"])`.
+
+ *fatkodima*
+
+* Revert "Fix autosave associations with validations added on `:base` of the
associated objects."
+
+ This change intended to remove the :base attribute from the message,
+ but broke many assumptions which key these errors were stored.
+
+ *zzak*
+
+* Fix `#previously_new_record?` to return true for destroyed records.
+
+ Before, if a record was created and then destroyed,
`#previously_new_record?` would return true.
+ Now, any UPDATE or DELETE to a record is considered a change, and will
result in `#previously_new_record?`
+ returning false.
+
+ *Adrianna Chang*
+
+* Revert breaking changes to `has_one` relationship deleting the old record
before the new one is validated.
+
+ *zzak*
+
+* Fix support for Active Record instances being uses in queries.
+
+ As of `7.0.5`, query arguments were deep duped to avoid mutations impacting
+ the query cache, but this had the adverse effect to clearing the primary
key when
+ the query argument contained an `ActiveRecord::Base` instance.
+
+ This broke the `noticed` gem.
+
+ *Jean Boussier*
+
+
+## Rails 7.0.6 (June 29, 2023) ##
+
+* Fix autosave associations with validations added on `:base` of the
associated objects.
+
+ *fatkodima*
+
+* Fix result with anonymous PostgreSQL columns of different type from json.
+
+ *Oleksandr Avoiants*
+
+* Preserve timestamp when setting an `ActiveSupport::TimeWithZone` value to
`timestamptz` attribute.
+
+ *fatkodima*
+
+* Fix assignment into an `has_one` relationship deleting the old record
before the new one is validated.
+
+ *Jean Boussier*
+
+* Fix where on association with has_one/has_many polymorphic relations.
+
+ Before:
+ ```ruby
+ Treasure.where(price_estimates: PriceEstimate.all)
+ #=> SELECT (...) WHERE "treasures"."id" IN (SELECT
"price_estimates"."estimate_of_id" FROM "price_estimates")
+ ```
+
+ Later:
+ ```ruby
+ Treasure.where(price_estimates: PriceEstimate.all)
+ #=> SELECT (...) WHERE "treasures"."id" IN (SELECT
"price_estimates"."estimate_of_id" FROM "price_estimates" WHERE
"price_estimates"."estimate_of_type" = 'Treasure')
+ ```
+
+ *Lázaro Nixon*
+
+* Fix decrementing counter caches on optimistically locked record deletion
+
+ *fatkodima*
+
+* Ensure binary-destined values have binary encoding during type cast.
+
+ *Matthew Draper*
+
+* Preserve existing column default functions when altering table in SQLite.
+
+ *fatkodima*
+
+* Remove table alias added when using `where.missing` or `where.associated`.
+
+ *fatkodima*
+
+* Fix `Enumerable#in_order_of` to only flatten first level to preserve
nesting.
+
+ *Miha Rekar*
+
+
+## Rails 7.0.5.1 (June 26, 2023) ##
+
+* No changes.
+
## Rails 7.0.5 (May 24, 2023) ##
* Type cast `#attribute_changed?` `:from` and `:to` options.
@@ -81,7 +260,7 @@
*Shota Toguchi*, *Yusaku Ono*
-* Use connection from `#with_raw_connection` in `#quote_string`.
+* Fix erroneous nil default precision on virtual datetime columns.
Prior to this change, virtual datetime columns did not have the same
default precision as regular datetime columns, resulting in the following
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/README.rdoc new/README.rdoc
--- old/README.rdoc 2023-06-26 23:35:10.000000000 +0200
+++ new/README.rdoc 2023-09-09 21:09:43.000000000 +0200
@@ -192,7 +192,7 @@
$ gem install activerecord
-Source code can be downloaded as part of the Rails project on GitHub:
+Source code can be downloaded as part of the \Rails project on GitHub:
* https://github.com/rails/rails/tree/main/activerecord
@@ -210,7 +210,7 @@
* https://api.rubyonrails.org
-Bug reports for the Ruby on Rails project can be filed here:
+Bug reports for the Ruby on \Rails project can be filed here:
* https://github.com/rails/rails/issues
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/collection_association.rb
new/lib/active_record/associations/collection_association.rb
--- old/lib/active_record/associations/collection_association.rb
2023-06-26 23:35:10.000000000 +0200
+++ new/lib/active_record/associations/collection_association.rb
2023-09-09 21:09:43.000000000 +0200
@@ -79,7 +79,7 @@
def reset
super
@target = []
- @replaced_or_added_targets = Set.new
+ @replaced_or_added_targets = Set.new.compare_by_identity
@association_ids = nil
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/active_record/associations/collection_proxy.rb
new/lib/active_record/associations/collection_proxy.rb
--- old/lib/active_record/associations/collection_proxy.rb 2023-06-26
23:35:10.000000000 +0200
+++ new/lib/active_record/associations/collection_proxy.rb 2023-09-09
21:09:43.000000000 +0200
@@ -1102,6 +1102,11 @@
super
end
+ def pretty_print(pp) # :nodoc:
+ load_target if find_from_target?
+ super
+ end
+
delegate_methods = [
QueryMethods,
SpawnMethods,
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 2023-06-26
23:35:10.000000000 +0200
+++ new/lib/active_record/associations/has_one_association.rb 2023-09-09
21:09:43.000000000 +0200
@@ -87,10 +87,6 @@
replace(record, false)
end
- def replace_keys(record, force: false)
- # Has one association doesn't have foreign keys to replace.
- end
-
def remove_target!(method)
case method
when :delete
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/lib/active_record/associations/singular_association.rb
new/lib/active_record/associations/singular_association.rb
--- old/lib/active_record/associations/singular_association.rb 2023-06-26
23:35:10.000000000 +0200
+++ new/lib/active_record/associations/singular_association.rb 2023-09-09
21:09:43.000000000 +0200
@@ -54,13 +54,11 @@
end
def _create_record(attributes, raise_error = false, &block)
- reflection.klass.transaction do
- record = build(attributes, &block)
- saved = record.save
- replace_keys(record, force: true)
- raise RecordInvalid.new(record) if !saved && raise_error
- record
- end
+ record = build_record(attributes, &block)
+ saved = record.save
+ set_new_record(record)
+ raise RecordInvalid.new(record) if !saved && raise_error
+ record
end
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
2023-06-26 23:35:10.000000000 +0200
+++ new/lib/active_record/connection_adapters/abstract/schema_statements.rb
2023-09-09 21:09:43.000000000 +0200
@@ -264,7 +264,7 @@
#
# generates:
#
- # CREATE TABLE order (
+ # CREATE TABLE orders (
# product_id bigint NOT NULL,
# client_id bigint NOT NULL
# );
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/lib/active_record/connection_adapters/abstract_adapter.rb
new/lib/active_record/connection_adapters/abstract_adapter.rb
--- old/lib/active_record/connection_adapters/abstract_adapter.rb
2023-06-26 23:35:10.000000000 +0200
+++ new/lib/active_record/connection_adapters/abstract_adapter.rb
2023-09-09 21:09:43.000000000 +0200
@@ -71,14 +71,6 @@
/\A(?:[(\s]|#{COMMENT_REGEX})*#{Regexp.union(*parts)}/
end
- def self.quoted_column_names # :nodoc:
- @quoted_column_names ||= {}
- end
-
- def self.quoted_table_names # :nodoc:
- @quoted_table_names ||= {}
- end
-
def initialize(connection, logger = nil, config = {}) # :nodoc:
super()
@@ -665,15 +657,6 @@
migration_context.current_version
end
- def field_ordered_value(column, values) # :nodoc:
- node = Arel::Nodes::Case.new(column)
- values.each.with_index(1) do |value, order|
- node.when(value).then(order)
- end
-
- Arel::Nodes::Ascending.new(node.else(values.length + 1))
- end
-
class << self
private
def initialize_type_map(m)
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
2023-06-26 23:35:10.000000000 +0200
+++ new/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
2023-09-09 21:09:43.000000000 +0200
@@ -138,11 +138,6 @@
true
end
- def field_ordered_value(column, values) # :nodoc:
- field = Arel::Nodes::NamedFunction.new("FIELD", [column,
values.reverse.map { |value| Arel::Nodes.build_quoted(value) }])
- Arel::Nodes::Descending.new(field)
- end
-
def get_advisory_lock(lock_name, timeout = 0) # :nodoc:
query_value("SELECT GET_LOCK(#{quote(lock_name.to_s)}, #{timeout})")
== 1
end
@@ -438,7 +433,8 @@
name: row["name"]
}
expression = row["expression"]
- expression = expression[1..-2] unless mariadb? # remove
parentheses added by mysql
+ expression = expression[1..-2] if expression.start_with?("(") &&
expression.end_with?(")")
+ expression = strip_whitespace_characters(expression)
CheckConstraintDefinition.new(table_name, expression, options)
end
else
@@ -619,6 +615,12 @@
end
private
+ def strip_whitespace_characters(expression)
+ expression = expression.gsub(/\\n|\\\\/, "")
+ expression = expression.gsub(/\s{2,}/, " ")
+ expression
+ end
+
def text_type?(type)
TYPE_MAP.lookup(type).is_a?(Type::String) ||
TYPE_MAP.lookup(type).is_a?(Type::Text)
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/lib/active_record/connection_adapters/mysql/database_statements.rb
new/lib/active_record/connection_adapters/mysql/database_statements.rb
--- old/lib/active_record/connection_adapters/mysql/database_statements.rb
2023-06-26 23:35:10.000000000 +0200
+++ new/lib/active_record/connection_adapters/mysql/database_statements.rb
2023-09-09 21:09:43.000000000 +0200
@@ -20,7 +20,7 @@
end
READ_QUERY =
ActiveRecord::ConnectionAdapters::AbstractAdapter.build_read_query_regexp(
- :desc, :describe, :set, :show, :use
+ :desc, :describe, :set, :show, :use, :kill
) # :nodoc:
private_constant :READ_QUERY
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/lib/active_record/connection_adapters/mysql/quoting.rb
new/lib/active_record/connection_adapters/mysql/quoting.rb
--- old/lib/active_record/connection_adapters/mysql/quoting.rb 2023-06-26
23:35:10.000000000 +0200
+++ new/lib/active_record/connection_adapters/mysql/quoting.rb 2023-09-09
21:09:43.000000000 +0200
@@ -6,6 +6,9 @@
module ConnectionAdapters
module MySQL
module Quoting # :nodoc:
+ QUOTED_COLUMN_NAMES = Concurrent::Map.new # :nodoc:
+ QUOTED_TABLE_NAMES = Concurrent::Map.new # :nodoc:
+
def quote_bound_value(value)
case value
when Rational
@@ -24,11 +27,11 @@
end
def quote_column_name(name)
- self.class.quoted_column_names[name] ||= "`#{super.gsub('`', '``')}`"
+ QUOTED_COLUMN_NAMES[name] ||= "`#{super.gsub('`', '``')}`"
end
def quote_table_name(name)
- self.class.quoted_table_names[name] ||= super.gsub(".", "`.`").freeze
+ QUOTED_TABLE_NAMES[name] ||= super.gsub(".", "`.`").freeze
end
def unquoted_true
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/lib/active_record/connection_adapters/postgresql/database_statements.rb
new/lib/active_record/connection_adapters/postgresql/database_statements.rb
--- old/lib/active_record/connection_adapters/postgresql/database_statements.rb
2023-06-26 23:35:10.000000000 +0200
+++ new/lib/active_record/connection_adapters/postgresql/database_statements.rb
2023-09-09 21:09:43.000000000 +0200
@@ -57,7 +57,7 @@
fields.each_with_index do |fname, i|
ftype = result.ftype i
fmod = result.fmod i
- types[fname] = get_oid_type(ftype, fmod, fname)
+ types[fname] = types[i] = get_oid_type(ftype, fmod, fname)
end
build_result(columns: fields, rows: result.values, column_types:
types)
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb
new/lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb
---
old/lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb
2023-06-26 23:35:10.000000000 +0200
+++
new/lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb
2023-09-09 21:09:43.000000000 +0200
@@ -13,7 +13,7 @@
return if value.blank?
time = super
- return time unless time.acts_like?(:time)
+ return time if time.is_a?(ActiveSupport::TimeWithZone) ||
!time.acts_like?(:time)
# While in UTC mode, the PG gem may not return times back in "UTC"
even if they were provided to Postgres in UTC.
# We prefer times always in UTC, so here we convert back.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/lib/active_record/connection_adapters/postgresql/quoting.rb
new/lib/active_record/connection_adapters/postgresql/quoting.rb
--- old/lib/active_record/connection_adapters/postgresql/quoting.rb
2023-06-26 23:35:10.000000000 +0200
+++ new/lib/active_record/connection_adapters/postgresql/quoting.rb
2023-09-09 21:09:43.000000000 +0200
@@ -4,6 +4,9 @@
module ConnectionAdapters
module PostgreSQL
module Quoting
+ QUOTED_COLUMN_NAMES = Concurrent::Map.new # :nodoc:
+ QUOTED_TABLE_NAMES = Concurrent::Map.new # :nodoc:
+
class IntegerOutOf64BitRange < StandardError
def initialize(msg)
super(msg)
@@ -81,7 +84,7 @@
# - "schema.name".table_name
# - "schema.name"."table.name"
def quote_table_name(name) # :nodoc:
- self.class.quoted_table_names[name] ||=
Utils.extract_schema_qualified_name(name.to_s).quoted.freeze
+ QUOTED_TABLE_NAMES[name] ||=
Utils.extract_schema_qualified_name(name.to_s).quoted.freeze
end
# Quotes schema names for use in SQL queries.
@@ -95,7 +98,7 @@
# Quotes column names for use in SQL queries.
def quote_column_name(name) # :nodoc:
- self.class.quoted_column_names[name] ||=
PG::Connection.quote_ident(super).freeze
+ QUOTED_COLUMN_NAMES[name] ||=
PG::Connection.quote_ident(super).freeze
end
# Quote date/time values for use in SQL input.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/lib/active_record/connection_adapters/sqlite3/quoting.rb
new/lib/active_record/connection_adapters/sqlite3/quoting.rb
--- old/lib/active_record/connection_adapters/sqlite3/quoting.rb
2023-06-26 23:35:10.000000000 +0200
+++ new/lib/active_record/connection_adapters/sqlite3/quoting.rb
2023-09-09 21:09:43.000000000 +0200
@@ -4,6 +4,9 @@
module ConnectionAdapters
module SQLite3
module Quoting # :nodoc:
+ QUOTED_COLUMN_NAMES = Concurrent::Map.new # :nodoc:
+ QUOTED_TABLE_NAMES = Concurrent::Map.new # :nodoc:
+
def quote_string(s)
@connection.class.quote(s)
end
@@ -13,11 +16,11 @@
end
def quote_table_name(name)
- self.class.quoted_table_names[name] ||= super.gsub(".",
"\".\"").freeze
+ QUOTED_TABLE_NAMES[name] ||= super.gsub(".", "\".\"").freeze
end
def quote_column_name(name)
- self.class.quoted_column_names[name] ||= %Q("#{super.gsub('"',
'""')}")
+ QUOTED_COLUMN_NAMES[name] ||= %Q("#{super.gsub('"', '""')}")
end
def quoted_time(value)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/lib/active_record/connection_adapters/sqlite3/schema_definitions.rb
new/lib/active_record/connection_adapters/sqlite3/schema_definitions.rb
--- old/lib/active_record/connection_adapters/sqlite3/schema_definitions.rb
2023-06-26 23:35:10.000000000 +0200
+++ new/lib/active_record/connection_adapters/sqlite3/schema_definitions.rb
2023-09-09 21:09:43.000000000 +0200
@@ -4,6 +4,12 @@
module ConnectionAdapters
module SQLite3
class TableDefinition < ActiveRecord::ConnectionAdapters::TableDefinition
+ def change_column(column_name, type, **options)
+ name = column_name.to_s
+ @columns_hash[name] = nil
+ column(name, type, **options)
+ end
+
def references(*args, **options)
super(*args, type: :integer, **options)
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/lib/active_record/connection_adapters/sqlite3/schema_statements.rb
new/lib/active_record/connection_adapters/sqlite3/schema_statements.rb
--- old/lib/active_record/connection_adapters/sqlite3/schema_statements.rb
2023-06-26 23:35:10.000000000 +0200
+++ new/lib/active_record/connection_adapters/sqlite3/schema_statements.rb
2023-09-09 21:09:43.000000000 +0200
@@ -84,11 +84,11 @@
table_sql = query_value(<<-SQL, "SCHEMA")
SELECT sql
FROM sqlite_master
- WHERE name = #{quote_table_name(table_name)} AND type = 'table'
+ WHERE name = #{quote(table_name)} AND type = 'table'
UNION ALL
SELECT sql
FROM sqlite_temp_master
- WHERE name = #{quote_table_name(table_name)} AND type = 'table'
+ WHERE name = #{quote(table_name)} AND type = 'table'
SQL
table_sql.to_s.scan(/CONSTRAINT\s+(?<name>\w+)\s+CHECK\s+\((?<expression>(:?[^()]|\(\g<expression>\))+)\)/i).map
do |name, expression|
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
2023-06-26 23:35:10.000000000 +0200
+++ new/lib/active_record/connection_adapters/sqlite3_adapter.rb
2023-09-09 21:09:43.000000000 +0200
@@ -287,10 +287,7 @@
def change_column(table_name, column_name, type, **options) # :nodoc:
alter_table(table_name) do |definition|
- definition[column_name].instance_eval do
- self.type = aliased_types(type.to_s, type)
- self.options.merge!(options)
- end
+ definition.change_column(column_name, type, **options)
end
end
@@ -480,6 +477,7 @@
if column.has_default?
type = lookup_cast_type_from_column(column)
default = type.deserialize(column.default)
+ default = -> { column.default_function } if default.nil?
end
@definition.column(column_name, column.type,
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 2023-06-26 23:35:10.000000000
+0200
+++ new/lib/active_record/gem_version.rb 2023-09-09 21:09:43.000000000
+0200
@@ -9,8 +9,8 @@
module VERSION
MAJOR = 7
MINOR = 0
- TINY = 5
- PRE = "1"
+ TINY = 8
+ PRE = nil
STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/active_record/locking/optimistic.rb
new/lib/active_record/locking/optimistic.rb
--- old/lib/active_record/locking/optimistic.rb 2023-06-26 23:35:10.000000000
+0200
+++ new/lib/active_record/locking/optimistic.rb 2023-09-09 21:09:43.000000000
+0200
@@ -2,14 +2,14 @@
module ActiveRecord
module Locking
- # == What is Optimistic Locking
+ # == What is \Optimistic \Locking
#
# Optimistic locking allows multiple users to access the same record for
edits, and assumes a minimum of
# conflicts with the data. It does this by checking whether another
process has made changes to a record since
- # it was opened, an <tt>ActiveRecord::StaleObjectError</tt> exception is
thrown if that has occurred
+ # it was opened, an ActiveRecord::StaleObjectError exception is thrown if
that has occurred
# and the update is ignored.
#
- # Check out <tt>ActiveRecord::Locking::Pessimistic</tt> for an alternative.
+ # Check out +ActiveRecord::Locking::Pessimistic+ for an alternative.
#
# == Usage
#
@@ -69,6 +69,11 @@
end
end
+ def initialize_dup(other) # :nodoc:
+ super
+ _clear_locking_column if locking_enabled?
+ end
+
private
def _create_record(attribute_names = self.attribute_names)
if locking_enabled?
@@ -91,8 +96,7 @@
locking_column = self.class.locking_column
lock_attribute_was = @attributes[locking_column]
- update_constraints = _primary_key_constraints_hash
- update_constraints[locking_column] =
_lock_value_for_database(locking_column)
+ update_constraints = _query_constraints_hash
attribute_names = attribute_names.dup if attribute_names.frozen?
attribute_names << locking_column
@@ -118,16 +122,9 @@
end
def destroy_row
- return super unless locking_enabled?
-
- locking_column = self.class.locking_column
+ affected_rows = super
- delete_constraints = _primary_key_constraints_hash
- delete_constraints[locking_column] =
_lock_value_for_database(locking_column)
-
- affected_rows = self.class._delete_record(delete_constraints)
-
- if affected_rows != 1
+ if locking_enabled? && affected_rows != 1
raise ActiveRecord::StaleObjectError.new(self, "destroy")
end
@@ -142,6 +139,18 @@
end
end
+ def _clear_locking_column
+ self[self.class.locking_column] = nil
+ clear_attribute_change(self.class.locking_column)
+ end
+
+ def _query_constraints_hash
+ return super unless locking_enabled?
+
+ locking_column = self.class.locking_column
+ super.merge(locking_column =>
_lock_value_for_database(locking_column))
+ end
+
module ClassMethods
DEFAULT_LOCKING_COLUMN = "lock_version"
@@ -159,10 +168,7 @@
end
# The version column used for optimistic locking. Defaults to
+lock_version+.
- def locking_column
- @locking_column = DEFAULT_LOCKING_COLUMN unless
defined?(@locking_column)
- @locking_column
- end
+ attr_reader :locking_column
# Reset the column used for optimistic locking back to the
+lock_version+ default.
def reset_locking_column
@@ -182,6 +188,14 @@
end
super
end
+
+ private
+ def inherited(base)
+ super
+ base.class_eval do
+ @locking_column = DEFAULT_LOCKING_COLUMN
+ end
+ end
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/active_record/migration/compatibility.rb
new/lib/active_record/migration/compatibility.rb
--- old/lib/active_record/migration/compatibility.rb 2023-06-26
23:35:10.000000000 +0200
+++ new/lib/active_record/migration/compatibility.rb 2023-09-09
21:09:43.000000000 +0200
@@ -56,12 +56,13 @@
super
end
- def create_table(table_name, **options)
- if block_given?
- super { |t| yield compatible_table_definition(t) }
- else
- super
+ def change_column(table_name, column_name, type, **options)
+ if type == :datetime
+ options[:precision] ||= nil
end
+
+ type = PostgreSQLCompat.compatible_timestamp_type(type, connection)
+ super
end
module TableDefinition
@@ -70,6 +71,11 @@
super
end
+ def change(name, type, index: nil, **options)
+ options[:precision] ||= nil
+ super
+ end
+
def column(name, type, index: nil, **options)
options[:precision] ||= nil
super
@@ -81,7 +87,7 @@
class << t
prepend TableDefinition
end
- t
+ super
end
end
@@ -105,30 +111,6 @@
end
end
- def create_table(table_name, **options)
- if block_given?
- super { |t| yield compatible_table_definition(t) }
- else
- super
- end
- end
-
- def change_table(table_name, **options)
- if block_given?
- super { |t| yield compatible_table_definition(t) }
- else
- super
- end
- end
-
- def create_join_table(table_1, table_2, **options)
- if block_given?
- super { |t| yield compatible_table_definition(t) }
- else
- super
- end
- end
-
def add_reference(table_name, ref_name, **options)
if connection.adapter_name == "SQLite"
options[:type] = :integer
@@ -182,30 +164,6 @@
end
end
- def create_table(table_name, **options)
- if block_given?
- super { |t| yield compatible_table_definition(t) }
- else
- super
- end
- end
-
- def change_table(table_name, **options)
- if block_given?
- super { |t| yield compatible_table_definition(t) }
- else
- super
- end
- end
-
- def create_join_table(table_1, table_2, **options)
- if block_given?
- super { |t| yield compatible_table_definition(t) }
- else
- super
- end
- end
-
def add_timestamps(table_name, **options)
options[:precision] ||= nil
super
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 2023-06-26 23:35:10.000000000 +0200
+++ new/lib/active_record/migration.rb 2023-09-09 21:09:43.000000000 +0200
@@ -551,6 +551,41 @@
# This must be defined before the inherited hook, below
class Current < Migration # :nodoc:
+ def create_table(table_name, **options)
+ if block_given?
+ super { |t| yield compatible_table_definition(t) }
+ else
+ super
+ end
+ end
+
+ def change_table(table_name, **options)
+ if block_given?
+ super { |t| yield compatible_table_definition(t) }
+ else
+ super
+ end
+ end
+
+ def create_join_table(table_1, table_2, **options)
+ if block_given?
+ super { |t| yield compatible_table_definition(t) }
+ else
+ super
+ end
+ end
+
+ def drop_table(table_name, **options)
+ if block_given?
+ super { |t| yield compatible_table_definition(t) }
+ else
+ super
+ end
+ end
+
+ def compatible_table_definition(t)
+ t
+ end
end
def self.inherited(subclass) # :nodoc:
@@ -916,9 +951,7 @@
end
def method_missing(method, *arguments, &block)
- arg_list = arguments.map(&:inspect) * ", "
-
- say_with_time "#{method}(#{arg_list})" do
+ say_with_time "#{method}(#{format_arguments(arguments)})" do
unless connection.respond_to? :revert
unless arguments.empty? || [:execute, :enable_extension,
:disable_extension].include?(method)
arguments[0] = proper_table_name(arguments.first,
table_name_options)
@@ -1026,6 +1059,22 @@
end
end
+ def format_arguments(arguments)
+ arg_list = arguments[0...-1].map(&:inspect)
+ last_arg = arguments.last
+ if last_arg.is_a?(Hash)
+ last_arg = last_arg.reject { |k, _v| internal_option?(k) }
+ arg_list << last_arg.inspect unless last_arg.empty?
+ else
+ arg_list << last_arg.inspect
+ end
+ arg_list.join(", ")
+ end
+
+ def internal_option?(option_name)
+ option_name.start_with?("_")
+ end
+
def command_recorder
CommandRecorder.new(connection)
end
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 2023-06-26 23:35:10.000000000
+0200
+++ new/lib/active_record/persistence.rb 2023-09-09 21:09:43.000000000
+0200
@@ -564,7 +564,7 @@
end
# Returns true if this object was just created -- that is, prior to the
last
- # save, the object didn't exist in the database and new_record? would have
+ # update or delete, the object didn't exist in the database and
new_record? would have
# returned true.
def previously_new_record?
@previously_new_record
@@ -663,6 +663,7 @@
def delete
_delete_row if persisted?
@destroyed = true
+ @previously_new_record = false
freeze
end
@@ -682,6 +683,7 @@
true
end
@destroyed = true
+ @previously_new_record = false
freeze
end
@@ -813,7 +815,7 @@
verify_readonly_attribute(name) || name
end
- update_constraints = _primary_key_constraints_hash
+ update_constraints = _query_constraints_hash
attributes = attributes.each_with_object({}) do |(k, v), h|
h[k] = @attributes.write_cast_value(k, v)
clear_attribute_change(k)
@@ -1028,7 +1030,7 @@
(self.class.default_scopes?(all_queries: true) ||
self.class.global_current_scope)
end
- def _primary_key_constraints_hash
+ def _query_constraints_hash
{ @primary_key => id_in_database }
end
@@ -1041,7 +1043,7 @@
end
def _delete_row
- self.class._delete_record(_primary_key_constraints_hash)
+ self.class._delete_record(_query_constraints_hash)
end
def _touch_row(attribute_names, time)
@@ -1057,7 +1059,7 @@
def _update_row(attribute_names, attempted_action = "update")
self.class._update_record(
attributes_with_values(attribute_names),
- _primary_key_constraints_hash
+ _query_constraints_hash
)
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/active_record/railties/controller_runtime.rb
new/lib/active_record/railties/controller_runtime.rb
--- old/lib/active_record/railties/controller_runtime.rb 2023-06-26
23:35:10.000000000 +0200
+++ new/lib/active_record/railties/controller_runtime.rb 2023-09-09
21:09:43.000000000 +0200
@@ -28,7 +28,7 @@
end
def cleanup_view_runtime
- if logger && logger.info? && ActiveRecord::Base.connected?
+ if logger && logger.info?
db_rt_before_render = ActiveRecord::LogSubscriber.reset_runtime
self.db_runtime = (db_runtime || 0) + db_rt_before_render
runtime = super
@@ -42,9 +42,8 @@
def append_info_to_payload(payload)
super
- if ActiveRecord::Base.connected?
- payload[:db_runtime] = (db_runtime || 0) +
ActiveRecord::LogSubscriber.reset_runtime
- end
+
+ payload[:db_runtime] = (db_runtime || 0) +
ActiveRecord::LogSubscriber.reset_runtime
end
end
end
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 2023-06-26 23:35:10.000000000 +0200
+++ new/lib/active_record/reflection.rb 2023-09-09 21:09:43.000000000 +0200
@@ -485,6 +485,10 @@
foreign_key
end
+ def join_primary_type
+ type
+ end
+
def join_foreign_key
active_record_primary_key
end
@@ -588,6 +592,10 @@
options[:polymorphic]
end
+ def polymorphic_name
+ active_record.polymorphic_name
+ end
+
def add_as_source(seed)
seed
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/lib/active_record/relation/predicate_builder/association_query_value.rb
new/lib/active_record/relation/predicate_builder/association_query_value.rb
--- old/lib/active_record/relation/predicate_builder/association_query_value.rb
2023-06-26 23:35:10.000000000 +0200
+++ new/lib/active_record/relation/predicate_builder/association_query_value.rb
2023-09-09 21:09:43.000000000 +0200
@@ -18,7 +18,10 @@
def ids
case value
when Relation
- value.select_values.empty? ? value.select(primary_key) : value
+ relation = value
+ relation = relation.select(primary_key) if select_clause?
+ relation = relation.where(primary_type => polymorphic_name) if
polymorphic_clause?
+ relation
when Array
value.map { |v| convert_to_id(v) }
else
@@ -30,6 +33,22 @@
associated_table.join_primary_key
end
+ def primary_type
+ associated_table.join_primary_type
+ end
+
+ def polymorphic_name
+ associated_table.polymorphic_name_association
+ end
+
+ def select_clause?
+ value.select_values.empty?
+ end
+
+ def polymorphic_clause?
+ primary_type && !value.where_values_hash.has_key?(primary_type)
+ end
+
def convert_to_id(value)
if value.respond_to?(primary_key)
value.public_send(primary_key)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/active_record/relation/predicate_builder.rb
new/lib/active_record/relation/predicate_builder.rb
--- old/lib/active_record/relation/predicate_builder.rb 2023-06-26
23:35:10.000000000 +0200
+++ new/lib/active_record/relation/predicate_builder.rb 2023-09-09
21:09:43.000000000 +0200
@@ -65,8 +65,7 @@
end
def build_bind_attribute(column_name, value)
- type = table.type(column_name)
- Relation::QueryAttribute.new(column_name, type.immutable_value(value),
type)
+ Relation::QueryAttribute.new(column_name, value, table.type(column_name))
end
def resolve_arel_attribute(table_name, column_name, &block)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/active_record/relation/query_attribute.rb
new/lib/active_record/relation/query_attribute.rb
--- old/lib/active_record/relation/query_attribute.rb 2023-06-26
23:35:10.000000000 +0200
+++ new/lib/active_record/relation/query_attribute.rb 2023-09-09
21:09:43.000000000 +0200
@@ -5,6 +5,20 @@
module ActiveRecord
class Relation
class QueryAttribute < ActiveModel::Attribute # :nodoc:
+ def initialize(...)
+ super
+
+ # The query attribute value may be mutated before we actually
"compile" the query.
+ # To avoid that if the type uses a serializer we eagerly compute the
value for database
+ if value_before_type_cast.is_a?(StatementCache::Substitute)
+ # we don't need to serialize StatementCache::Substitute
+ elsif @type.serialized?
+ value_for_database
+ elsif @type.mutable? # If the type is simply mutable, we deep_dup it.
+ @value_before_type_cast = @value_before_type_cast.deep_dup
+ end
+ end
+
def type_cast(value)
value
end
@@ -35,6 +49,15 @@
@_unboundable
end
+ def ==(other)
+ super && value_for_database == other.value_for_database
+ end
+ alias eql? ==
+
+ def hash
+ [self.class, name, value_for_database, type].hash
+ end
+
private
def infinity?(value)
value.respond_to?(:infinite?) && value.infinite?
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 2023-06-26
23:35:10.000000000 +0200
+++ new/lib/active_record/relation/query_methods.rb 2023-09-09
21:09:43.000000000 +0200
@@ -77,7 +77,11 @@
associations.each do |association|
reflection = scope_association_reflection(association)
@scope.joins!(association)
- self.not(association => { reflection.association_primary_key => nil
})
+ if reflection.options[:class_name]
+ self.not(association => { reflection.association_primary_key =>
nil })
+ else
+ self.not(reflection.table_name => {
reflection.association_primary_key => nil })
+ end
end
@scope
@@ -105,7 +109,11 @@
associations.each do |association|
reflection = scope_association_reflection(association)
@scope.left_outer_joins!(association)
- @scope.where!(association => { reflection.association_primary_key =>
nil })
+ if reflection.options[:class_name]
+ @scope.where!(association => { reflection.association_primary_key
=> nil })
+ else
+ @scope.where!(reflection.table_name => {
reflection.association_primary_key => nil })
+ end
end
@scope
@@ -436,13 +444,16 @@
self
end
- # Allows to specify an order by a specific set of values. Depending on your
- # adapter this will either use a CASE statement or a built-in function.
+ # Allows to specify an order by a specific set of values.
#
# User.in_order_of(:id, [1, 5, 3])
# # SELECT "users".* FROM "users"
- # # ORDER BY FIELD("users"."id", 1, 5, 3)
# # WHERE "users"."id" IN (1, 5, 3)
+ # # ORDER BY CASE
+ # # WHEN "users"."id" = 1 THEN 1
+ # # WHEN "users"."id" = 5 THEN 2
+ # # WHEN "users"."id" = 3 THEN 3
+ # # END ASC
#
def in_order_of(column, values)
klass.disallow_raw_sql!([column], permit:
connection.column_name_with_order_matcher)
@@ -454,9 +465,16 @@
values = values.map { |value| type_caster.type_cast_for_database(column,
value) }
arel_column = column.is_a?(Symbol) ? order_column(column.to_s) : column
+ where_clause =
+ if values.include?(nil)
+ arel_column.in(values.compact).or(arel_column.eq(nil))
+ else
+ arel_column.in(values)
+ end
+
spawn
- .order!(connection.field_ordered_value(arel_column, values))
- .where!(arel_column.in(values))
+ .order!(build_case_for_value_position(arel_column, values))
+ .where!(where_clause)
end
# Replaces any existing order defined on the relation with the specified
order.
@@ -1661,6 +1679,15 @@
end
end
+ def build_case_for_value_position(column, values)
+ node = Arel::Nodes::Case.new
+ values.each.with_index(1) do |value, order|
+ node.when(column.eq(value)).then(order)
+ end
+
+ Arel::Nodes::Ascending.new(node)
+ end
+
def resolve_arel_attributes(attrs)
attrs.flat_map do |attr|
case attr
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/active_record/result.rb
new/lib/active_record/result.rb
--- old/lib/active_record/result.rb 2023-06-26 23:35:10.000000000 +0200
+++ new/lib/active_record/result.rb 2023-09-09 21:09:43.000000000 +0200
@@ -108,7 +108,7 @@
type = if type_overrides.is_a?(Array)
type_overrides.first
else
- column_type(columns.first, type_overrides)
+ column_type(columns.first, 0, type_overrides)
end
rows.map do |(value)|
@@ -118,7 +118,7 @@
types = if type_overrides.is_a?(Array)
type_overrides
else
- columns.map { |name| column_type(name, type_overrides) }
+ columns.map.with_index { |name, i| column_type(name, i,
type_overrides) }
end
rows.map do |values|
@@ -135,9 +135,11 @@
end
private
- def column_type(name, type_overrides = {})
+ def column_type(name, index, type_overrides)
type_overrides.fetch(name) do
- column_types.fetch(name, Type.default_value)
+ column_types.fetch(index) do
+ column_types.fetch(name, Type.default_value)
+ end
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/active_record/table_metadata.rb
new/lib/active_record/table_metadata.rb
--- old/lib/active_record/table_metadata.rb 2023-06-26 23:35:10.000000000
+0200
+++ new/lib/active_record/table_metadata.rb 2023-09-09 21:09:43.000000000
+0200
@@ -2,7 +2,7 @@
module ActiveRecord
class TableMetadata # :nodoc:
- delegate :join_primary_key, :join_foreign_key, :join_foreign_type, to:
:reflection
+ delegate :join_primary_key, :join_primary_type, :join_foreign_key,
:join_foreign_type, to: :reflection
def initialize(klass, arel_table, reflection = nil)
@klass = klass
@@ -19,7 +19,7 @@
end
def has_column?(column_name)
- klass&.columns_hash.key?(column_name)
+ klass&.columns_hash&.key?(column_name)
end
def associated_with?(table_name)
@@ -54,6 +54,10 @@
reflection&.polymorphic?
end
+ def polymorphic_name_association
+ reflection&.polymorphic_name
+ end
+
def through_association?
reflection&.through_reflection?
end
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 2023-06-26 23:35:10.000000000
+0200
+++ new/lib/active_record/transactions.rb 2023-09-09 21:09:43.000000000
+0200
@@ -336,9 +336,9 @@
@_trigger_update_callback = @_trigger_destroy_callback = false if
force_restore_state
end
- # Executes +method+ within a transaction and captures its return value as a
- # status flag. If the status is true the transaction is committed,
otherwise
- # a ROLLBACK is issued. In any case the status flag is returned.
+ # Executes a block within a transaction and captures its return value as a
+ # status flag. If the status is true, the transaction is committed,
+ # otherwise a ROLLBACK is issued. In any case, the status flag is returned.
#
# This method is available within the context of an ActiveRecord::Base
# instance.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/active_record/type/serialized.rb
new/lib/active_record/type/serialized.rb
--- old/lib/active_record/type/serialized.rb 2023-06-26 23:35:10.000000000
+0200
+++ new/lib/active_record/type/serialized.rb 2023-09-09 21:09:43.000000000
+0200
@@ -55,6 +55,10 @@
coder.respond_to?(:object_class) && value.is_a?(coder.object_class)
end
+ def serialized? # :nodoc:
+ true
+ end
+
private
def default_value?(value)
value == coder.load(nil)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/arel/nodes/and.rb new/lib/arel/nodes/and.rb
--- old/lib/arel/nodes/and.rb 2023-06-26 23:35:10.000000000 +0200
+++ new/lib/arel/nodes/and.rb 2023-09-09 21:09:43.000000000 +0200
@@ -18,6 +18,10 @@
children[1]
end
+ def fetch_attribute(&block)
+ children.any? && children.all? { |child| child.fetch_attribute(&block)
}
+ end
+
def hash
children.hash
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/metadata new/metadata
--- old/metadata 2023-06-26 23:35:10.000000000 +0200
+++ new/metadata 2023-09-09 21:09:43.000000000 +0200
@@ -1,14 +1,14 @@
--- !ruby/object:Gem::Specification
name: activerecord
version: !ruby/object:Gem::Version
- version: 7.0.5.1
+ version: 7.0.8
platform: ruby
authors:
- David Heinemeier Hansson
autorequire:
bindir: bin
cert_chain: []
-date: 2023-06-26 00:00:00.000000000 Z
+date: 2023-09-09 00:00:00.000000000 Z
dependencies:
- !ruby/object:Gem::Dependency
name: activesupport
@@ -16,28 +16,28 @@
requirements:
- - '='
- !ruby/object:Gem::Version
- version: 7.0.5.1
+ version: 7.0.8
type: :runtime
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - '='
- !ruby/object:Gem::Version
- version: 7.0.5.1
+ version: 7.0.8
- !ruby/object:Gem::Dependency
name: activemodel
requirement: !ruby/object:Gem::Requirement
requirements:
- - '='
- !ruby/object:Gem::Version
- version: 7.0.5.1
+ version: 7.0.8
type: :runtime
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - '='
- !ruby/object:Gem::Version
- version: 7.0.5.1
+ version: 7.0.8
description: Databases on Rails. Build a persistent domain model by mapping
database
tables to Ruby classes. Strong conventions for associations, validations,
aggregations,
migrations, and testing come baked-in.
@@ -434,10 +434,10 @@
- MIT
metadata:
bug_tracker_uri: https://github.com/rails/rails/issues
- changelog_uri:
https://github.com/rails/rails/blob/v7.0.5.1/activerecord/CHANGELOG.md
- documentation_uri: https://api.rubyonrails.org/v7.0.5.1/
+ changelog_uri:
https://github.com/rails/rails/blob/v7.0.8/activerecord/CHANGELOG.md
+ documentation_uri: https://api.rubyonrails.org/v7.0.8/
mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
- source_code_uri: https://github.com/rails/rails/tree/v7.0.5.1/activerecord
+ source_code_uri: https://github.com/rails/rails/tree/v7.0.8/activerecord
rubygems_mfa_required: 'true'
post_install_message:
rdoc_options:
@@ -456,7 +456,7 @@
- !ruby/object:Gem::Version
version: '0'
requirements: []
-rubygems_version: 3.3.3
+rubygems_version: 3.4.18
signing_key:
specification_version: 4
summary: Object-relational mapper framework (part of Rails).