Ticket #1246 (closed defect: fixed)

Opened 5 months ago

Last modified 3 months ago

Exception when using using DQL to query a relationship to a reserved word in MySQL

Reported by: Jamon Owned by: jwage
Priority: major Milestone:
Component: Attributes Version: 2.0-DEV
Keywords: Cc:
Has Test: no Status: Pending Core Response
Has Patch: yes

Description

When you have a relationship to a table that is a mysql reserved word, and using the Doctrine::ATTR_QUOTE_IDENTIFIER option, it is possible to use the relationship through lazy loading, but attempting to query it using DQL will result in an exception: Doctrine_Query_Exception: Unknown table alias c in /home/jamon/a1ive/include/Doctrine/Query/Abstract.php on line 905

Call Stack:
    0.0003     124288   1. {main}() /home/jamon/a1ive/test.php:0
    0.0628    3626760   2. Doctrine_Query_Abstract->execute() /home/jamon/a1ive/test.php:26
    0.0628    3628328   3. Doctrine_Query_Abstract->_execute() /home/jamon/a1ive/include/Doctrine/Query/Abstract.php:993
    0.0639    3727864   4. Doctrine_Query->getSqlQuery() /home/jamon/a1ive/include/Doctrine/Query/Abstract.php:935
    0.1071    6117472   5. Doctrine_Query->_buildSqlFromPart() /home/jamon/a1ive/include/Doctrine/Query.php:1147
    0.1071    6117472   6. Doctrine_Query_Abstract->getComponentAlias() /home/jamon/a1ive/include/Doctrine/Query.php:1062

(See http://www.phpdoctrine.org/forum/viewtopic.php?f=2&t=46&start=0&st=0&sk=t&sd=a for additional detail)

The problem is that in Doctrine/Query.php, an attempt is made to remove the quoting added by ATTR_QUOTE_IDENTIFIER, but this only removes double-quotes, and not backticks like used in MySQL. The fix appears to just be adding the backtick character to the list of characters in the trim statement.

I've attached a patch for revision 4685.

Attachments

fix.patch (0.5 KB) - added by Jamon 5 months ago.
patch file

Change History

Changed 5 months ago by Jamon

patch file

Changed 5 months ago by guilhermeblanco

  • status changed from new to closed
  • resolution set to fixed

(In [4686]) Fixed #1246 and fixed #1247. The issue is the same, patch applied! Thanks for report and for the patch.

Changed 3 months ago by anonymous

  • milestone New deleted

Milestone New deleted

Note: See TracTickets for help on using tickets.