eventuate-foundation / eventuate-common

Other
12 stars 20 forks source link

EventuateSpringReactiveJdbcStatementExecutor doesn't handle null parameters correctly #134

Open cer opened 1 year ago

cer commented 1 year ago

See https://github.com/eventuate-tram/eventuate-tram-sagas/issues/97

The problem

First, reformatInsertParameters() - for Postgres replaces placeholders for null parameters with NULL:

INSERT INTO eventuate.saga_instance(saga_type, saga_id, state_name, last_request_id, saga_data_type, saga_data_json, end_state, compensating, failed) VALUES(:param1, :param2, :param3, NULL, :param5, :param6, :param7, :param8, :param9)

And then bindParameters() does this when the value is null:

        if (!(sqlDialect instanceof PostgresDialect)) {
          genericExecuteSpec = genericExecuteSpec.bindNull(i, Object.class);
        } else {
          // ??
          // skippedParameters++;
        }

This happens when i == 3, which corresponds to the 4th placeholder = :param5.

Fix: