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

Brackets used in RETURNING keyword can cause issues #541

Closed
pjverity opened this issue Apr 26, 2020 · 2 comments
Closed

Brackets used in RETURNING keyword can cause issues #541

pjverity opened this issue Apr 26, 2020 · 2 comments

Comments

@pjverity
Copy link

pjverity commented Apr 26, 2020

return client.preparedQuery("INSERT INTO fruits (name) VALUES ($1) RETURNING (id)", Tuple.of(name))

The PostgreSQL documentation for use of the RETURNING clause does not indicate that brackets should surround column names in the clause. This only appears to work Ok when returning a single value as in this example. When RETURNING multiple columns it causes all values to be returned as a single bracketed string.

For example, RETURNING (id, name) would return a single column named row with the string value "(1, Kiwi)", causing row.getLong("id") or row.getString("name") to return null.

I would suggest removing the brackets at per PostgreSQL documentation to avoid developers making the mistake of bracketing multiple return values and falling in to this trap.

The Getting Started guide should also be updated if this change is made.

gsmet pushed a commit to gsmet/quarkus that referenced this issue Oct 6, 2020
* 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>
gsmet pushed a commit to gsmet/quarkus that referenced this issue Oct 6, 2020
* 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>
@nderwin
Copy link
Contributor

nderwin commented Oct 6, 2020

@gsmet This one can be closed now since the PRs are merged. Maybe I didn't link them correctly so that it was automatically closed.

@gsmet gsmet closed this as completed Oct 6, 2020
@gsmet
Copy link
Member

gsmet commented Oct 6, 2020

Closing, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants