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

fix: EXPOSED-261 [H2] JSON column throws when setting nullable parameters #1969

Merged
merged 1 commit into from
Jan 17, 2024

Conversation

bog-walk
Copy link
Member

When using H2, attempting to insert null into a nullable JSON column results in an NPE that states:

null cannot be cast to non-null type kotlin.String

When using PostgreSQL-NG, attempting to retrieve a null value stored in a JSON column results in a deserialization error because a non-null object is read with string value 'null'.

Both these issues occur because the JsonColumnType override for setParameter() does not handle null values correctly.
In the case of PostgreSQL-NG, this meant that a null value was being stored as a string literal instead of SQL NULL.

If null values are passed, the dialect overrides now ensure that they are sent to the super implementation so they can be handled as SQL NULL.

…ters

When using H2, attempting to insert a null value into a nullable JSON column results in an NPE
that states: 'null cannot be cast to non-null type kotlin.String'.

When using PostgreSQL-NG, attempting to retrieve a null value stored in a JSON column results in a
deserialization error because non-null object is read with string value 'null'.

Both these issues occur because the JsonColumnType override for setParameter()
does not handle null values correctly. In the case of PostgreSQL-NG, this meant
that a null value was being stored as a string literal instead of SQL NULL.

If null values are passed, the dialect overrides now pass them on to the super
implementation so they can be handled correctly.
@bog-walk bog-walk requested review from e5l and joc-a January 16, 2024 19:47
@bog-walk bog-walk merged commit 526b2b8 into main Jan 17, 2024
5 checks passed
@bog-walk bog-walk deleted the bog-walk/fix-json-nullable branch January 17, 2024 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants