Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* updated documentation to remove the parenthesis around the return value from the insert query to reinforce the idea of only one value being returned

Signed-off-by:Nathan Erwin <nathan.d.erwin@gmail.com>
  • Loading branch information
nderwin authored and gsmet committed Oct 6, 2020
1 parent 60000f7 commit f456512
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions docs/src/main/asciidoc/reactive-sql-clients.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ The same logic applies when saving a `Fruit`:
.src/main/java/org/acme/vertx/Fruit.java
----
public Uni<Long> save(PgPool client) {
return client.preparedQuery("INSERT INTO fruits (name) VALUES ($1) RETURNING (id)").execute(Tuple.of(name))
return client.preparedQuery("INSERT INTO fruits (name) VALUES ($1) RETURNING id").execute(Tuple.of(name))
.onItem().transform(pgRowSet -> pgRowSet.iterator().next().getLong("id"));
}
----
Expand Down Expand Up @@ -502,9 +502,9 @@ The following snippet shows how to run 2 insertions in the same transaction:
----
public static Uni<Void> insertTwoFruits(PgPool client, Fruit fruit1, Fruit fruit2) {
return SqlClientHelper.inTransactionUni(client, tx -> {
Uni<RowSet<Row>> insertOne = tx.preparedQuery("INSERT INTO fruits (name) VALUES ($1) RETURNING (id)")
Uni<RowSet<Row>> insertOne = tx.preparedQuery("INSERT INTO fruits (name) VALUES ($1) RETURNING id")
.execute(Tuple.of(fruit1.name));
Uni<RowSet<Row>> insertTwo = tx.preparedQuery("INSERT INTO fruits (name) VALUES ($1) RETURNING (id)")
Uni<RowSet<Row>> insertTwo = tx.preparedQuery("INSERT INTO fruits (name) VALUES ($1) RETURNING id")
.execute(Tuple.of(fruit2.name));
return insertOne.and(insertTwo)
Expand All @@ -522,7 +522,7 @@ You can also create dependent actions as follows:
----
return SqlClientHelper.inTransactionUni(client, tx -> tx
.preparedQuery("INSERT INTO person (firstname,lastname) VALUES ($1,$2) RETURNING (id)")
.preparedQuery("INSERT INTO person (firstname,lastname) VALUES ($1,$2) RETURNING id")
.execute(Tuple.of(person.getFirstName(), person.getLastName()))
.onItem().transformToUni(id -> tx.preparedQuery("INSERT INTO addr (person_id,addrline1) VALUES ($1,$2)")
Expand Down

0 comments on commit f456512

Please sign in to comment.