You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix Type#cast to support Rails 8.0 bulk operations (#469)
* Add comprehensive tests for ActiveRecord Type#cast and bulk operations
- Test Type#cast returns Enumerize::Value for symbols, integers, and
strings
- Test Type#cast handles invalid values and preserves existing Value
objects
- Test insert_all/upsert_all work with mixed value types and handle
invalid values
* Fix Type#cast to handle symbol values correctly in Rails 8.0 bulk operations
Rails 8.0 changed how Type#cast is used during insert_all/upsert_all operations,
causing symbol enum values (e.g., :active) to fail. The previous implementation
always delegated to @subtype.cast first, which could incorrectly transform
symbol values before looking them up.
This fix:
- First attempts to find the enumerize value directly with the input value
- Only delegates to @subtype.cast if the direct lookup fails
- Ensures both symbol values (:active) and their database representations (1)
work correctly
This maintains backward compatibility while fixing bulk operations in Rails 8.0.
0 commit comments