2023/09/02分のコミットです。
CHANGELOGにのったコミットは以下の通りです。
activemodel/CHANGELOG.md
- Support composite identifiers in
to_key
- Fix
change_column
not settingprecision: 6
ondatetime
columns when using 7.0+ Migrations and SQLite. - Add validation option for
enum
- Change
has_secure_token
default toon: :initialize
Add CHANGELOG entries for ActiveModel::Conversion#to_key
changes
activemodel/CHANGELOG.md
、
activerecord/CHANGELOG.md
の修正です。
to_key
メソッドでcomposite keysをサポートするよう修正した、Support composite identifiers in to_keyについてCHANGELOGにエントリーを追加しています。
Document where
support for AR normalizes
Active Recordの修正です。
ActiveRecord::Base.normalizes
で指定した値はwhere
にも影響を与える旨ドキュメントにexampleを追加、及び、挙動を確認する為のテストを追加しています。
[skip ci] Document using FinderMethods.find
on composite primary key models
activerecord/lib/active_record/relation/finder_methods.rb
のdocの修正です。
FinderMethods.find
のドキュメントにcomposite primary keyを使用している場合の挙動の説明を追加しています。
Fix DescendantsTrackerTest when ran in isolation
activesupport/lib/active_support/descendants_tracker.rb
の修正です。
Remove useless include in DescendantsTrackerの対応の影響で、DescendantsTracker
のテストがコケるようになってしまっていたのを修正しています。
[skip ci] ActiveModel notable changes added to 7.1 release note
rails guideのRuby on Rails 7.1 Release Notes
の修正です。
Active ModelのNotable changesについての説明を追加しています。
Fix change_column not setting precision for sqlite
activerecord/lib/active_record/connection_adapters/sqlite3/schema_definitions.rb
、
activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb
の修正です。
SQLite3 adapter + バージョンが7.0以上のmigrationファイルで、datetime
カラムに対するprecision: 6
が設定されないバグがあったのを修正しています。
Make enums validatable without raising error (#49100)
activerecord/lib/active_record/enum.rb
の修正です。
enum
に対してvalidationの挙動を指定出来るよう修正しています。save
より前にvalidationを実行したい場合、enum
にvalidate: true
を指定すれば良いようになっています。
class Contract < ApplicationRecord enum :status, %w[in_progress completed], validate: true end Contract.new(status: "unknown").valid? # => false Contract.new(status: nil).valid? # => false Contract.new(status: "completed").valid? # => true
また、validate
にはallow_nil
などのオプションも指定出来るようになっています(内部的にはvalidates_inclusion_of
が使用されるようになっています)。
class Contract < ApplicationRecord enum :status, %w[in_progress completed], validate: { allow_nil: true } end Contract.new(status: "unknown").valid? # => false Contract.new(status: nil).valid? # => true Contract.new(status: "completed").valid? # => true
Merge pull request #49112 from gmcgibbon/cpk_id_docs
activerecord/lib/active_record/attribute_methods/primary_key.rb
、
activerecord/lib/active_record/model_schema.rb
のdocの修正です。
id
関係のメソッド(e.g: id
、id_before_type_cast
)にComposite Primary Keyを使用している場合の挙動についての説明を追加しています。
Change has_secure_token
default to on: :initialize
Active Record、railtiesの修正です。
has_secure_token
を使用している場合の値の設定タイミングのデフォルトをconfig.active_record.generate_secure_token_on
で指定出来るよう修正しています。既存の挙動は:create
(作成時に設定)ですが、config.active_record.generate_secure_token_on
に:initialize
を指定する、または、load_defaults 7.1
を指定している場合、modelの初期化時に設定するようになります。
Use the released version of trilogy
Gemfile
の修正です。
trilogy
gemを使用するのにRubygemsにリリースされているバージョンを使用するよう修正しています。
Merge pull request #49067 from p8/performance/securerandom-choose
activesupport/lib/active_support/core_ext/securerandom.rb
の修正です。
Ruby 3.3以上の場合、SecureRandom.base36/base58
メソッドで値を生成する際にSecureRandom.alphanumeric
+ chars
オプションを指定するよう修正しています。元の処理よりこちらの方が高速な為。
参考: Feature #18183: make SecureRandom.choose public
Merge pull request #49065 from RuhmUndAnsehen/fix-_to_partial_path-model_name
activemodel/lib/active_model/conversion.rb
の修正です。
ActiveModel::Conversion._to_partial_path
メソッドで、定義されている場合modelのmodel_name
の値をpartial pathとして使用するよう修正しています。他のpath参照系のメソッドと挙動を合わせる為。
Make sure the message format doesn't change
activesupport/lib/active_support/messages/metadata.rb
の修正です。
use_message_serializer_for_metadata
がfalseの場合、ActiveSupport::MessageVerifier
が生成するメッセージがが古いRailsで生成したデータから変わらないよう修正しています。