[DBAL-398] Native query does not allow mysql assignment operator := Created: 18/Dec/12 Updated: 03/Jan/13 Resolved: 22/Dec/12 |
|
| Status: | Resolved |
| Project: | Doctrine DBAL |
| Component/s: | None |
| Affects Version/s: | 2.3 |
| Fix Version/s: | 2.3.2 |
| Security Level: | All |
| Type: | Bug | Priority: | Major |
| Reporter: | David Ward | Assignee: | Benjamin Eberlei |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | mysql | ||
| Environment: |
Using Doctrine within Symfony 2.1.x |
||
| Attachments: |
|
| Description |
|
When trying to use the mysql assignment operator in a native query one gets an exception as SqlParserUtils does not qualify the character after the : as being part of a valid parameter value. Undefined index: in vendor/doctrine/dbal/lib/Doctrine/DBAL/SQLParserUtils.php line 156 (uncaught exception) A simple example is Or a more complicated example is (similar to actual use): $rsm = new ResultSetMapping(); I have attached quick-fix patch, but it looks like the getPlaceholderPositions method is wanting something better overall (due to the TODO comment in it). |
| Comments |
| Comment by David Ward [ 18/Dec/12 ] |
|
A pull request has been added at https://github.com/doctrine/dbal/pull/237 which also has tests added. |
| Comment by Bryson Armstrong [ 03/Jan/13 ] |
|
I ran into this error and the fix caused other queries to have errors. I fixed it by changing line 57 in vendor/doctrine/dbal/lib/Doctrine/DBAL/SQLParserUtils.php:
if ($statement[$i] == $match && !$inLiteral && (!$isPositional && $statement[$i+1] != '=')) {
to:
if ($statement[$i] == $match && !$inLiteral && ($isPositional || $statement[$i+1] != '=')) {
|