Update dependency activerecord to "~>7.2.0" #158
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
"~>7.0.8"
->"~>7.2.0"
Release Notes
rails/rails (activerecord)
v7.2.2
: 7.2.2Compare Source
Active Support
Include options when instrumenting
ActiveSupport::Cache::Store#delete
andActiveSupport::Cache::Store#delete_multi
.Adam Renberg Tamm
Print test names when running
rails test -v
for parallel tests.John Hawthorn, Abeid Ahmed
Active Model
Fix regression in
alias_attribute
to work with user defined methods.alias_attribute
would wrongly assume the attribute accessor was generated by Active Model.Jean Boussier
Active Record
Fix support for
query_cache: false
indatabase.yml
.query_cache: false
would no longer entirely disable the Active Record query cache.zzak
Set
.attributes_for_inspect
to:all
by default.For new applications it is set to
[:id]
in config/environment/production.rb.In the console all the attributes are always shown.
Andrew Novoselac
PG::UnableToSend: no connection to the server
is now retryable as a connection-related exceptionKazuma Watanabe
Fix marshalling of unsaved associated records in 7.1 format.
The 7.1 format would only marshal associated records if the association was loaded.
But associations that would only contain unsaved records would be skipped.
Jean Boussier
Fix incorrect SQL query when passing an empty hash to
ActiveRecord::Base.insert
.David Stosik
Allow to save records with polymorphic join tables that have
inverse_of
specified.
Markus Doits
Fix association scopes applying on the incorrect join when using a polymorphic
has_many through:
.Joshua Young
Fix
dependent: :destroy
for bi-directional has one through association.Fixes #50948.
In the above example
left.destroy
wouldn't destroy its associatedRight
record.
Andy Stewart
Properly handle lazily pinned connection pools.
Fixes #53147.
When using transactional fixtures with system tests to similar tools
such as capybara, it could happen that a connection end up pinned by the
server thread rather than the test thread, causing
"Cannot expire connection, it is owned by a different thread"
errors.Jean Boussier
Fix
ActiveRecord::Base.with
to accept more than two sub queries.Fixes #53110.
The above now works as expected.
fatkodima
Properly release pinned connections with non joinable connections.
Fixes #52973
When running system tests with transactional fixtures on, it could happen that
the connection leased by the Puma thread wouldn't be properly released back to the pool,
causing "Cannot expire connection, it is owned by a different thread" errors in later tests.
Jean Boussier
Make Float distinguish between
float4
andfloat8
in PostgreSQL.Fixes #52742
Ryota Kitazawa, Takayuki Nagatomi
Fix an issue where
.left_outer_joins
used with multiple associations that havethe same child association but different parents does not join all parents.
Previously, using
.left_outer_joins
with the same child association would only join one of the parents.Now it will correctly join both parents.
Fixes #41498.
Garrett Blehm
Ensure
ActiveRecord::Encryption.config
is always ready before access.Previously,
ActiveRecord::Encryption
configuration was deferred untilActiveRecord::Base
was loaded. Therefore, accessing
ActiveRecord::Encryption.config
properties beforeActiveRecord::Base
was loaded would give incorrect results.ActiveRecord::Encryption
now has its own loading hook so that its configuration is set assoon as needed.
When
ActiveRecord::Base
is loaded, even lazily, it in turn triggers the loading ofActiveRecord::Encryption
, thus preserving the original behavior of having its config readybefore any use of
ActiveRecord::Base
.Maxime Réty
Add
TimeZoneConverter#==
method, so objects will be properly compared bytheir type, scale, limit & precision.
Address #52699.
Ruy Rocha
Action View
Action Pack
Fix non-GET requests not updating cookies in
ActionController::TestCase
.Jon Moss, Hartley McGuire
Active Job
Action Mailer
Action Cable
Active Storage
Action Mailbox
Action Text
Railties
Guides
v7.2.1.2
: 7.2.1.2Compare Source
Active Support
Active Model
Active Record
Action View
Action Pack
Active Job
Action Mailer
Fix NoMethodError in
block_format
helperMichael Leimstaedtner
Action Cable
Active Storage
Action Mailbox
Action Text
Railties
Guides
v7.2.1.1
: 7.2.1.1Compare Source
Active Support
Active Model
Active Record
Action View
Action Pack
Avoid regex backtracking in HTTP Token authentication
[CVE-2024-47887]
Avoid regex backtracking in query parameter filtering
[CVE-2024-41128]
Active Job
Action Mailer
Avoid regex backtracking in
block_format
helper[CVE-2024-47889]
Action Cable
Active Storage
Action Mailbox
Action Text
Avoid backtracing in plain_text_for_blockquote_node
[CVE-2024-47888]
Railties
Guides
v7.2.1
: 7.2.1Compare Source
Active Support
Active Model
Active Record
Fix detection for
enum
columns with parallelized tests and PostgreSQL.Rafael Mendonça França
Allow to eager load nested nil associations.
fatkodima
Fix swallowing ignore order warning when batching using
BatchEnumerator
.fatkodima
Fix memory bloat on the connection pool when using the Fiber
IsolatedExecutionState
.Jean Boussier
Restore inferred association class with the same modularized name.
Justin Ko
Fix
ActiveRecord::Base.inspect
to properly explain how to load schema information.Jean Boussier
Check invalid
enum
options for the new syntax.The options using
_
prefix in the old syntax are invalid in the new syntax.Rafael Mendonça França
Fix
ActiveRecord::Encryption::EncryptedAttributeType#type
to returnactual cast type.
Vasiliy Ermolovich
Fix
create_table
with:auto_increment
option for MySQL adapter.fatkodima
Action View
Action Pack
Fix
Request#raw_post
raisingNoMethodError
whenrack.input
isnil
.Hartley McGuire
Active Job
Action Mailer
Action Cable
Active Storage
Action Mailbox
Action Text
Strip
content
attribute if the key is present but the value is emptyJeremy Green
Railties
Fix
rails console
for application with non default application constant.The wrongly assumed the Rails application would be named
AppNamespace::Application
,which is the default but not an obligation.
Jean Boussier
Fix the default Dockerfile to include the full sqlite3 package.
Prior to this it only included
libsqlite3
, so it wasn't enough torun
rails dbconsole
.Jerome Dalbert
Don't update public directory during
app:update
command for API-only Applications.y-yagi
Don't add bin/brakeman if brakeman is not in bundle when upgrading an application.
Etienne Barrié
Remove PWA views and routes if its an API only project.
Jean Boussier
Simplify generated Puma configuration
DHH, Rafael Mendonça França
v7.2.0
: 7.2.0Compare Source
Active Support
Fix
delegate_missing_to allow_nil: true
when called with implict selfJean Boussier
Add
logger
as a dependency since it is a bundled gem candidate for Ruby 3.5Earlopain
Define
Digest::UUID.nil_uuid
, which returns the so-called nil UUID.Xavier Noria
Support
duration
type inActiveSupport::XmlMini
.heka1024
Remove deprecated
ActiveSupport::Notifications::Event#children
andActiveSupport::Notifications::Event#parent_of?
.Rafael Mendonça França
Remove deprecated support to call the following methods without passing a deprecator:
deprecate
deprecate_constant
ActiveSupport::Deprecation::DeprecatedObjectProxy.new
ActiveSupport::Deprecation::DeprecatedInstanceVariableProxy.new
ActiveSupport::Deprecation::DeprecatedConstantProxy.new
assert_deprecated
assert_not_deprecated
collect_deprecations
Rafael Mendonça França
Remove deprecated
ActiveSupport::Deprecation
delegation to instance.Rafael Mendonça França
Remove deprecated
SafeBuffer#clone_empty
.Rafael Mendonça França
Remove deprecated
#to_default_s
fromArray
,Date
,DateTime
andTime
.Rafael Mendonça França
Remove deprecated support to passing
Dalli::Client
instances toMemCacheStore
.Rafael Mendonça França
Remove deprecated
config.active_support.use_rfc4122_namespaced_uuids
.Rafael Mendonça França
Remove deprecated
config.active_support.remove_deprecated_time_with_zone_name
.Rafael Mendonça França
Remove deprecated
config.active_support.disable_to_s_conversion
.Rafael Mendonça França
Remove deprecated support to bolding log text with positional boolean in
ActiveSupport::LogSubscriber#color
.Rafael Mendonça França
Remove deprecated constants
ActiveSupport::LogSubscriber::CLEAR
andActiveSupport::LogSubscriber::BOLD
.Rafael Mendonça França
Remove deprecated support for
config.active_support.cache_format_version = 6.1
.Rafael Mendonça França
Remove deprecated
:pool_size
and:pool_timeout
options for the cache storage.Rafael Mendonça França
Warn on tests without assertions.
ActiveSupport::TestCase
now warns when tests do not run any assertions.This is helpful in detecting broken tests that do not perform intended assertions.
fatkodima
Support
hexBinary
type inActiveSupport::XmlMini
.heka1024
Deprecate
ActiveSupport::ProxyObject
in favor of Ruby's built-inBasicObject
.Earlopain
stub_const
now accepts aexists: false
parameter to allow stubbing missing constants.Jean Boussier
Make
ActiveSupport::BacktraceCleaner
copy filters and silencers on dup and clone.Previously the copy would still share the internal silencers and filters array,
causing state to leak.
Jean Boussier
Updating Astana with Western Kazakhstan TZInfo identifier.
Damian Nelson
Add filename support for
ActiveSupport::Logger.logger_outputs_to?
.Christian Schmidt
Include
IPAddr#prefix
when serializing anIPAddr
using theActiveSupport::MessagePack
serializer.This change is backward and forward compatible — old payloads can
still be read, and new payloads will be readable by older versions of Rails.
Taiki Komaba
Add
default:
support forActiveSupport::CurrentAttributes.attribute
.Sean Doyle
Yield instance to
Object#with
block.Sean Doyle
Use logical core count instead of physical core count to determine the
default number of workers when parallelizing tests.
Jonathan Hefner
Fix
Time.now/DateTime.now/Date.today
to return results in a system timezone after#travel_to
.There is a bug in the current implementation of #travel_to:
it remembers a timezone of its argument, and all stubbed methods start
returning results in that remembered timezone. However, the expected
behavior is to return results in a system timezone.
Aleksei Chernenkov
Add
ErrorReported#unexpected
to report precondition violations.For example:
...
Make the order of read_multi and write_multi notifications for
Cache::Store#fetch_multi
operations match the order they are executed in.Adam Renberg Tamm
Make return values of
Cache::Store#write
consistent.The return value was not specified before. Now it returns
true
on a successful write,nil
if there was an error talking to the cache backend, andfalse
if the write failedfor another reason (e.g. the key already exists and
unless_exist: true
was passed).Sander Verdonschot
Fix logged cache keys not always matching actual key used by cache action.
Hartley McGuire
Improve error messages of
assert_changes
andassert_no_changes
.assert_changes
error messages now display objects with.inspect
to make it easierto differentiate nil from empty strings, strings from symbols, etc.
assert_no_changes
error messages now surface the actual value.pcreux
Fix
#to_fs(:human_size)
to correctly work with negative numbers.Earlopain
Fix
BroadcastLogger#dup
so that it duplicates the logger'sbroadcasts
.Andrew Novoselac
Fix issue where
bootstrap.rb
overwrites thelevel
of aBroadcastLogger
'sbroadcasts
.Andrew Novoselac
Fix compatibility with the
semantic_logger
gem.The
semantic_logger
gem doesn't behave exactly like stdlib logger in thatSemanticLogger#level
returns a Symbol while stdlibLogger#level
returns an Integer.This caused the various
LogSubscriber
classes in Rails to break when assigned aSemanticLogger
instance.Jean Boussier, ojab
Fix MemoryStore to prevent race conditions when incrementing or decrementing.
Pierre Jambet
Implement
HashWithIndifferentAccess#to_proc
.Previously, calling
#to_proc
onHashWithIndifferentAccess
object used inherited#to_proc
method from the
Hash
class, which was not able to access values using indifferent keys.fatkodima
Active Model
Fix a bug where type casting of string to
Time
andDateTime
doesn'tcalculate minus minute value in TZ offset correctly.
Akira Matsuda
Port the
type_for_attribute
method to Active Model. Classes that includeActiveModel::Attributes
will now provide this method. This method behavesthe same for Active Model as it does for Active Record.
Jonathan Hefner
Active Record
Handle commas in Sqlite3 default function definitions.
Stephen Margheim
Fixes
validates_associated
raising an exception when configured with asingular association and having
index_nested_attribute_errors
enabled.Martin Spickermann
The constant
ActiveRecord::ImmutableRelation
has been deprecated becausewe want to reserve that name for a stronger sense of "immutable relation".
Please use
ActiveRecord::UnmodifiableRelation
instead.Xavier Noria
Add condensed
#inspect
forConnectionPool
,AbstractAdapter
, andDatabaseConfig
.Hartley McGuire
Fixed a memory performance issue in Active Record attribute methods definition.
Jean Boussier
Define the new Active Support notification event
start_transaction.active_record
.This event is fired when database transactions or savepoints start, and
complements
transaction.active_record
, which is emitted when they finish.The payload has the transaction (
:transaction
) and the connection (:connection
).Xavier Noria
Fix an issue where the IDs reader method did not return expected results
for preloaded associations in models using composite primary keys.
Jay Ang
The payload of
sql.active_record
Active Support notifications now has the current transaction in the:transaction
key.Xavier Noria
The payload of
transaction.active_record
Active Support notifications now has the transaction the event is related to in the:transaction
key.Xavier Noria
Define
ActiveRecord::Transaction#uuid
, which returns a UUID for the database transaction. This may be helpful when tracing database activity. These UUIDs are generated only on demand.Xavier Noria
Fix inference of association model on nested models with the same demodularized name.
E.g. with the following setup:
Before,
#post
would infer the model asNested::Post
, but now it correctly infersPost
.Joshua Young
PostgreSQL
Cidr#change?
detects the address prefix change.Taketo Takashima
Change
BatchEnumerator#destroy_all
to return the total number of affected rows.Previously, it always returned
nil
.fatkodima
Support
touch_all
in batches.fatkodima
Add support for
:if_not_exists
and:force
options tocreate_schema
.fatkodima
Fix
index_errors
having incorrect index in association validation errors.lulalala
Add
index_errors: :nested_attributes_order
mode.This indexes the association validation errors based on the order received by nested attributes setter, and respects the
reject_if
configuration. This enables API to provide enough information to the frontend to map the validation errors back to their respective form fields.lulalala
Add
Rails.application.config.active_record.postgresql_adapter_decode_dates
to opt out of decoding dates automatically with the postgresql adapter. Defaults to true.Joé Dupuis
Association option
query_constraints
is deprecated in favor offoreign_key
.Nikita Vasilevsky
Add
ENV["SKIP_TEST_DATABASE_TRUNCATE"]
flag to speed up multi-process test runs on large DBs when all tests run within default transaction.This cuts ~10s from the test run of HEY when run by 24 processes against the 178 tables, since ~4,000 table truncates can then be skipped.
DHH
Added support for recursive common table expressions.
Generates the following SQL:
ClearlyClaire
validate_constraint
can be called in achange_table
block.ex:
Cody Cutrer
PostgreSQLAdapter
now decodes columns of type date toDate
instead of string.Ex:
Joé Dupuis
Strict loading using
:n_plus_one_only
does not eagerly load child associations.With this change, child associations are no longer eagerly loaded, to
match intended behavior and to prevent non-deterministic order issues caused
by calling methods like
first
orlast
. Asfirst
andlast
don't causean N+1 by themselves, calling child associations will no longer raise.
Fixes #49473.
Before:
SELECT * FROM posts WHERE person_id = 1; -- non-deterministic order
SELECT * FROM posts WHERE person_id = 1 ORDER BY id LIMIT 1;
Allow
Sqlite3Adapter
to usesqlite3
gem version2.x
.Mike Dalessio
Allow
ActiveRecord::Base#pluck
to accept hash values.Before
After
Raise an
ActiveRecord::ActiveRecordError
error when the MySQL database returns an invalid version string.Kevin McPhillips
ActiveRecord::Base.transaction
now yields anActiveRecord::Transaction
object.This allows to register callbacks on it.
Jean Boussier
Add
ActiveRecord::Base.current_transaction
.Returns the current transaction, to allow registering callbacks on it.
Jean Boussier
Add
ActiveRecord.after_all_transactions_commit
callback.Useful for code that may run either inside or outside a transaction and needs
to perform work after the state changes have been properly persisted.
In the above example, the block is either executed immediately if called outside
of a transaction, or called after the open transaction is committed.
If the transaction is rolled back, the block isn't called.
Jean Boussier
Add the ability to ignore counter cache columns until they are backfilled.
Starting to use counter caches on existing large tables can be troublesome, because the column
values must be backfilled separately of the column addition (to not lock the table for too long)
and before the use of
:counter_cache
(otherwise methods likesize
/any?
/etc, which usecounter caches internally, can produce incorrect results). People usually use database triggers
or callbacks on child associations while backfilling before introducing a counter cache
configuration to the association.
Now, to safely backfill the column, while keeping the column updated with child records added/removed, use:
While the counter cache is not "active", the methods like
size
/any?
/etc will not use it,but get the results directly from the database. After the counter cache column is backfilled, simply
remove the
{ active: false }
part from the counter cache definition, and it will now be used by thementioned methods.
fatkodima
Retry known idempotent SELECT queries on connection-related exceptions.
SELECT queries we construct by walking the Arel tree and / or with known model attributes
are idempotent and can safely be retried in the case of a connection error. Previously,
adapters such as
TrilogyAdapter
would raiseActiveRecord::ConnectionFailed: Trilogy::EOFError
when encountering a connection error mid-request.
Adrianna Chang
Allow association's
foreign_key
to be composite.query_constraints
option was the only way to configure a composite foreign key by passing anArray
.Now it's possible to pass an Array value as
foreign_key
to achieve the same behavior of an association.Nikita Vasilevsky
Allow association's
primary_key
to be composite.Association's
primary_key
can be composite when derived from associated modelprimary_key
orquery_constraints
.Now it's possible to explicitly set it as composite on the association.
Nikita Vasilevsky
Add
config.active_record.permanent_connection_checkout
setting.Controls whether
ActiveRecord::Base.connection
raises an error, emits a deprecation warning, or neither.ActiveRecord::Base.connection
checkouts a database connection from the pool and keeps it leased until the end ofthe request or job. This behavior can be undesirable in environments that use many more threads or fibers than there
is available connections.
This configuration can be used to track down and eliminate code that calls
ActiveRecord::Base.connection
andmigrate it to use
ActiveRecord::Base.with_connection
instead.The default behavior remains unchanged, and there is currently no plans to change the default.
Jean Boussier
Add dirties option to uncached.
This adds a
dirties
option toActiveRecord::Base.uncached
andActiveRecord::ConnectionAdapters::ConnectionPool#uncached
.When set to
true
(the default), writes will clear all query caches belonging to the current thread.When set to
false
, writes to the affected connection pool will not clear any query cache.This is needed by Solid Cache so that cache writes do not clear query caches.
Donal McBreen
Deprecate
ActiveRecord::Base.connection
in favor of.lease_connection
.The method has been renamed as
lease_connection
to better reflect that the returnedconnection will be held for the duration of the request or job.
This deprecation is a soft deprecation, no warnings will be issued and there is no
current plan to remove the method.
Jean Boussier
Deprecate
ActiveRecord::ConnectionAdapters::ConnectionPool#connection
.The method has been renamed as
lease_connection
to better reflect that the returnedconnection will be held for the duration of the request or job.
Jean Boussier
Expose a generic fixture accessor for fixture names that may conflict with Minitest.
Jean Boussier
Using
Model.query_constraints
with a single non-primary-key column used to raise as expected, but with anincorrect error message.
This has been fixed to raise with a more appropriate error message.
Joshua Young
Fix
has_one
association autosave setting the foreign key attribute when it is unchanged.This behavior is also inconsistent with autosaving
belongs_to
and can have unintended side effects like raisingan
ActiveRecord::ReadonlyAttributeError
when the foreign key attribute is marked as read-only.Joshua Young
Remove deprecated behavior that would rollback a transaction block when exited using
return
,break
orthrow
.Rafael Mendonça França
Deprecate
Rails.application.config.active_record.commit_transaction_on_non_local_return
.Rafael Mendonça França
Remove deprecated support to pass
rewhere
toActiveRecord::Relation#merge
.Rafael Mendonça França
Remove deprecated support to pass
deferrable: true
toadd_foreign_key
.Rafael Mendonça França
Remove deprecated support to quote
ActiveSupport::Duration
.Rafael Mendonça França
Remove deprecated
#quote_bound_value
.Rafael Mendonça França
Remove deprecated
ActiveRecord::ConnectionAdapters::ConnectionPool#connection_klass
.Rafael Mendonça França
Remove deprecated support to apply
#connection_pool_list
,#active_connections?
,#clear_active_connections!
,#clear_reloadable_connections!
,#clear_all_connections!
and#flush_idle_connections!
to the connections poolsfor the current role when the
role
argument isn't provided.Rafael Mendonça França
Remove deprecated
#all_connection_pools
.Rafael Mendonça França
Remove deprecated
ActiveRecord::ConnectionAdapters::SchemaCache#data_sources
.Rafael Mendonça França
Remove deprecated
ActiveRecord::ConnectionAdapters::SchemaCache.load_from
.Rafael Mendonça França
Remove deprecated
#all_foreign_keys_valid?
from database adapters.Rafael Mendonça França
Remove deprecated support to passing coder and class as second argument to
serialize
.Rafael Mendonça França
Remove deprecated support to
ActiveRecord::Base#read_attribute(:id)
to return the custom primary key value.Rafael Mendonça França
Remove deprecated
TestFixtures.fixture_path
.Rafael Mendonça França
Remove deprecated behavior to support referring to a singular association by its plural name.
Rafael Mendonça França
Deprecate
Rails.application.config.active_record.allow_deprecated_singular_associations_name
.Rafael Mendonça França
Remove deprecated support to passing
SchemaMigration
andInternalMetadata
classes as arguments toActiveRecord::MigrationContext
.Rafael Mendonça França
Remove deprecated
ActiveRecord::Migration.check_pending!
method.Rafael Mendonça França
Remove deprecated
ActiveRecord::LogSubscriber.runtime
method.Rafael Mendonça França
Remove deprecated
ActiveRecord::LogSubscriber.runtime=
method.Rafael Mendonça França
Remove deprecated
ActiveRecord::LogSubscriber.reset_runtime
method.Rafael Mendonça França
Remove deprecated support to define
explain
in the connection adapter with 2 arguments.Rafael Mendonça França
Remove deprecated
ActiveRecord::ActiveJobRequiredError
.Rafael Mendonça França
Remove deprecated
ActiveRecord::Base.clear_active_connections!
.Rafael Mendonça França
Remove deprecated
ActiveRecord::Base.clear_reloadable_connections!
.Rafael Mendonça França
Remove deprecated
ActiveRecord::Base.clear_all_connections!
.Rafael Mendonça França
Remove deprecated
ActiveRecord::Base.flush_idle_connections!
.Rafael Mendonça França
Remove deprecated
name
argument fromActiveRecord::Base.remove_connection
.Rafael Mendonça França
Remove deprecated support to call
alias_attribute
with non-existent attribute names.Rafael Mendonça França
Remove deprecated
Rails.application.config.active_record.suppress_multiple_database_warning
.Rafael Mendonça França
Add
ActiveRecord::Encryption::MessagePackMessageSerializer
.Serialize data to the MessagePack format, for efficient storage in binary columns.
The binary encoding requires around 30% less space than the base64 encoding
used by the default serializer.
Donal McBreen
Add support for encrypting binary columns.
Ensure encryption and decryption pass
Type::Binary::Data
around for binary data.Previously encrypting binary columns with the
ActiveRecord::Encryption::MessageSerializer
incidentally worked for MySQL and SQLite, but not PostgreSQL.
Donal McBreen
Deprecated
ENV["SCHEMA_CACHE"]
in favor ofschema_cache_path
in the database configuration.Rafael Mendonça França
Add
ActiveRecord::Base.with_connection
as a shortcut for leasing a connection for a short duration.The leased connection is yielded, and for the duration of the block, any call to
ActiveRecord::Base.connection
will yield that same connection.
This is useful to perform a few database operations without causing a connection to be leased for the
entire duration of the request or job.
Jean Boussier
Deprecate
config.active_record.warn_on_records_fetched_greater_than
now thatsql.active_record
notification includes
:row_count
field.Jason Nochlin
The fix ensures that the association is joined using the appropriate join type
(either inner join or left outer join) based on the existing joins in the scope.
This prevents unintentional overrides of existing join types and ensures consistency in the generated SQL queries.
Example:
associated
will useLEFT JOIN
instead of usingJOIN
Fix an issue where
ActiveRecord::Encryption
configurations are not ready before the loadingof Active Record models, when an application is eager loaded. As a result, encrypted attributes
could be misconfigured in some cases.
Maxime Réty
Deprecate defining an
enum
with keyword arguments.BAD
GOOD
Add
config.active_record.validate_migration_timestamps
option for validating migration timestamps.When set, validates that the timestamp prefix for a migration is no more than a day ahead of
the timestamp associated with the current time. This is designed to prevent migrations prefixes
from being hand-edited to future timestamps, which impacts migration generation and other
migration commands.
Adrianna Chang
Properly synchronize
Mysql2Adapter#active?
andTrilogyAdapter#active?
.As well as
disconnect!
andverify!
.This generally isn't a big problem as connections must not be shared between
threads, but is required when running transactional tests or system tests
and could lead to a SEGV.
Jean Boussier
Support
:source_location
tag option for query log tags.Calculating the caller location is a costly operation and should be used primarily in development
(note, there is also a
config.active_record.verbose_query_logs
that serves the same purpose)or occasionally on production for debugging purposes.
fatkodima
Add an option to
ActiveRecord::Encryption::Encryptor
to disable compression.Allow compression to be disabled by setting
compress: false
Donal McBreen
Deprecate passing strings to
ActiveRecord::Tasks::DatabaseTasks.cache_dump_filename
.A
ActiveRecord::DatabaseConfigurations::DatabaseConfig
object should be passed instead.Rafael Mendonça França
Add
row_count
field tosql.active_record
notification.This field returns the amount of rows returned by the query that emitted the notification.
This metric is useful in cases where one wants to detect queries with big result sets.
Marvin Bitterlich
Consistently raise an
ArgumentError
when passing an invalid argument to a nested attributes association writer.Previously, this would only raise on collection associations and produce a generic error on singular associations.
Now, it will raise on both collection and singular associations.
Joshua Young
Fix single quote escapes on default generated MySQL columns.
MySQL 5.7.5+ supports generated columns, which can be used to create a column that is computed from an expression.
Previously, the schema dump would output a string with double escapes for generated columns with single quotes in the default expression.
This would result in issues when importing the schema on a fresh instance of a MySQL database.
Now, the string will not be escaped and will be valid Ruby upon importing of the schema.
Yash Kapadia
Fix Migrations with versions older than 7.1 validating options given to
add_reference
andt.references
.Hartley McGuire
Add
<role>_types
class method toActiveRecord::DelegatedType
so that the delegated types can be introspected.JP Rosevear
Make
schema_dump
,query_cache
,replica
anddatabase_tasks
configurable viaDATABASE_URL
.This wouldn't always work previously because boolean values would be interpreted as strings.
e.g.
DATABASE_URL=postgres://localhost/foo?schema_dump=false
now properly disable dumping the schemacache.
Mike Coutermarsh, Jean Boussier
Introduce
ActiveRecord::Transactions::ClassMethods#set_callback
.It is identical to
ActiveSupport::Callbacks::ClassMethods#set_callback
but with support for
after_commit
andafter_rollback
callback options.Joshua Young
Make
ActiveRecord::Encryption::Encryptor
agnostic of the serialization format used for encrypted data.Previously, the encryptor instance only allowed an encrypted value serialized as a
String
to be passed to the message serializer.Now, the encryptor lets the configured
message_serializer
decide which types of serialized encrypted values are supported. A custom serialiser is therefore allowed to serializeActiveRecord::Encryption::Message
objects using a type other thanString
.The default
ActiveRecord::Encryption::MessageSerializer
already ensures that onlyString
objects are passed for deserialization.Maxime Réty
Fix
encrypted_attribute?
to take into account context properties passed toencrypts
.Maxime Réty
The object returned by
explain
now responds topluck
,first
,last
,average
,count
,maximum
,minimum
, andsum
. Thosenew methods run
EXPLAIN
on the corresponding queries:EXPLAIN SELECT COUNT(*) FROM
users
...
EXPLAIN SELECT MAX(
users
.id
) FROMusers
...
Fixes an issue where
validates_associated
:on
option wasn't respectedwhen validating associated records.
Austen Madden, Alex Ghiculescu, Rafał Brize
Allow overriding SQLite defaults from
database.yml
.Any PRAGMA configuration set under the
pragmas
key in the configurationfile takes precedence over Rails' defaults, and additional PRAGMAs can be
set as well.
Stephen Margheim
Remove warning message when running SQLite in production, but leave it unconfigured.
There are valid use cases for running SQLite in production. However, it must be done
with care, so instead of a warning most users won't see anyway, it's preferable to
leave the configuration commented out to force them to think about having the database
on a persistent volume etc.
Jacopo Beschi, Jean Boussier
Add support for generated columns to the SQLite3 adapter.
Generated columns (both stored and dynamic) are supported since version 3.31.0 of SQLite.
This adds support for those to the SQLite3 adapter.
Stephen Margheim
TrilogyAdapter: ignore
host
ifsocket
parameter is set.This allows to configure a connection on a UNIX socket via
DATABASE_URL
:Jean Boussier
Make
assert_queries_count
,assert_no_queries
,assert_queries_match
, andassert_no_queries_match
assertions public.To assert the expected number of queries are made, Rails internally uses
assert_queries_count
andassert_no_queries
. To assert that specific SQL queries are made,assert_queries_match
andassert_no_queries_match
are used. These assertions can now be used in applications as well.Petrik de Heus, fatkodima
Fix
has_secure_token
calls the setter method on initialize.Abeid Ahmed
When using a
DATABASE_URL
, allow for a configuration to map the protocol in the URL to a specific databaseadapter. This allows decoupling the adapter the application chooses to use from the database connection details
set in the deployment environment.
ENV['DATABASE_URL'] = "mysql://localhost/example_database"
will connect to MySQL using the trilogy adapter
In cases where MySQL returns
warning_count
greater than zero, but returns no warnings whenthe
SHOW WARNINGS
query is executed,ActiveRecord.db_warnings_action
proc will still becalled with a generic warning message rather than silently ignoring the warning(s).
Kevin McPhillips
DatabaseConfigurations#configs_for
accepts a symbol in thename
parameter.Andrew Novoselac
Fix
where(field: values)
queries whenfield
is a serialized attribute(for example, when
field
usesActiveRecord::Base.serialize
or is a JSONcolumn).
João Alves
Make the output of
ActiveRecord::Core#inspect
configurable.By default, calling
inspect
on a record will yield a formatted string including just theid
.The attributes to be included in the output of
inspect
can be configured withActiveRecord::Core#attributes_for_inspect
.With
attributes_for_inspect
set to:all
,inspect
will list all the record's attributes.In
development
andtest
mode,attributes_for_inspect
will be set to:all
by default.You can also call
full_inspect
to get an inspection with all the attributes.The attributes in
attribute_for_inspect
will also be used forpretty_print
.Andrew Novoselac
Don't mark attributes as changed when reassigned to
Float::INFINITY
or-Float::INFINITY
.Maicol Bentancor
Support the
RETURNING
clause for MariaDB.fatkodima, Nikolay Kondratyev
The SQLite3 adapter now implements the
supports_deferrable_constraints?
contract.Allows foreign keys to be deferred by adding the
:deferrable
key to theforeign_key
options.Stephen Margheim
Add the
set_constraints
helper to PostgreSQL connections.Cody Cutrer
Include
ActiveModel::API
inActiveRecord::Base
.Sean Doyle
Ensure
#signed_id
outputsurl_safe
strings.Jason Meller
Add
nulls_last
and workingdesc.nulls_first
for MySQL.Tristan Fellows
Allow for more complex hash arguments for
order
which mimicswhere
inActiveRecord::Relation
.Myles Boone
Action View
Fix templates with strict locals to also include
local_assigns
.Previously templates defining strict locals wouldn't receive the
local_assigns
hash.
Jean Boussier
Add queries count to template rendering instrumentation.
Before
After
Raise
ArgumentError
if:renderable
object does not respond to#render_in
.Sean Doyle
Add the
nonce: true
option forstylesheet_link_tag
helper to support automatic nonce generation for Content Security Policy.Works the same way as
javascript_include_tag nonce: true
does.Akhil G Krishnan, AJ Esler
Parse
ActionView::TestCase#rendered
HTML content asNokogiri::XML::DocumentFragment
instead ofNokogiri::XML::Document
.Sean Doyle
Rename
ActionView::TestCase::Behavior::Content
toActionView::TestCase::Behavior::RenderedViewContent
.Make
RenderedViewContent
inherit fromString
. Make private API with:nodoc:
Sean Doyle
Deprecate passing
nil
as value for themodel:
argument to theform_with
method.Collin Jilbert
Alias
field_set_tag
helper tofieldset_tag
to match<fieldset>
element.Sean Doyle
Deprecate passing content to void elements when using
tag.br
type tag builders.Hartley McGuire
Fix the
number_to_human_size
view helper to correctly work with negative numbers.Earlopain
Automatically discard the implicit locals injected by collection rendering for template that can't accept them.
When rendering a collection, two implicit variables are injected, which breaks templates with strict locals.
Now they are only passed if the template will actually accept them.
Yasha Krasnou, Jean Boussier
Fix
@rails/ujs
callingstart()
an extra time when using bundlers.Hartley McGuire, Ryunosuke Sato
Fix the
capture
view helper compatibility with HAML and Slim.When a blank string was captured in HAML or Slim (and possibly other template engines)
it would instead return the entire buffer.
Jean Boussier
Updated
@rails/ujs
files to ignore certain data-* attributes when element is contenteditable.This fix was already landed in >= 7.0.4.3, < 7.1.0.
[CVE-2023-23913]
Ryunosuke Sato
Added validation for HTML tag names in the
tag
andcontent_tag
helper method.The
tag
andcontent_tag
method now checks that the provided tag name adheres to the HTMLspecification. If an invalid HTML tag name is provided, the method raises an
ArgumentError
with an appropriate error message.
Examples:
Raises ArgumentError: Invalid HTML5 tag name: 12p
Raises ArgumentError: Invalid HTML5 tag name: ""
Raises ArgumentError: Invalid HTML5 tag name: div/
Raises ArgumentError: Invalid HTML5 tag name: "image file"
Action Pack
Allow bots to ignore
allow_browser
.Matthew Nguyen
Include the HTTP Permissions-Policy on non-HTML Content-Types
[CVE-2024-28103]
Aaron Patterson, Zack Deveau
Fix
Mime::Type.parse
handling type parameters for HTTP Accept headers.Taylor Chaparro
Fix the error page that is displayed when a view template is missing to account for nested controller paths in the
suggested correct location for the missing template.
Joshua Young
Add
save_and_open_page
helper toIntegrationTest
.save_and_open_page
is a helpful helper to keep a short feedback loop when working on system tests.A similar helper with matching signature has been added to integration tests.
Joé Dupuis
Fix a regression in 7.1.3 passing a
to:
option without a controller when the controller is already defined by a scope.Étienne Barrié
Request Forgery takes relative paths into account.
Stefan Wienert
Add ".test" as a default allowed host in development to ensure smooth golden-path setup with puma.dev.
DHH
Add
allow_browser
to set minimum browser versions for the application.A browser that's blocked will by default be served the file in
public/406-unsupported-browser.html
with a HTTP status code of "406 Not Acceptable".Allow only browsers natively supporting webp images, web push, badges, import maps, CSS nesting + :has
All versions of Chrome and Opera will be allowed, but no versions of "internet explorer" (ie). Safari needs to be 16.4+ and Firefox 121+.
In addition to the browsers blocked by ApplicationController, also block Opera below 104 and Chrome below 119 for the show action.
Add rate limiting API.
DHH, Jean Boussier
Add
image/svg+xml
to the compressible content types ofActionDispatch::Static
.Georg Ledermann
Add instrumentation for
ActionController::Live#send_stream
.Allows subscribing to
send_stream
events. The event payload contains the filename, disposition, and type.Hannah Ramadan
Add support for
with_routing
test helper inActionDispatch::IntegrationTest
.Gannon McGibbon
Remove deprecated support to set
Rails.application.config.action_dispatch.show_exceptions
totrue
andfalse
.Rafael Mendonça França
Remove deprecated
speaker
,vibrate
, andvr
permissions policy directives.Rafael Mendonça França
Remove deprecated
Rails.application.config.action_dispatch.return_only_request_media_type_on_content_type
.Rafael Mendonça França
Deprecate
Rails.application.config.action_controller.allow_deprecated_parameters_hash_equality
.Rafael Mendonça França
Remove deprecated comparison between
ActionController::Parameters
andHash
.Rafael Mendonça França
Remove deprecated constant
AbstractController::Helpers::MissingHelperError
.Rafael Mendonça França
Fix a race condition that could cause a
Text file busy - chromedriver
error with parallel system tests.
Matt Brictson
Add
racc
as a dependency since it will become a bundled gem in Ruby 3.4.0Hartley McGuire
Remove deprecated constant
ActionDispatch::IllegalStateError
.Rafael Mendonça França
Add parameter filter capability for redirect locations.
It uses the
config.filter_parameters
to match what needs to be filtered.The result would be like this:
Fixes #14055.
Roque Pinel, Trevor Turk, tonytonyjan
Active Job
All tests now respect the
active_job.queue_adapter
config.Previously if you had set
config.active_job.queue_adapter
in yourconfig/application.rb
or
config/environments/test.rb
file, the adapter you selected was previously not used consistentlyacross all tests. In some tests your adapter would be used, but other tests would use the
TestAdapter
.In Rails 7.2, all tests will respect the
queue_adapter
config if provided. If no config is provided,the
TestAdapter
will continue to be used.See #48585 for more details.
Alex Ghiculescu
Make Active Job transaction aware when used conjointly with Active Record.
A common mistake with Active Job is to enqueue jobs from inside a transaction,
causing them to potentially be picked and ran by another process, before the
transaction is committed, which may result in various errors.
Now Active Job will automatically defer the enqueuing to after the transaction is committed,
and drop the job if the transaction is rolled back.
Various queue implementations can choose to disable this behavior, and users can disable it,
or force it on a per job basis:
Jean Boussier, Cristian Bica
Do not trigger immediate loading of
ActiveJob::Base
when loadingActiveJob::TestHelper
.Maxime Réty
Preserve the serialized timezone when deserializing `ActiveSupport::TimeWithZon
Configuration
📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.