vertx-jdbc-client3.5.2 postgresql : sql 更新原因 "A result was returned when none was expected"

vertx-jdbc-client3.5.2 postgresql : sql update cause "A result was returned when none was expected"

在 vertx-jdbc-client 3.5.0 中,sql "DELETE FROM user;INSERT INTO user... " ok.After 更新到 vertx-jdbc-cient 3.5 .2,sql 失败并出现错误: io.vertx.core.VertxException: org.postgresql.util.PSQLException: A result was returned when none was expected。通过调试,我发现SQL自动更改为DELETE FROM user RETURNING *;INSERT INTO user ...,然后RETURNING *导致更新错误。

我找到了 cause:in vert-jdbc-client 3.5.0。

class JDBCConnectionImpl implements SQLConnection {
...
  private SQLOptions options;

}

在vert-jdbc-client 3.5.2:

class JDBCConnectionImpl implements SQLConnection {
    ...
    private SQLOptions options = new SQLOptions().setAutoGeneratedKeys(true);
}

然后是

public class Parser {
...
  private static boolean addReturning(StringBuilder nativeSql, SqlCommandType currentCommandType,
      String[] returningColumnNames, boolean isReturningPresent) throws SQLException {
    if (isReturningPresent || returningColumnNames.length == 0) {
      return false;
    }
    if (currentCommandType != SqlCommandType.INSERT
        && currentCommandType != SqlCommandType.UPDATE
        && currentCommandType != SqlCommandType.DELETE) {
      return false;
    }

    nativeSql.append("\nRETURNING ");
...
}

我应该修改SQL代码还是设置JDBC客户端?谁能给我一个建议?

我只是发现这不是问题,因为当我编码 SQLConnection sqlConnection = ...; sqlConnection.setOptions(null); 时,旧的 sql 更新是 ok.So 我认为这是一个变化。