-
Notifications
You must be signed in to change notification settings - Fork 269
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
Fix #715 by removing subqueries without using regex #723
Conversation
@mnewnham as mentioned in #718 (comment), it would be nice if you could take a look at this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems all good. I was unable to break it with
- Subselects within the 'select from'
- Subselects within the 'where'
- Unmatched parentheses inside strings within the statements
Great, thanks for testing. |
- Refactor the driver matching code to make it easier to add. - Add support for PDO/mysql driver
Following discussion in #718, using regex to identify and remove sub-queries in _adodb_getcount() is flawed and can't be fixed. This led to implementing a hack using _ADODB_COUNT "keyword" to (see #88 41839f5). This replaces the regex parsing by a simple loop on the query string, removing everything between the SELECT and the FROM clause, ignoring whatever is between parentheses (i.e. subqueries). The _ADODB_COUNT logic is therefore obsolete Fixes #715
1189f54
to
98b5579
Compare
While I haven't tested this yet, I disagree with removing the _ADODB_COUNT functionally to override the built-in removal of sub-selects. Without a full SQL parser (which will never happen of course), I fail to see how we can handle every possible SQL query that anyone could ever possibly write across all drivers. It seems like pretty cheap insurance to keep around, and even a potential optimization for queries that may be executed often too. Based on a very quick read of the code, it would appear that the following real-world query (where _ADODB_COUNT is currently used) could possibly fail:
|
@Mike-Benoit given the above SQL statement (with or without the |
Alternative to #718