2023-11-15 06:25:07 +08:00
|
|
|
* `DatabaseConfigurations#configs_for` can accept a symbol in the `name` parameter.
|
|
|
|
|
|
|
|
*Andrew Novoselac*
|
|
|
|
|
2023-08-27 22:41:11 +08:00
|
|
|
* Fix `where(field: values)` queries when `field` is a serialized attribute
|
|
|
|
(for example, when `field` uses `ActiveRecord::Base.serialize` or is a JSON
|
|
|
|
column).
|
|
|
|
|
|
|
|
*João Alves*
|
|
|
|
|
2023-10-21 06:27:33 +08:00
|
|
|
* Make the output of `ActiveRecord::Core#inspect` configurable.
|
|
|
|
|
|
|
|
By default, calling `inspect` on a record will yield a formatted string including just the `id`.
|
|
|
|
|
|
|
|
```ruby
|
|
|
|
Post.first.inspect #=> "#<Post id: 1>"
|
|
|
|
```
|
|
|
|
|
|
|
|
The attributes to be included in the output of `inspect` can be configured with
|
|
|
|
`ActiveRecord::Core#attributes_for_inspect`.
|
|
|
|
|
|
|
|
```ruby
|
|
|
|
Post.attributes_for_inspect = [:id, :title]
|
|
|
|
Post.first.inspect #=> "#<Post id: 1, title: "Hello, World!">"
|
|
|
|
```
|
|
|
|
|
|
|
|
With the `attributes_for_inspect` set to `:all`, `inspect` will list all the record's attributes.
|
|
|
|
|
|
|
|
```ruby
|
|
|
|
Post.attributes_for_inspect = :all
|
|
|
|
Post.first.inspect #=> "#<Post id: 1, title: "Hello, World!", published_at: "2023-10-23 14:28:11 +0000">"
|
|
|
|
```
|
|
|
|
|
|
|
|
In development and test 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 for `pretty_print`.
|
|
|
|
|
|
|
|
*Andrew Novoselac*
|
|
|
|
|
2023-11-03 23:24:19 +08:00
|
|
|
* Don't mark Float::INFINITY as changed when reassigning it
|
|
|
|
|
|
|
|
When saving a record with a float infinite value, it shouldn't mark as changed
|
|
|
|
|
|
|
|
*Maicol Bentancor*
|
|
|
|
|
2023-10-30 07:13:48 +08:00
|
|
|
* Support `RETURNING` clause for MariaDB
|
|
|
|
|
|
|
|
*fatkodima*, *Nikolay Kondratyev*
|
|
|
|
|
2023-09-25 05:14:02 +08:00
|
|
|
* The SQLite3 adapter now implements the `supports_deferrable_constraints?` contract
|
|
|
|
|
|
|
|
Allows foreign keys to be deferred by adding the `:deferrable` key to the `foreign_key` options.
|
|
|
|
|
|
|
|
```ruby
|
|
|
|
add_reference :person, :alias, foreign_key: { deferrable: :deferred }
|
|
|
|
add_reference :alias, :person, foreign_key: { deferrable: :deferred }
|
|
|
|
```
|
|
|
|
|
|
|
|
*Stephen Margheim*
|
|
|
|
|
2023-09-07 06:26:29 +08:00
|
|
|
* Add `set_constraints` helper for PostgreSQL
|
|
|
|
|
|
|
|
```ruby
|
|
|
|
Post.create!(user_id: -1) # => ActiveRecord::InvalidForeignKey
|
|
|
|
|
|
|
|
Post.transaction do
|
|
|
|
Post.connection.set_constraints(:deferred)
|
|
|
|
p = Post.create!(user_id: -1)
|
|
|
|
u = User.create!
|
|
|
|
p.user = u
|
|
|
|
p.save!
|
|
|
|
end
|
|
|
|
```
|
|
|
|
|
|
|
|
*Cody Cutrer*
|
|
|
|
|
2023-10-18 07:08:16 +08:00
|
|
|
* Include `ActiveModel::API` in `ActiveRecord::Base`
|
|
|
|
|
|
|
|
*Sean Doyle*
|
|
|
|
|
2023-10-06 21:24:37 +08:00
|
|
|
* Ensure `#signed_id` outputs `url_safe` strings.
|
|
|
|
|
|
|
|
*Jason Meller*
|
2023-09-27 11:08:31 +08:00
|
|
|
|
2023-09-27 11:59:11 +08:00
|
|
|
Please check [7-1-stable](https://github.com/rails/rails/blob/7-1-stable/activerecord/CHANGELOG.md) for previous changes.
|