Update dependency @rails/activestorage to v7 #66
Closed
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:
6.1.4
->7.0.2
Release Notes
rails/rails
v7.0.2
Compare Source
Active Support
Fix
ActiveSupport::EncryptedConfiguration
to be compatible with Psych 4Stephen Sugden
Improve
File.atomic_write
error handling.Daniel Pepper
Active Model
Use different cache namespace for proxy calls
Models can currently have different attribute bodies for the same method
names, leading to conflicts. Adding a new namespace
:active_model_proxy
fixes the issue.
Chris Salzberg
Active Record
Fix
PG.connect
keyword arguments deprecation warning on ruby 2.7.Nikita Vasilevsky
Fix the ability to exclude encryption params from being autofiltered.
Mark Gangl
Dump the precision for datetime columns following the new defaults.
Rafael Mendonça França
Make sure encrypted attributes are not being filtered twice.
Nikita Vasilevsky
Dump the database schema containing the current Rails version.
Since https://github.com/rails/rails/pull/42297, Rails now generate datetime columns
with a default precision of 6. This means that users upgrading to Rails 7.0 from 6.1,
when loading the database schema, would get the new precision value, which would not match
the production schema.
To avoid this the schema dumper will generate the new format which will include the Rails
version and will look like this:
When upgrading from Rails 6.1 to Rails 7.0, you can run the
rails app:update
task that willset the current schema version to 6.1.
Rafael Mendonça França
Fix parsing expression for PostgreSQL generated column.
fatkodima
Fix
Mysql2::Error: Commands out of sync; you can't run this command now
when bulk-inserting fixtures that exceed
max_allowed_packet
configuration.Nikita Vasilevsky
Fix error when saving an association with a relation named
record
.Dorian Marié
Fix
MySQL::SchemaDumper
behavior about datetime precision value.y0t4
Improve associated with no reflection error.
Nikolai
Fix PG.connect keyword arguments deprecation warning on ruby 2.7.
Fixes #44307.
Nikita Vasilevsky
Fix passing options to
check_constraint
fromchange_table
.Frederick Cheung
Action View
Ensure
preload_link_tag
preloads JavaScript modules correctly.Máximo Mussini
Fix
stylesheet_link_tag
and similar helpers are being used to work in objects witha
response
method.dark-panda
Action Pack
Active Job
Action Mailer
Action Cable
Active Storage
Revert the ability to pass
service_name
param toDirectUploadsController
which was introducedin 7.0.0.
That change caused a lot of problems to upgrade Rails applications so we decided to remove it
while in work in a more backwards compatible implementation.
Gannon McGibbon
Allow applications to opt out of precompiling Active Storage JavaScript assets.
jlestavel
Action Mailbox
Action Text
Railties
v7.0.1
Compare Source
Active Support
Fix
Class#descendants
andDescendantsTracker#descendants
compatibility with Ruby 3.1.The native
Class#descendants
was reverted prior to Ruby 3.1 release,but
Class#subclasses
was kept, breaking the feature detection.Jean Boussier
Active Model
Active Record
Change
QueryMethods#in_order_of
to drop records not listed in values.in_order_of
now filters down to the values provided, to match the behavior of theEnumerable
version.Kevin Newton
Allow named expression indexes to be revertible.
Previously, the following code would raise an error in a reversible migration executed while rolling back, due to the index name not being used in the index removal.
Fixes #43331.
Oliver Günther
Better error messages when association name is invalid in the argument of
ActiveRecord::QueryMethods::WhereChain#missing
.ykpythemind
Fix ordered migrations for single db in multi db environment.
Himanshu
Extract
on update CURRENT_TIMESTAMP
for mysql2 adapter.Kazuhiro Masuda
Fix incorrect argument in PostgreSQL structure dump tasks.
Updating the
--no-comment
argument added in Rails 7 to the correct--no-comments
argument.Alex Dent
Fix schema dumping column default SQL values for sqlite3.
fatkodima
Correctly parse complex check constraint expressions for PostgreSQL.
fatkodima
Fix
timestamptz
attributes on PostgreSQL handle blank inputs.Alex Ghiculescu
Fix migration compatibility to create SQLite references/belongs_to column as integer when migration version is 6.0.
Reference/belongs_to in migrations with version 6.0 were creating columns as
bigint instead of integer for the SQLite Adapter.
Marcelo Lauxen
Fix joining through a polymorphic association.
Alexandre Ruban
Fix
QueryMethods#in_order_of
to handle empty order list.Also more explicitly set the column as secondary order, so that any other
value is still ordered.
Jean Boussier
Fix
rails dbconsole
for 3-tier config.Eileen M. Uchitelle
Fix quoting of column aliases generated by calculation methods.
Since the alias is derived from the table name, we can't assume the result
is a valid identifier.
syntax error at or near "1" (ActiveRecord::StatementInvalid)
LINE 1: SELECT COUNT(*) AS count_all, "1abc"."id" AS 1abc_id FROM "1...
Action View
Fix
button_to
to work with a hash parameter as URL.MingyuanQin
Fix
link_to
with a model passed as an argument twice.Alex Ghiculescu
Action Pack
Fix
ActionController::Parameters
methods to keep the original logger context when creating a new copyof the original object.
Yutaka Kamei
Active Job
Allow testing
discard_on/retry_on ActiveJob::DeserializationError
Previously in
perform_enqueued_jobs
,deserialize_arguments_if_needed
was called before calling
perform_now
. When a record no longer existsand is serialized using GlobalID this led to raising
an
ActiveJob::DeserializationError
before reachingperform_now
call.This behaviour makes difficult testing the job
discard_on/retry_on
logic.Now
deserialize_arguments_if_needed
call is postponed to whenperform_now
is called.
Example:
...
In the test
Action Mailer
Keep configuration of
smtp_settings
consistent between 6.1 and 7.0.André Luis Leal Cardoso Junior
Action Cable
Active Storage
Action Mailbox
Action Text
Railties
Prevent duplicate entries in plugin Gemfile.
Jonathan Hefner
Fix asset pipeline errors for plugin dummy apps.
Jonathan Hefner
Fix generated route revocation.
Jonathan Hefner
Addresses an issue in which Sidekiq jobs could not reload certain
namespaces.
See fxn/zeitwerk#198 for
details.
Xavier Noria
Fix plugin generator to a plugin that pass all the tests.
Rafael Mendonça França
v7.0.0
Compare Source
Action Cable
The Action Cable client now ensures successful channel subscriptions:
the server confirms the subscription or the channel is torn down.
by a subscribe (on the same channel identifier) and the requests are
handled out of order by the ActionCable server, thereby ignoring the
subscribe command.
Daniel Spinosa
Compile ESM package that can be used directly in the browser as actioncable.esm.js.
DHH
Move action_cable.js to actioncable.js to match naming convention used for other Rails frameworks, and use JS console to communicate the deprecation.
DHH
Stop transpiling the UMD package generated as actioncable.js and drop the IE11 testing that relied on that.
DHH
Truncate broadcast logging messages.
J Smith
OpenSSL constants are now used for Digest computations.
Dirkjan Bussink
The Action Cable client now includes safeguards to prevent a "thundering
herd" of client reconnects after server connectivity loss:
threshold after the server's last ping before making the first
reconnection attempt.
logarithmic backoff. To allow the delay between reconnection attempts to
increase slowly at first, the default exponentiation base is < 2.
Jonathan Hefner
Action Mailbox
Removed deprecated environment variable
MAILGUN_INGRESS_API_KEY
.Rafael Mendonça França
Removed deprecated
Rails.application.credentials.action_mailbox.mailgun_api_key
.Rafael Mendonça França
Add
attachments
to the list of permitted parameters for inbound emails conductor.When using the conductor to test inbound emails with attachments, this prevents an
unpermitted parameter warning in default configurations, and prevents errors for
applications that set:
David Jones, Dana Henke
Add ability to configure ActiveStorage service
for storing email raw source.
config/storage.yml
Add ability to incinerate an inbound message through the conductor interface.
Santiago Bartesaghi
OpenSSL constants are now used for Digest computations.
Dirkjan Bussink
Action Mailer
Remove deprecated
ActionMailer::DeliveryJob
andActionMailer::Parameterized::DeliveryJob
in favor of
ActionMailer::MailDeliveryJob
.Rafael Mendonça França
email_address_with_name
returns just the address if name is blank.Thomas Hutterer
Configures a default of 5 for both
open_timeout
andread_timeout
for SMTP Settings.André Luis Leal Cardoso Junior
Action Pack
Deprecate
Rails.application.config.action_controller.urlsafe_csrf_tokens
. This config is now always enabled.Étienne Barrié
Instance variables set in requests in a
ActionController::TestCase
are now cleared before the next requestThis means if you make multiple requests in the same test, instance variables set in the first request will
not persist into the second one. (It's not recommended to make multiple requests in the same test.)
Alex Ghiculescu
Rails.application.executor
hooks can now be called around every request in aActionController::TestCase
This helps to better simulate request or job local state being reset between requests and prevent state
leaking from one request to another.
To enable this, set
config.active_support.executor_around_test_case = true
(this is the default in Rails 7).Alex Ghiculescu
Consider onion services secure for cookies.
Justin Tracey
Remove deprecated
Rails.config.action_view.raise_on_missing_translations
.Rafael Mendonça França
Remove deprecated support to passing a path to
fixture_file_upload
relative tofixture_path
.Rafael Mendonça França
Remove deprecated
ActionDispatch::SystemTestCase#host!
.Rafael Mendonça França
Remove deprecated
Rails.config.action_dispatch.hosts_response_app
.Rafael Mendonça França
Remove deprecated
ActionDispatch::Response.return_only_media_type_on_content_type
.Rafael Mendonça França
Raise
ActionController::Redirecting::UnsafeRedirectError
for unsaferedirect_to
redirects.This allows
rescue_from
to be used to add a default fallback route:Kasper Timm Hansen, Chris Oliver
Add
url_from
to verify a redirect location is internal.Takes the open redirect protection from
redirect_to
so users can wrap aparam, and fall back to an alternate redirect URL when the param provided
one is unsafe.
dmcge, Kasper Timm Hansen
Allow Capybara driver name overrides in
SystemTestCase::driven_by
Allow users to prevent conflicts among drivers that use the same driver
type (selenium, poltergeist, webkit, rack test).
Fixes #42502
Chris LaRose
Allow multiline to be passed in routes when using wildcard segments.
Previously routes with newlines weren't detected when using wildcard segments, returning
a
No route matches
error.After this change, routes with newlines are detected on wildcard segments. Example
After the change, the path matches.
Treat html suffix in controller translation.
Rui Onodera, Gavin Miller
Allow permitting numeric params.
Previously it was impossible to permit different fields on numeric parameters.
After this change you can specify different fields for each numbered parameter.
For example params like,
Before you could permit name on each author with,
permit book: { authors_attributes: [ :name ] }
After this change you can permit different keys on each numbered element,
permit book: { authors_attributes: { '1': [ :name ], '0': [ :name, :age_of_death ] } }
Fixes #41625
Adam Hess
Update
HostAuthorization
middleware to render debug info onlywhen
config.consider_all_requests_local
is set to true.Also, blocked host info is always logged with level
error
.Fixes #42813
Nikita Vyrko
Add Server-Timing middleware
Server-Timing specification defines how the server can communicate to browsers performance metrics
about the request it is responding to.
The ServerTiming middleware is enabled by default on
development
environment by default using theconfig.server_timing
setting and set the relevant duration metrics in theServer-Timing
headerThe full specification for Server-Timing header can be found in: https://www.w3.org/TR/server-timing/#dfn-server-timing-header-field
Sebastian Sogamoso, Guillermo Iguaran
Use a static error message when raising
ActionDispatch::Http::Parameters::ParseError
to avoid inadvertently logging the HTTP request body at the
fatal
level when it containsmalformed JSON.
Fixes #41145
Aaron Lahey
Add
Middleware#delete!
to delete middleware or raise if not found.Middleware#delete!
works just likeMiddleware#delete
but willraise an error if the middleware isn't found.
Alex Ghiculescu, Petrik de Heus, Junichi Sato
Raise error on unpermitted open redirects.
Add
allow_other_host
options toredirect_to
.Opt in to this behaviour with
ActionController::Base.raise_on_open_redirects = true
.Gannon McGibbon
Deprecate
poltergeist
andwebkit
(capybara-webkit) driver registration for system testing (they will be removed in Rails 7.1). Addcuprite
instead.Poltergeist and capybara-webkit are already not maintained. These usage in Rails are removed for avoiding confusing users.
Cuprite is a good alternative to Poltergeist. Some guide descriptions are replaced from Poltergeist to Cuprite.
Yusuke Iwaki
Exclude additional flash types from
ActionController::Base.action_methods
.Ensures that additional flash types defined on ActionController::Base subclasses
are not listed as actions on that controller.
Gavin Morrice
OpenSSL constants are now used for Digest computations.
Dirkjan Bussink
Remove IE6-7-8 file download related hack/fix from ActionController::DataStreaming module.
Due to the age of those versions of IE this fix is no longer relevant, more importantly it creates an edge-case for unexpected Cache-Control headers.
Tadas Sasnauskas
Configuration setting to skip logging an uncaught exception backtrace when the exception is
present in
rescued_responses
.It may be too noisy to get all backtraces logged for applications that manage uncaught
exceptions via
rescued_responses
andexceptions_app
.config.action_dispatch.log_rescued_responses
(defaults totrue
) can be set tofalse
inthis case, so that only exceptions not found in
rescued_responses
will be logged.Alexander Azarov, Mike Dalessio
Ignore file fixtures on
db:fixtures:load
.Kevin Sjöberg
Fix ActionController::Live controller test deadlocks by removing the body buffer size limit for tests.
Dylan Thacker-Smith
New
ActionController::ConditionalGet#no_store
method to set HTTP cache controlno-store
directive.Tadas Sasnauskas
Drop support for the
SERVER_ADDR
header.Following up https://github.com/rack/rack/pull/1573 and https://github.com/rails/rails/pull/42349.
Ricardo Díaz
Set session options when initializing a basic session.
Gannon McGibbon
Add
cache_control: {}
option tofresh_when
andstale?
.Works as a shortcut to set
response.cache_control
with the above methods.Jacopo Beschi
Writing into a disabled session will now raise an error.
Previously when no session store was set, writing into the session would silently fail.
Jean Boussier
Add support for 'require-trusted-types-for' and 'trusted-types' headers.
Fixes #42034.
lfalcao
Remove inline styles and address basic accessibility issues on rescue templates.
Jacob Herrington
Add support for 'private, no-store' Cache-Control headers.
Previously, 'no-store' was exclusive; no other directives could be specified.
Alex Smith
Expand payload of
unpermitted_parameters.action_controller
instrumentation to allow subscribers toknow which controller action received unpermitted parameters.
bbuchalter
Add
ActionController::Live#send_stream
that makes it more convenient to send generated streams:DHH
Add
ActionController::Live::Buffer#writeln
to write a line to the stream with a newline included.DHH
ActionDispatch::Request#content_type
now returned Content-Type header as it is.Previously,
ActionDispatch::Request#content_type
returned value does NOT contain charset part.This behavior changed to returned Content-Type header containing charset part as it is.
If you want just MIME type, please use
ActionDispatch::Request#media_type
instead.Before:
After:
Rafael Mendonça França
Change
ActionDispatch::Request#media_type
to returnnil
when the request don't have aContent-Type
header.Rafael Mendonça França
Fix error in
ActionController::LogSubscriber
that would happen when throwing inside a controller action.Janko Marohnić
Allow anything with
#to_str
(likeAddressable::URI
) as aredirect_to
location.ojab
Change the request method to a
GET
when passing failed requests down toconfig.exceptions_app
.Alex Robbin
Deprecate the ability to assign a single value to
config.action_dispatch.trusted_proxies
as
RemoteIp
middleware behaves inconsistently depending on whether this is configuredwith a single value or an enumerable.
Fixes #40772.
Christian Sutter
Add
redirect_back_or_to(fallback_location, **)
as a more aesthetically pleasing version ofredirect_back fallback_location:, **
.The old method name is retained without explicit deprecation.
DHH
Action Text
Fix an issue with how nested lists were displayed when converting to plain text
Matt Swanson
Allow passing in a custom
direct_upload_url
orblob_url_template
torich_text_area_tag
.Lucas Mansur
Make the Action Text + Trix JavaScript and CSS available through the asset pipeline.
DHH
OpenSSL constants are now used for Digest computations.
Dirkjan Bussink
Add support for passing
form:
option torich_text_area_tag
andrich_text_area
helpers to specify the<input type="hidden" form="...">
value.
Sean Doyle
Add
config.action_text.attachment_tag_name
, to specify the HTML tag that contains attachments.Mark VanLandingham
Expose how we render the HTML surrounding rich text content as an
extensible
layouts/action_view/contents/_content.html.erb
template toencourage user-land customizations, while retaining private API control over how
the rich text itself is rendered by
action_text/contents/_content.html.erb
partial.
Sean Doyle
Add
with_all_rich_text
method to eager load all rich text associations on a model at once.Matt Swanson, DHH
Action View
Support
include_hidden:
option in calls toActionView::Helper::FormBuilder#file_field
withmultiple: true
tosupport submitting an empty collection of files.
=>
=>
Fix
number_with_precision(raise: true)
always raising even on valid numbers.Pedro Moreira
Support
fields model: [@​nested, @​model]
the same way asform_with model: [@​nested, @​model]
.Sean Doyle
Infer HTTP verb
[method]
from a model or Array with model as the firstargument to
button_to
when combined with a block:Sean Doyle
Support passing a Symbol as the first argument to
FormBuilder#button
:=> Create post
=>
Save as draft
Introduce the
field_name
view helper, along with theFormBuilder#field_name
counterpart:=>
Execute the
ActionView::Base.field_error_proc
within the context of theActionView::Base
instance:Sean Doyle
Add support for
button_to ..., authenticity_token: false
=> Create
=> Create
=> Create
Support rendering
<form>
elements without[action]
attributes by:form_with url: false
orform_with ..., html: { action: false }
form_for ..., url: false
orform_for ..., html: { action: false }
form_tag false
orform_tag ..., action: false
button_to "...", false
orbutton_to(false) { ... }
Sean Doyle
Add
:day_format
option todate_select
generates day options like 1st\n2nd...
Allow
link_to
helper to infer link name fromModel#to_s
when itis used with a single argument:
This assumes the model class implements a
to_s
method like this:...
Support svg unpaired tags for
tag
helper.=>
Improves the performance of ActionView::Helpers::NumberHelper formatters by avoiding the use of
exceptions as flow control.
Mike Dalessio
preload_link_tag
properly insertsas
attributes for files withimage
MIME types, such as JPG or SVG.Nate Berkopec
Add
weekday_options_for_select
andweekday_select
helper methods. Also addsweekday_select
toFormBuilder
.Drew Bragg, Dana Kashubeck, Kasper Timm Hansen
Add
caching?
helper that returns whether the current code path is being cached anduncacheable!
to denote helper methods that can't participate in fragment caching.Ben Toews, John Hawthorn, Kasper Timm Hansen, Joel Hawksley
Add
include_seconds
option fortime_field
.=>
=>
Improve error messages when template file does not exist at absolute filepath.
Ted Whang
Add
:country_code
option tosms_to
for consistency withphone_to
.Jonathan Hefner
OpenSSL constants are now used for Digest computations.
Dirkjan Bussink
The
translate
helper now passesdefault
values that aren'ttranslation keys through
I18n.translate
for interpolation.Jonathan Hefner
Adds option
extname
tostylesheet_link_tag
to skip default.css
extension appended to the stylesheet path.Before:
Deprecate
render
locals to be assigned to instance variables.Petrik de Heus
Remove legacy default
media=screen
fromstylesheet_link_tag
.André Luis Leal Cardoso Junior
Change
ActionView::Helpers::FormBuilder#button
to transformformmethod
attributes into
_method="$VERB"
Form Data to enable varied same-form actions:Sean Doyle
Change
ActionView::Helpers::UrlHelper#button_to
to always render a<button>
element, regardless of whether or not the content is passed asthe first argument or as a block.
=> Delete
=> Delete
Add
config.action_view.preload_links_header
to allow disabling ofthe
Link
header being added by default when usingstylesheet_link_tag
and
javascript_include_tag
.Andrew White
The
translate
helper now resolvesdefault
values when anil
key isspecified, instead of always returning
nil
.Jonathan Hefner
Add
config.action_view.image_loading
to configure the default value ofthe
image_tag
:loading
option.By setting
config.action_view.image_loading = "lazy"
, an application can opt in tolazy loading images sitewide, without changing view code.
Jonathan Hefner
ActionView::Helpers::FormBuilder#id
returns the valueof the
<form>
element'sid
attribute. With amethod
argument, returnsthe
id
attribute for a form field with that name.Sean Doyle
ActionView::Helpers::FormBuilder#field_id
returns the value generated bythe FormBuilder for the given attribute name.
Sean Doyle
Add
tag.attributes
to transform a Hash into HTML Attributes, ready to beinterpolated into ERB.
=>
Active Job
Remove deprecated
:return_false_on_aborted_enqueue
option.Rafael Mendonça França
Deprecated
Rails.config.active_job.skip_after_callbacks_if_terminated
.Rafael Mendonça França
Removed deprecated behavior that was not halting
after_enqueue
/after_perform
callbacks when aprevious callback was halted with
throw :abort
.Rafael Mendonça França
Raise an
SerializationError
inSerializer::ModuleSerializer
if the module name is not present.
Veerpal Brar
Allow a job to retry indefinitely
The
attempts
parameter of theretry_on
method now accepts thesymbol reference
:unlimited
in addition to a specific number of retryattempts to allow a developer to specify that a job should retry
forever until it succeeds.
the actual job code
Added possibility to check on
:priority
in test helper methodsassert_enqueued_with
andassert_performed_with
.Wojciech Wnętrzak
OpenSSL constants are now used for Digest computations.
Dirkjan Bussink
Add a Serializer for the Range class.
This should allow things like
MyJob.perform_later(range: 1..100)
.Communicate enqueue failures to callers of
perform_later
.perform_later
can now optionally take a block which will execute afterthe adapter attempts to enqueue the job. The block will receive the job
instance as an argument even if the enqueue was not successful.
Additionally,
ActiveJob
adapters now have the ability to raise anActiveJob::EnqueueError
which will be caught and stored in the jobinstance so code attempting to enqueue jobs can inspect any raised
EnqueueError
using the block.invoke some code that will retry the job after a delay
Don't log rescuable exceptions defined with
rescue_from
.Hu Hailin
Allow
rescue_from
to rescue all exceptions.Adrianna Chang, Étienne Barrié
Active Model
Remove support to Marshal load Rails 5.x
ActiveModel::AttributeSet
format.Rafael Mendonça França
Remove support to Marshal and YAML load Rails 5.x error format.
Rafael Mendonça França
Remove deprecated support to use
[]=
inActiveModel::Errors#messages
.Rafael Mendonça França
Remove deprecated support to
delete
errors fromActiveModel::Errors#messages
.Rafael Mendonça França
Remove deprecated support to
clear
errors fromActiveModel::Errors#messages
.Rafael Mendonça França
Remove deprecated support concat errors to
ActiveModel::Errors#messages
.Rafael Mendonça França
Remove deprecated
ActiveModel::Errors#to_xml
.Rafael Mendonça França
Remove deprecated
ActiveModel::Errors#keys
.Rafael Mendonça França
Remove deprecated
ActiveModel::Errors#values
.Rafael Mendonça França
Remove deprecated
ActiveModel::Errors#slice!
.Rafael Mendonça França
Remove deprecated
ActiveModel::Errors#to_h
.Rafael Mendonça França
Remove deprecated enumeration of
ActiveModel::Errors
instances as a Hash.Rafael Mendonça França
Clear secure password cache if password is set to
nil
Before:
user.password = 'something'
user.password = nil
user.password # => 'something'
Now:
user.password = 'something'
user.password = nil
user.password # => nil
Markus Doits
Introduce
ActiveModel::API
.Make
ActiveModel::API
the minimum API to talk with Action Pack and Action View.This will allow adding more functionality to
ActiveModel::Model
.Petrik de Heus, Nathaniel Watts
Fix dirty check for Float::NaN and BigDecimal::NaN.
Float::NaN and BigDecimal::NaN in Ruby are special values
and can't be compared with
==
.Marcelo Lauxen
Fix
to_json
forActiveModel::Dirty
object.Exclude
mutations_from_database
attribute from json as it lead to recursion.Anil Maurya
Add
ActiveModel::AttributeSet#values_for_database
.Returns attributes with values for assignment to the database.
Chris Salzberg
Fix delegation in ActiveModel::Type::Registry#lookup and ActiveModel::Type.lookup.
Passing a last positional argument
{}
would be incorrectly considered as keyword argument.Benoit Daloze
Cache and re-use generated attribute methods.
Generated methods with identical implementations will now share their instruction sequences
leading to reduced memory retention, and slightly faster load time.
Jean Boussier
Add
in: range
parameter tonumericality
validator.Michal Papis
Add
locale
argument toActiveModel::Name#initialize
to be used to generate thesingular
,plural
,route_key
andsingular_route_key
values.Lukas Pokorny
Make ActiveModel::Errors#inspect slimmer for readability
lulalala
Active Record
Better handle SQL queries with invalid encoding.
Would cause all adapters to fail in a non controlled way in the code
responsible to detect write queries.
The query is now properly passed to the database connection, which might or might
not be able to handle it, but will either succeed or failed in a more correct way.
Jean Boussier
Move database and shard selection config options to a generator.
Rather than generating the config options in
production.rb
when applications are created, applications can now run a generator to create an initializer and uncomment / update options as needed. All multi-db configuration can be implemented in this initializer.Eileen M. Uchitelle
Remove deprecated
ActiveRecord::DatabaseConfigurations::DatabaseConfig#spec_name
.Rafael Mendonça França
Remove deprecated
ActiveRecord::Connection#in_clause_length
.Rafael Mendonça França
Remove deprecated
ActiveRecord::Connection#allowed_index_name_length
.Rafael Mendonça França
Remove deprecated
ActiveRecord::Base#remove_connection
.Rafael Mendonça França
Load STI Models in fixtures
Data from Fixtures now loads based on the specific class for models with
Single Table Inheritance. This affects enums defined in subclasses, previously
the value of these fields was not parsed and remained
nil
Andres Howard
#authenticate
returns false when the password is blank instead of raising an error.Muhammad Muhammad Ibrahim
Fix
ActiveRecord::QueryMethods#in_order_of
behavior for integer enums.ActiveRecord::QueryMethods#in_order_of
didn't work as expected for enums stored as integers in the database when passing an array of strings or symbols as the order argument. This unexpected behavior occurred because the string or symbol values were not casted to match the integers in the database.The following example now works as expected:
Alexandre Ruban
Ignore persisted in-memory records when merging target lists.
Kevin Sjöberg
Add a new option
:update_only
toupsert_all
to configure the list of columns to update in case of conflict.Before, you could only customize the update SQL sentence via
:on_duplicate
. There is now a new option:update_only
that lets you provide a list of columns to update in case of conflict:Jorge Manrubia
Remove deprecated
ActiveRecord::Result#map!
andActiveRecord::Result#collect!
.Rafael Mendonça França
Remove deprecated
ActiveRecord::Base.configurations.to_h
.Rafael Mendonça França
Remove deprecated
ActiveRecord::Base.configurations.default_hash
.Rafael Mendonça França
Remove deprecated
ActiveRecord::Base.arel_attribute
.Rafael Mendonça França
Remove deprecated
ActiveRecord::Base.connection_config
.Rafael Mendonça França
Filter attributes in SQL logs
Previously, SQL queries in logs containing
ActiveRecord::Base.filter_attributes
were not filtered.Now, the filter attributes will be masked
[FILTERED]
in the logs whenprepared_statement
is enabled.Before:
After:
Remove deprecated
Tasks::DatabaseTasks.spec
.Rafael Mendonça França
Remove deprecated
Tasks::DatabaseTasks.current_config
.Rafael Mendonça França
Deprecate
Tasks::DatabaseTasks.schema_file_type
.Rafael Mendonça França
Remove deprecated
Tasks::DatabaseTasks.dump_filename
.Rafael Mendonça França
Remove deprecated
Tasks::DatabaseTasks.schema_file
.Rafael Mendonça França
Remove deprecated
environment
andname
arguments fromTasks::DatabaseTasks.schema_up_to_date?
.Rafael Mendonça França
Merging conditions on the same column no longer maintain both conditions,
and will be consistently replaced by the latter condition.
Rails 6.1 (IN clause is replaced by merger side equality condition)
Rails 6.1 (both conflict conditions exists, deprecated)
Rails 6.1 with rewhere to migrate to Rails 7.0's behavior
Rails 7.0 (same behavior with IN clause, mergee side condition is consistently replaced)
Remove deprecated support to
Model.reorder(nil).first
to search using non-deterministic order.Rafael Mendonça França
Remove deprecated rake tasks:
db:schema:load_if_ruby
db:structure:dump
db:structure:load
db:structure:load_if_sql
db:structure:dump:#{name}
db:structure:load:#{name}
db:test:load_structure
db:test:load_structure:#{name}
Rafael Mendonça França
Remove deprecated
DatabaseConfig#config
method.Rafael Mendonça França
Rollback transactions when the block returns earlier than expected.
Before this change, when a transaction block returned early, the transaction would be committed.
The problem is that timeouts triggered inside the transaction block was also making the incomplete transaction
to be committed, so in order to avoid this mistake, the transaction block is rolled back.
Rafael Mendonça França
Add middleware for automatic shard swapping.
Provides a basic middleware to perform automatic shard swapping. Applications will provide a resolver which will determine for an individual request which shard should be used. Example:
See guides for more details.
Eileen M. Uchitelle, John Crepezzi
Remove deprecated support to pass a column to
type_cast
.Rafael Mendonça França
Remove deprecated support to type cast to database values
ActiveRecord::Base
objects.Rafael Mendonça França
Remove deprecated support to quote
ActiveRecord::Base
objects.Rafael Mendonça França
Remove deprecacated support to resolve connection using
"primary"
as connection specification name.Rafael Mendonça França
Remove deprecation warning when using
:interval
column is used in PostgreSQL database.Now, interval columns will return
ActiveSupport::Duration
objects instead of strings.To keep the old behavior, you can add this line to your model:
Rafael Mendonça França
Remove deprecated support to YAML load
ActiveRecord::Base
instance in the Rails 4.2 and 4.1 formats.Rafael Mendonça França
Remove deprecated option
:spec_name
in theconfigs_for
method.Rafael Mendonça França
Remove deprecated
ActiveRecord::Base.allow_unsafe_raw_sql
.Rafael Mendonça França
Fix regression bug that caused ignoring additional conditions for preloading has_many-through relations.
Fixes #43132
Alexander Pauly
Fix
has_many
inversing recursion on models with recursive associations.Gannon McGibbon
Add
accepts_nested_attributes_for
support fordelegated_type
=> #Entry:0x00
id: 1
entryable_id: 1,
entryable_type: 'Message'
...>
=> #Message:0x01
id: 1
content: 'Hello world'
...>
ArgumentError: Cannot build association `entryable'. Are you trying to build a polymorphic one-to-one association?
Use subquery for DELETE with GROUP_BY and HAVING clauses.
Prior to this change, deletes with GROUP_BY and HAVING were returning an error.
After this change, GROUP_BY and HAVING are valid clauses in DELETE queries, generating the following query:
Ignacio Chiazzo Cardarello
Use subquery for UPDATE with GROUP_BY and HAVING clauses.
Prior to this change, updates with GROUP_BY and HAVING were being ignored, generating a SQL like this:
After this change, GROUP_BY and HAVING clauses are used as a subquery in updates, like this:
Ignacio Chiazzo Cardarello
Add support for setting the filename of the schema or structure dump in the database config.
Applications may now set their the filename or path of the schema / structure dump file in their database configuration.
The filename set in
schema_dump
will be used by the application. If set tofalse
the schema will not be dumped. The database tasks are responsible for adding the database directory to the filename. If a full path is provided, the Rails tasks will use that instead ofActiveRecord::DatabaseTasks.db_dir
.Eileen M. Uchitelle, Ryan Kerr
Add
ActiveRecord::Base.prohibit_shard_swapping
to prevent attempts to change the shard within a block.John Crepezzi, Eileen M. Uchitelle
Filter unchanged attributes with default function from insert query when
partial_inserts
is disabled.Akshay Birajdar, Jacopo Beschi
Add support for FILTER clause (SQL:2003) to Arel.
Currently supported by PostgreSQL 9.4+ and SQLite 3.30+.
Andrey Novikov
Automatically set timestamps on record creation during bulk insert/upsert
Prior to this change, only updates during an upsert operation (e.g.
upsert_all
) would touch timestamps (updated_{at,on}
). Now, record creations also touch timestamp columns ({created,updated}_{at,on}
).This behaviour is controlled by the
<model>.record_timestamps
config, matching the behaviour ofcreate
,update
, etc. It can also be overridden by using therecord_timestamps:
keyword argument.Note that this means
upsert_all
on models withrecord_timestamps = false
will no longer touchupdated_{at,on}
automatically.Sam Bostock
Don't require
role
when passingshard
toconnected_to
.connected_to
can now be called with ashard
only. Note thatrole
is still inherited ifconnected_to
calls are nested.Eileen M. Uchitelle
Add option to lazily load the schema cache on the connection.
Previously, the only way to load the schema cache in Active Record was through the Railtie on boot. This option provides the ability to load the schema cache on the connection after it's been established. Loading the cache lazily on the connection can be beneficial for Rails applications that use multiple databases because it will load the cache at the time the connection is established. Currently Railties doesn't have access to the connections before boot.
To use the cache, set
config.active_record.lazily_load_schema_cache = true
in your application configuration. In addition aschema_cache_path
should be set in your database configuration if you don't want to use the default "db/schema_cache.yml" path.Eileen M. Uchitelle
Allow automatic
inverse_of
detection for associations with scopes.Automatic
inverse_of
detection now works for associations with scopes. Forexample, the
comments
association here now automatically detectsinverse_of: :post
, so we don't need to pass that option:Note that the automatic detection still won't work if the inverse
association has a scope. In this example a scope on the
post
associationwould still prevent Rails from finding the inverse for the
comments
association.
This will be the default for new apps in Rails 7. To opt in:
Daniel Colson, Chris Bloom
Accept optional transaction args to
ActiveRecord::Locking::Pessimistic#with_lock
#with_lock
now accepts transaction options likerequires_new:
,isolation:
, andjoinable:
John Mileham
Adds support for deferrable foreign key constraints in PostgreSQL.
By default, foreign key constraints in PostgreSQL are checked after each statement. This works for most use cases,
but becomes a major limitation when creating related records before the parent record is inserted into the database.
One example of this is looking up / creating a person via one or more unique alias.
Using the default behavior, the transaction would fail when executing the first
INSERT
statement.By passing the
:deferrable
option to theadd_foreign_key
statement in migrations, it's possible to defer thischeck.
Passing
deferrable: true
doesn't change the default behavior, but allows manually deferring the check usingSET CONSTRAINTS ALL DEFERRED
within a transaction. This will cause the foreign keys to be checked after thetransaction.
It's also possible to adjust the default behavior from an immediate check (after the statement), to a deferred check
(after the transaction):
Benedikt Deicke
Allow configuring Postgres password through the socket URL.
For example:
will now return,
Abeid Ahmed
PostgreSQL: support custom enum types
In migrations, use
create_enum
to add a new enum type, andt.enum
to add a column.Enums will be presented correctly in
schema.rb
. Note that this is only supported bythe PostgreSQL adapter.
Alex Ghiculescu
Avoid COMMENT statements in PostgreSQL structure dumps
COMMENT statements are now omitted from the output of
db:structure:dump
when using PostgreSQL >= 11.This allows loading the dump without a pgsql superuser account.
Fixes #36816, #43107.
Janosch Müller
Add support for generated columns in PostgreSQL adapter
Generated columns are supported since version 12.0 of PostgreSQL. Th
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 has been generated by Mend Renovate. View repository job log here.