Migrating Guide: v2.0.0-pre18
This version completes the JSON serialization implementation by removing the string-as-is optimization and fixes encrypted field visibility in serialization.
JSON Serialization for All Types
What Changed:
All field values (including strings) are now JSON-encoded during storage for consistent type preservation.
Storage Format:
# Before (v2.0.0-pre14):
HGET user:123 name
"John Doe" # Plain string
# After (v2.0.0-pre18):
HGET user:123 name
"\"John Doe\"" # JSON-encoded string
Migration:
No migration needed. The deserializer automatically handles:
- New format:
"\"value\""→"value" - Legacy format:
"value"→"value"
Why This Matters:
Prevents data corruption for edge cases:
- Badge
"007"stays"007"(not converted to integer7) - String
"true"stays"true"(not converted to boolean) - String
"null"stays"null"(not converted tonil)
Encrypted Field Security Fix
What Changed:
Fields defined with category: :encrypted now correctly exclude encrypted data from to_h() output.
Before:
field :secret, category: :encrypted
user.to_h # => {"id" => "123", "secret" => {...}} # ❌ Exposed!
After:
field :secret, category: :encrypted
user.to_h # => {"id" => "123"} # ✅ Secure
Both encrypted_field and field :name, category: :encrypted now behave identically for security.
Migration:
No code changes needed. Review any code relying on encrypted fields appearing in to_h() output.