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-263 Null arg parameter in exec() throws if logger enabled #1973

Merged
merged 1 commit into from
Jan 23, 2024

Commits on Jan 22, 2024

  1. fix: EXPOSED-263 Null arg parameter in exec() throws if logger enabled

    The type for exec() parameterized arguments is declared as args: Iterable<Pair<IColumnType, Any?>>,
    so passing null as the second element correctly sets the statement parameter to SQL NULL.
    But if a logger is enabled, this exception is thrown:
    java.lang.IllegalStateException: NULL in non-nullable column.
    This is because all IColumnType default to being not nullable and fail the check
    in `ColumnType.valueToString()` when attempting to parse the 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 in `exec()` has no knowledge of this because it is meant to accept
    plain SQL using an anonymous Statement object.
    This fix sets the nullable parameter of any column type in args to true so that
    no exception will be thrown when the logger invokes valueToString().
    bog-walk committed Jan 22, 2024
    Configuration menu
    Copy the full SHA
    83c6c22 View commit details
    Browse the repository at this point in the history