rails/activerecord/CHANGELOG.md
Igor Depolli 00f38563a4
[ActiveRecord] Add option filter on in_order_of (#51761)
* Add option  on

* Add CHANGELOG and fix method doc

* Rename option to 'filter' and fix grammar

* Adjust filter attribute

* Fix typo and solve conflict

* Update activerecord/test/cases/relation/field_ordered_values_test.rb

Co-authored-by: Timo Schilling <timo@schilling.io>

---------

Co-authored-by: Timo Schilling <timo@schilling.io>
Co-authored-by: Rafael Mendonça França <rafael@rubyonrails.org>
2024-06-12 15:14:06 -07:00

2.3 KiB

  • Add a filter option to in_order_of to prioritize certain values in the sorting without filtering the results by these values.

    Igor Depolli

  • Fix an issue where the IDs reader method did not return expected results for preloaded associations in models using composite primary keys.

    Jay Ang

  • Allow to configure strict_loading_mode globally or within a model.

    Defaults to :all, can be changed to :n_plus_one_only.

    Garen Torikian

  • Add ActiveRecord::Relation#readonly?.

    Reflects if the relation has been marked as readonly.

    Theodor Tonum

  • 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

  • Fix inference of association model on nested models with the same demodularized name.

    E.g. with the following setup:

    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

  • 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.

    ActiveRecord.schema_cache_ignored_tables = ["developers"]
    ActiveRecord.schema_cache_ignored_table?("developers")
    => true
    

    Eileen M. Uchitelle

Please check 7-2-stable for previous changes.