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
Right now the $casting configuration on ViewableData only kicks in if the value that should be cast is not already an object. This means if a method returns some instance of DBField the casting configuration will be ignored.
The casting also doesn't care what the original value is - so the default cast of Text will cast e.g. booleans to DBText instead of to DBBoolean
More recently this caused problems when trying to allow push associative arrays to templates in #11237. We wanted to treat associative arrays as ArrayData, but this resulted in bypassing casting, which caused problems in various areas of kitchen sink.
Notes
There's a fair amount of duplicated logic regarding this between ViewableData and SSViewer_Scope - if feasible, they should be deduped and share logic between them.
Refer to this diff for when casting to ArrayData was previously removed from a PR - this may be useful e.g. for test coverage
Acceptance Criteria
A new "magic" value for the default_cast and casting configuration properties is added
This casts things intelligently - associative arrays become ArrayData and primitives become the appropriate type (boolean becomes DBBoolean, int becomes DBInt, etc)
The default value for default_cast is set to the new value
Kitchen sink is updated as necessary so that tests pass - e.g. some $casting config may need to be updated so specific associative arrays are still cast as Text, retaining existing behaviour
SSViewer_Scope::convertScalarToDBField() is updated to use the default_cast configuration value
The text was updated successfully, but these errors were encountered:
Right now the
$casting
configuration onViewableData
only kicks in if the value that should be cast is not already an object. This means if a method returns some instance ofDBField
the casting configuration will be ignored.The casting also doesn't care what the original value is - so the default cast of
Text
will cast e.g. booleans toDBText
instead of toDBBoolean
More recently this caused problems when trying to allow push associative arrays to templates in #11237. We wanted to treat associative arrays as
ArrayData
, but this resulted in bypassing casting, which caused problems in various areas of kitchen sink.Notes
ViewableData
andSSViewer_Scope
- if feasible, they should be deduped and share logic between them.ArrayData
was previously removed from a PR - this may be useful e.g. for test coverageAcceptance Criteria
default_cast
andcasting
configuration properties is addedArrayData
and primitives become the appropriate type (boolean
becomesDBBoolean
,int
becomesDBInt
, etc)default_cast
is set to the new value$casting
config may need to be updated so specific associative arrays are still cast asText
, retaining existing behaviourSSViewer_Scope::convertScalarToDBField()
is updated to use thedefault_cast
configuration valueThe text was updated successfully, but these errors were encountered: