vert-x3 / vertx-mysql-postgresql-client

This client is deprecated - use instead
https://github.com/eclipse-vertx/vertx-sql-client
Apache License 2.0
117 stars 59 forks source link

UpdateResult getKeys method is retuning empty #167

Open jgutierreznab opened 4 years ago

jgutierreznab commented 4 years ago

Hi guys, first, thank you so much for this amazing framework.

updateWithParams UpdateResult getKeys methods is returning an empty array, not sure if this is important => https://github.com/vert-x3/vertx-jdbc-client/issues/113 from 2017

I'm currently under <vertx.version>3.8.3</vertx.version>

     <dependency>
     <groupId>io.vertx</groupId>
     <artifactId>vertx-mysql-postgresql-client</artifactId>
    </dependency>

connection type is SQLConnection

String execQuery = "INSERT INTO users(username, email, password) VALUES (?, ?, ?) RETURNING (id)";

the query is valid and is inserting properly in the Pg table

connection.updateWithParams(execQuery, queryParams, h -> {
  if (h.succeeded()) {

     UpdateResult result = h.result();
     System.out.println("result.getUpdated() => " + result.getKeys());

        someFuture.complete(result.getKeys().getValue(0));
    connection.close();
 }
})

also tried with .setOptions(new SQLOptions().setAutoGeneratedKeys(true)) with no luck

connection.setOptions(new SQLOptions().setAutoGeneratedKeys(true)).updateWithParams(execQuery, queryParams, h -> {

thank you very much for the amazing work

garrydias commented 4 years ago

Same problem here. setAutoGeneratedKeys(true) is unsupported operation and raises an exception. The version i'm using is 3.8.5. Is there any workarounds?

jgutierreznab commented 4 years ago

@garrydias probably using the ReactiveJDBC will solve it