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
QueryBuilder: Add comments to SQL queries #4168
Comments
Are you aware of doctrine/DoctrineBundle#954 ? Do you think part of it should be backported to the DBAL? |
@greg0ire Thank you, I was not aware of that. doctrine:
dbal:
profiling_collect_backtrace: true This option enables that feature and it is very helpful. However, option to add a comment to a SQL query would allow us to add not only from where the query was executed, it would also allow us to add a note about some additional details, like a reason why it was invoked. Another reason for the comment is to see from where the query come in the slow log on a production database server, where we do not have the option to show a backtrace, only the query itself. |
@jkufner this can be probably achieved currently with a combination of setHint and by defining a custom SqlWalker.
In your Query Builder
The resulting query would be similar to
PROS CONS Event though I think that your proposal would be of great help, especially with the slow log on a production database server. |
Feature Request
Summary
I would like to add a small comment to every SQL query that says in which method is the query located.
Example:
Such code would generate the following query:
Then, in the list of executed queries, we can see which repository executed which query.
It may be useful to have two methods, e.g., commentHeader and commentFooter, that add comments to the begin and the end of the query, respectively.
I used this approach with other query builder and I found it very useful when debugging. It really helps to locate relevant queries.
The text was updated successfully, but these errors were encountered: