-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
SQLParserUtils does not support quotes in comments when combined with quoted parameters #3742
Labels
Comments
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Bug Report
Summary
SqlParserUtils does not properly replace named parameters when there is an SQL comment with a quote in it, when the query also has "hardcoded" properties.
Pull request #3743 contains a regression test for this problem.
How to reproduce
Execute a query using an initialized Doctrine\DBAL\Connection:
Expected behaviour
I can call
fetchAll
on$statement
and get an array from BAR where SOME_VALUE is 'hardcoded'.Current behaviour
An exception is thrown:
Context
As long as the query is valid, it should not matter what I put in the comments.
The produced error does not allude to the fact that a comment is at fault here.
For all intents and purposes the query, amount of parameters and the given types seem to be correct and only by removing the comment (or specifically the quote) will you get it to work.
The problem becomes even less visible when there is another comment with two quotes does not seem to produce the error. As long as there are an even amount of quotes (or 0) it will work as expected.
This problem can easily be triggerd by writing a comment like:
To prevent the programmer from hunting down this problem, either the parser should ignore comments, or throw an exception when this problem occurs.
Workaround
Our my project I added an assertion to (hopefully) help prevent my teammates from falling into the same trap:
The text was updated successfully, but these errors were encountered: