Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better casting in ViewableData #11262

Closed
GuySartorelli opened this issue May 23, 2024 · 1 comment
Closed

Better casting in ViewableData #11262

GuySartorelli opened this issue May 23, 2024 · 1 comment

Comments

@GuySartorelli
Copy link
Member

GuySartorelli commented May 23, 2024

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
@GuySartorelli
Copy link
Member Author

Done as part of #11322

@GuySartorelli GuySartorelli closed this as not planned Won't fix, can't repro, duplicate, stale Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant