[DBAL-477] Just doublequote all schema names and field names in PostgreSQL sql command generation, and the same for MySQL Created: 28/Mar/13 Updated: 28/Mar/13 |
|
| Status: | Open |
| Project: | Doctrine DBAL |
| Component/s: | Platforms, Schema Managers |
| Affects Version/s: | 2.3.2 |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Improvement | Priority: | Major |
| Reporter: | jos de witte | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | mysql, postgresql | ||
| Environment: |
Any PostgreSQL environment |
||
| Description |
|
Generation of any SQL command to the database (From entities or migration versions) does not quote all the reserved keywords (For example a fieldname `right`. Simple fix that always works: double-quote dbname, schemaname and fieldname e.g "dbsecurity"."userschema"."users" or "tblusers" MySQL : use the ` sign. e.g `security`.`users` or `tblusers` (No support for schemas since I last checked some time ago) |
[DBAL-442] Break the query building with multiple from parts Created: 10/Feb/13 Updated: 22/Apr/13 Resolved: 22/Apr/13 |
|
| Status: | Resolved |
| Project: | Doctrine DBAL |
| Component/s: | None |
| Affects Version/s: | 2.3.2 |
| Fix Version/s: | 2.4 |
| Security Level: | All |
| Type: | Bug | Priority: | Major |
| Reporter: | Denis Vasilev | Assignee: | Benjamin Eberlei |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | mysql | ||
| Description |
|
For example:
$queryBuilder
->select('DISTINCT c.id')
->from('Campaigns', 'c')
->leftJoin('c', 'CampaignOperations', 'od', 'od.campaignId = c.id AND od.operation = :operation')
->from('BannerGroups', 'bg')
->innerJoin('bg', 'BannerGroupStrategies', 'bgs', 'bgs.groupId = bg.id AND bgs.advSystem = :system')
->where('bg.campaignId = c.id');
Builded the query: SELECT DISTINCT c.id FROM Campaigns s LEFT JOIN CampaignOperations od ON (od.campaignId = c.id AND od.operation = :operation) INNER JOIN BannerGroupStrategies bgs ON (bgs.groupId = bg.id AND bgs.advSystem = :system), BannerGroups bg WHERE (bg.campaignId = c.id) If this query execute on mysql, we get error: Expected result: SELECT DISTINCT c.id FROM Campaigns s LEFT JOIN CampaignOperations od ON (od.campaignId = c.id AND od.operation = :operation), BannerGroups bg INNER JOIN BannerGroupStrategies bgs ON (bgs.groupId = bg.id AND bgs.advSystem = :system) WHERE (bg.campaignId = c.id) Regression after patch https://github.com/doctrine/dbal/pull/175 |
| Comments |
| Comment by Denis Vasilev [ 10/Feb/13 ] |
| Comment by Fabio B. Silva [ 22/Apr/13 ] |
|
Fixed by : https://github.com/doctrine/dbal/commit/99574240f332a814ec193b6e7a88abb6a457f061 |
[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] != '=')) {
|