Skip to content

Unable to insert a new entity in a table containing name "returning" #377

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

Closed
aryadnasauchyts opened this issue Jan 6, 2021 · 4 comments · Fixed by #384
Closed

Unable to insert a new entity in a table containing name "returning" #377

aryadnasauchyts opened this issue Jan 6, 2021 · 4 comments · Fixed by #384
Labels
status: ideal-for-contribution An issue that a contributor can help us with type: bug A general bug
Milestone

Comments

@aryadnasauchyts
Copy link

Bug Report

Unable to insert a new entity in a table containing name "returning". The following error observed:
Statement already includes RETURNING clause

Versions

  • Driver: 0.8.6
  • Database: Postgres 11.6
  • Java: 11
  • OS: Mac OS Big Sur

Current Behavior

After debugging the guts of the driver I have found that GeneratedValuesUtils#hasReturningClause pattern matcher incorrectly identifies sql query

INSERT INTO returning_user (id, name, user_details) VALUES ($1, $2, $3)

like having returning clause even though it does not have it.

Looks like RETURNING clause matcher needs to be adjusted for such cases.

Stack trace
reactor.core.Exceptions$ErrorCallbackNotImplemented: java.lang.IllegalStateException: Statement already includes RETURNING clause
Caused by: java.lang.IllegalStateException: Statement already includes RETURNING clause
	at io.r2dbc.postgresql.ExtendedQueryPostgresqlStatement.returnGeneratedValues(ExtendedQueryPostgresqlStatement.java:129)

Expected behavior/code

It's possible to insert records in a table having "returning" in its name.

@aryadnasauchyts aryadnasauchyts added the status: waiting-for-triage An issue we've not yet triaged label Jan 6, 2021
@mp911de mp911de added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Jan 6, 2021
@mp911de
Copy link
Collaborator

mp911de commented Jan 14, 2021

Care to submit a pull request to address the issue?

@mp911de mp911de added the status: ideal-for-contribution An issue that a contributor can help us with label Jan 14, 2021
@govi20
Copy link
Contributor

govi20 commented Jan 29, 2021

Hi, @mp911de would it be fine, If I work on it?

@mp911de
Copy link
Collaborator

mp911de commented Jan 29, 2021

Sure. Contributions are always welcome.

@govi20
Copy link
Contributor

govi20 commented Jan 30, 2021

Thanks.

One thing I observed, we are using a regex in GeneratedValuesUtils.isSupportedCommand which may cause an issue:

  • if an unsupported command's table name contains insert/delete/delete words
  • if nested query performs insert/update/delete operation. But the outer query performs an unsupported operation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: ideal-for-contribution An issue that a contributor can help us with type: bug A general bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants