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

Incorrect "filled SQL" if comment in SQL contains "?" #65

Closed
sylvainlaurent opened this issue Jan 29, 2018 · 3 comments
Closed

Incorrect "filled SQL" if comment in SQL contains "?" #65

sylvainlaurent opened this issue Jan 29, 2018 · 3 comments
Labels
Milestone

Comments

@sylvainlaurent
Copy link
Owner

with Hibernate SQL comments enabled, the SQL statement starts with a comment that contains the JPA query, which may contains bound variables like ?1, ?2...
In such a case v0.8.2 tries to replace the ? in the SQL comment which is incorrect.

@sylvainlaurent
Copy link
Owner Author

it would require to use ANTLR to correctly parse SQL statement...�

@samyBadjoudj
Copy link
Contributor

samyBadjoudj commented Jan 5, 2020

the pull request #71 should take care of that. Without implementing a full parser with tokens.
It removes comments before letting the fillParameters method doing the job.

NB:
The filled sql, will not have the comment but RDBMSes hints (Mysql and Oracle) will be kept in the filledSql.
https://docs.oracle.com/cd/E11882_01/server.112/e41573/hintsref.htm#PFGRF005

But the code will manage even inner comments in the sql statements like those
PreparedStatement stmnt = con.prepareStatement(" UPDATE /*blah = ? */ TBL SET col1 = ? ")

Hope it helped

@sylvainlaurent
Copy link
Owner Author

fixed by merging PR #72

@sylvainlaurent sylvainlaurent added this to the 0.9.1 milestone Jan 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants