fix: EXPOSED-130 Logger throws ClassCastException with JSON and ListSerializer #1835
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When a JSON/JSONB column that takes a
List
orListSerializer
is created, it correctly deserializes/serializes the JSON array to and from the database. However, attempting to log any SQL statements with the collection as a String throws aClassCastException
.If the column is created to take an
Array
orArraySerializer
instead, then no exception is thrown when the logger is used.This happens because lists are processed by
ColumnType.valueToString()
asArrayList
, which extends theIterable
superclass and is handled separately:Whereas arrays are processed as
Array
(or another type-specific class), which does not extendIterable
, so theelse
branch is reached.This function now has an override in
JsonColumnType
.