2024-05-31 03:18:46 +08:00
* Replace `SQLite3::Database#busy_timeout` with `#busy_handler_timeout=`
Provides a non-GVL-blocking, fair retry interval busy handler implementation
*Stephen Margheim*
2024-08-12 19:39:45 +08:00
* SQLite3Adapter: Translate `SQLite3::BusyException` into `ActiveRecord::StatementTimeout` .
*Matthew Nguyen*
2024-07-12 03:32:59 +08:00
* Include schema name in `enable_extension` statements in `db/schema.rb` .
The schema dumper will now include the schema name in generated
`enable_extension` statements if they differ from the current schema.
For example, if you have a migration:
```ruby
enable_extension "heroku_ext.pgcrypto"
enable_extension "pg_stat_statements"
```
then the generated schema dump will also contain:
```ruby
enable_extension "heroku_ext.pgcrypto"
enable_extension "pg_stat_statements"
```
*Tony Novak*
2024-08-14 05:04:24 +08:00
* Fix `ActiveRecord::Encryption::EncryptedAttributeType#type` to return
actual cast type.
*Vasiliy Ermolovich*
2024-08-11 15:05:44 +08:00
* SQLite3Adapter: Bulk insert fixtures.
Previously one insert command was executed for each fixture, now they are
aggregated in a single bulk insert command.
*Lázaro Nixon*
2024-07-30 23:49:57 +08:00
* PostgreSQLAdapter: Allow `disable_extension` to be called with schema-qualified name.
For parity with `enable_extension` , the `disable_extension` method can be called with a schema-qualified
name (e.g. `disable_extension "myschema.pgcrypto"` ). Note that PostgreSQL's `DROP EXTENSION` does not
actually take a schema name (unlike `CREATE EXTENSION` ), so the resulting SQL statement will only name
the extension, e.g. `DROP EXTENSION IF EXISTS "pgcrypto"` .
*Tony Novak*
2024-07-30 23:39:27 +08:00
* Make `create_schema` / `drop_schema` reversible in migrations.
Previously, `create_schema` and `drop_schema` were irreversible migration operations.
*Tony Novak*
2024-07-13 22:19:06 +08:00
* Support batching using custom columns.
```ruby
Product.in_batches(cursor: [:shop_id, :id]) do |relation|
# do something with relation
end
```
*fatkodima*
2024-05-31 06:47:22 +08:00
* Use SQLite `IMMEDIATE` transactions when possible.
Transactions run against the SQLite3 adapter default to IMMEDIATE mode to improve concurrency support and avoid busy exceptions.
*Stephen Margheim*
2024-06-06 13:32:33 +08:00
* Raise specific exception when a connection is not defined.
The new `ConnectionNotDefined` exception provides connection name, shard and role accessors indicating the details of the connection that was requested.
*Hana Harencarova* , *Matthew Draper*
2024-07-13 18:51:40 +08:00
* Delete the deprecated constant `ActiveRecord::ImmutableRelation` .
*Xavier Noria*
2023-10-30 21:15:35 +08:00
* Fix duplicate callback execution when child autosaves parent with `has_one` and `belongs_to` .
Before, persisting a new child record with a new associated parent record would run `before_validation` ,
`after_validation` , `before_save` and `after_save` callbacks twice.
Now, these callbacks are only executed once as expected.
*Joshua Young*
2024-05-04 11:27:06 +08:00
* `ActiveRecord::Encryption::Encryptor` now supports a `:compressor` option to customize the compression algorithm used.
```ruby
module ZstdCompressor
def self.deflate(data)
Zstd.compress(data)
end
def self.inflate(data)
Zstd.decompress(data)
end
end
class User
encrypts :name, compressor: ZstdCompressor
end
```
You disable compression by passing `compress: false` .
```ruby
class User
encrypts :name, compress: false
end
```
*heka1024*
2023-12-20 01:07:58 +08:00
* Add condensed `#inspect` for `ConnectionPool` , `AbstractAdapter` , and
`DatabaseConfig` .
*Hartley McGuire*
2024-02-08 16:05:22 +08:00
* Add `.shard_keys` , `.sharded?` , & `.connected_to_all_shards` methods.
```ruby
class ShardedBase < ActiveRecord::Base
self.abstract_class = true
connects_to shards: {
shard_one: { writing: :shard_one },
shard_two: { writing: :shard_two }
}
end
class ShardedModel < ShardedBase
end
ShardedModel.shard_keys => [:shard_one, :shard_two]
ShardedModel.sharded? => true
ShardedBase.connected_to_all_shards { ShardedModel.current_shard } => [:shard_one, :shard_two]
```
*Nony Dutton*
2024-06-13 06:14:06 +08:00
* Add a `filter` option to `in_order_of` to prioritize certain values in the sorting without filtering the results
by these values.
*Igor Depolli*
2024-06-04 21:08:29 +08:00
* Fix an issue where the IDs reader method did not return expected results
for preloaded associations in models using composite primary keys.
*Jay Ang*
2024-03-18 00:38:38 +08:00
* Allow to configure `strict_loading_mode` globally or within a model.
Defaults to `:all` , can be changed to `:n_plus_one_only` .
*Garen Torikian*
2024-05-30 00:52:15 +08:00
* Add `ActiveRecord::Relation#readonly?` .
2024-03-21 19:23:21 +08:00
Reflects if the relation has been marked as readonly.
*Theodor Tonum*
2024-05-24 02:53:57 +08:00
* Improve `ActiveRecord::Store` to raise a descriptive exception if the column is not either
structured (e.g., PostgreSQL +hstore+/+json+, or MySQL +json+) or declared serializable via
`ActiveRecord.store` .
Previously, a `NoMethodError` would be raised when the accessor was read or written:
NoMethodError: undefined method `accessor' for an instance of ActiveRecord::Type::Text
Now, a descriptive `ConfigurationError` is raised:
ActiveRecord::ConfigurationError: the column 'metadata' has not been configured as a store.
Please make sure the column is declared serializable via 'ActiveRecord.store' or, if your
database supports it, use a structured column type like hstore or json.
*Mike Dalessio*
2024-05-03 11:25:57 +08:00
* Fix inference of association model on nested models with the same demodularized name.
E.g. with the following setup:
```ruby
class Nested::Post < ApplicationRecord
has_one :post, through: :other
end
```
Before, `#post` would infer the model as `Nested::Post` , but now it correctly infers `Post` .
*Joshua Young*
2024-05-22 02:37:13 +08:00
* Add public method for checking if a table is ignored by the schema cache.
Previously, an application would need to reimplement `ignored_table?` from the schema cache class to check if a table was set to be ignored. This adds a public method to support this and updates the schema cache to use that directly.
```ruby
ActiveRecord.schema_cache_ignored_tables = ["developers"]
2024-05-22 03:37:38 +08:00
ActiveRecord.schema_cache_ignored_table?("developers")
2024-05-22 02:37:13 +08:00
=> true
```
*Eileen M. Uchitelle*
2024-02-22 01:43:15 +08:00
2024-05-14 00:44:50 +08:00
Please check [7-2-stable ](https://github.com/rails/rails/blob/7-2-stable/activerecord/CHANGELOG.md ) for previous changes.