2022-04-02 03:15:32 +08:00
* Remove `ActiveRecord.legacy_connection_handling` .
*Eileen M. Uchitelle*
2022-04-04 07:30:52 +08:00
* `rails db:schema:{dump,load}` now checks `ENV["SCHEMA_FORMAT"]` before config
Since `rails db:structure:{dump,load}` was deprecated there wasn't a simple
way to dump a schema to both SQL and Ruby formats. You can now do this with
an environment variable. For example:
```
SCHEMA_FORMAT=sql rake db:schema:dump
```
*Alex Ghiculescu*
2022-03-10 16:32:43 +08:00
* Fixed MariaDB default function support.
Defaults would be written wrong in "db/schema.rb" and not work correctly
if using `db:schema:load` . Further more the function name would be
added as string content when saving new records.
*kaspernj*
2022-02-05 05:32:24 +08:00
* Add `active_record.destroy_association_async_batch_size` configuration
This allows applications to specify the maximum number of records that will
be destroyed in a single background job by the `dependent: :destroy_async`
association option. By default, the current behavior will remain the same:
when a parent record is destroyed, all dependent records will be destroyed
in a single background job. If the number of dependent records is greater
than this configuration, the records will be destroyed in multiple
background jobs.
*Nick Holden*
2022-03-08 19:31:09 +08:00
* Fix `remove_foreign_key` with `:if_exists` option when foreign key actually exists.
*fatkodima*
2022-03-08 02:40:12 +08:00
* Remove `--no-comments` flag in structure dumps for PostgreSQL
This broke some apps that used custom schema comments. If you don't want
comments in your structure dump, you can use:
```ruby
ActiveRecord::Tasks::DatabaseTasks.structure_dump_flags = ['--no-comments']
```
*Alex Ghiculescu*
2022-02-23 21:31:40 +08:00
* Reduce the memory footprint of fixtures accessors.
Until now fixtures accessors were eagerly defined using `define_method` .
So the memory usage was directly dependent of the number of fixtures and
test suites.
Instead fixtures accessors are now implemented with `method_missing` ,
so they incur much less memory and CPU overhead.
*Jean Boussier*
2022-02-02 09:03:55 +08:00
* Fix `config.active_record.destroy_association_async_job` configuration
`config.active_record.destroy_association_async_job` should allow
applications to specify the job that will be used to destroy associated
records in the background for `has_many` associations with the
`dependent: :destroy_async` option. Previously, that was ignored, which
meant the default `ActiveRecord::DestroyAssociationAsyncJob` always
destroyed records in the background.
*Nick Holden*
2022-03-01 01:00:40 +08:00
* Fix `change_column_comment` to preserve column's AUTO_INCREMENT in the MySQL adapter
2022-02-19 01:59:06 +08:00
*fatkodima*
2022-02-12 02:04:02 +08:00
* Fix quoting of `ActiveSupport::Duration` and `Rational` numbers in the MySQL adapter.
*Kevin McPhillips*
2022-02-10 11:53:46 +08:00
* Allow column name with COLLATE (e.g., title COLLATE "C") as safe SQL string
*Shugo Maeda*
2022-01-27 04:36:01 +08:00
* Permit underscores in the VERSION argument to database rake tasks.
*Eddie Lebow*
2022-02-09 03:14:38 +08:00
* Reversed the order of `INSERT` statements in `structure.sql` dumps
This should decrease the likelihood of merge conflicts. New migrations
will now be added at the top of the list.
For existing apps, there will be a large diff the next time `structure.sql`
is generated.
*Alex Ghiculescu* , *Matt Larraz*
2022-02-07 01:22:33 +08:00
* Fix PG.connect keyword arguments deprecation warning on ruby 2.7
Fixes #44307 .
*Nikita Vasilevsky*
2022-01-09 09:09:52 +08:00
* Fix dropping DB connections after serialization failures and deadlocks.
Prior to 6.1.4, serialization failures and deadlocks caused rollbacks to be
issued for both real transactions and savepoints. This breaks MySQL which
disallows rollbacks of savepoints following a deadlock.
6.1.4 removed these rollbacks, for both transactions and savepoints, causing
the DB connection to be left in an unknown state and thus discarded.
These rollbacks are now restored, except for savepoints on MySQL.
*Thomas Morgan*
2022-01-09 02:11:05 +08:00
* Make `ActiveRecord::ConnectionPool` Fiber-safe
When `ActiveSupport::IsolatedExecutionState.isolation_level` is set to `:fiber` ,
the connection pool now supports multiple Fibers from the same Thread checking
out connections from the pool.
*Alex Matchneer*
2022-01-11 05:53:27 +08:00
* Add `update_attribute!` to `ActiveRecord::Persistence`
Similar to `update_attribute` , but raises `ActiveRecord::RecordNotSaved` when a `before_*` callback throws `:abort` .
```ruby
class Topic < ActiveRecord::Base
before_save :check_title
def check_title
throw(:abort) if title == "abort"
end
end
topic = Topic.create(title: "Test Title")
# #=> #< Topic title: " Test Title " >
topic.update_attribute!(:title, "Another Title")
# #=> #< Topic title: " Another Title " >
topic.update_attribute!(:title, "abort")
# raises ActiveRecord::RecordNotSaved
```
*Drew Tempelmeyer*
2022-01-11 01:25:36 +08:00
* Avoid loading every record in `ActiveRecord::Relation#pretty_print`
2021-09-24 15:46:54 +08:00
```ruby
# Before
pp Foo.all # Loads the whole table.
# After
pp Foo.all # Shows 10 items and an ellipsis.
```
*Ulysse Buonomo*
2022-01-07 01:54:41 +08:00
* 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 the `Enumerable` version.
*Kevin Newton*
2022-01-02 04:25:28 +08:00
* 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.
```ruby
add_index(:settings, "(data->'property')", using: :gin, name: :index_settings_data_property)
```
Fixes #43331 .
*Oliver Günther*
2021-12-30 11:52:54 +08:00
* 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*
2021-09-24 01:34:23 +08:00
* 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*
2021-09-12 08:08:22 +08:00
* Add a deprecation warning when `prepared_statements` configuration is not
set for the mysql2 adapter.
*Thiago Araujo and Stefanni Brasil*
2021-12-17 21:25:48 +08:00
* Fix `QueryMethods#in_order_of` to handle empty order list.
```ruby
Post.in_order_of(:id, []).to_a
```
Also more explicitly set the column as secondary order, so that any other
value is still ordered.
*Jean Boussier*
2021-12-17 18:38:50 +08:00
* 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.
```ruby
class Test < ActiveRecord::Base
self.table_name = '1abc'
end
Test.group(:id).count
# syntax error at or near "1" (ActiveRecord::StatementInvalid)
# LINE 1: SELECT COUNT(*) AS count_all, "1abc"."id" AS 1abc_id FROM "1...
```
*Jean Boussier*
2021-12-15 11:47:40 +08:00
* Add `authenticate_by` when using `has_secure_password` .
`authenticate_by` is intended to replace code like the following, which
returns early when a user with a matching email is not found:
```ruby
User.find_by(email: "...")& .authenticate("...")
```
Such code is vulnerable to timing-based enumeration attacks, wherein an
attacker can determine if a user account with a given email exists. After
confirming that an account exists, the attacker can try passwords associated
with that email address from other leaked databases, in case the user
re-used a password across multiple sites (a common practice). Additionally,
knowing an account email address allows the attacker to attempt a targeted
phishing ("spear phishing") attack.
`authenticate_by` addresses the vulnerability by taking the same amount of
time regardless of whether a user with a matching email is found:
```ruby
User.authenticate_by(email: "...", password: "...")
```
*Jonathan Hefner*
2021-12-07 23:52:30 +08:00
Please check [7-0-stable ](https://github.com/rails/rails/blob/7-0-stable/activerecord/CHANGELOG.md ) for previous changes.