fix: EXPOSED-263 Null arg parameter in exec() throws if logger enabled #1973
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.
The type for
exec()
parameterized arguments is declared asargs: Iterable<Pair<IColumnType, Any?>>
, so passingnull
as the second element correctly sets the statement parameter to SQL NULL.But if a logger is enabled, this exception is thrown instead:
This is because all
IColumnType
default to being not nullable and fail the check inColumnType.valueToString()
when attempting to parse the null parameter value.This exception can be avoided by always providing SQL NULL directly, via
Op.nullOp<T>()
.But given the type hints, the accepted parameter values should match what would be accepted by any other DSL statement.
Even if the column in the Exposed table object is declared as being
nullable()
, the column type inexec()
has no knowledge of this because it is meant to accept plain SQL using an anonymousStatement
object.This fix sets the nullable parameter of any column type in
args
totrue
so that no exception will be thrown when the logger invokesvalueToString()
.