Ticket #849 (closed defect: fixed)

Opened 16 months ago

Last modified 16 months ago

Doctrine_Hydrator error while populate records if tablename's first character is underscore

Reported by: purnama Owned by: zYne-
Priority: major Milestone: 0.10.4
Component: Query/Hydration Version: 0.10.0
Severity: Keywords: underscore
Cc: Has Test:
Status: Has Patch:

Description

I used '_portal_' prefix for my MySQL tables, and have Error while fetch records from tables.

this is the Doctrine_Query string :

SELECT 
  _.gid AS ___gid, 
  _.name AS ___name, 
  _.email AS ___email, 
  _.comment AS ___comment, 
  _.tstamp AS ___tstamp, 
  _.status AS ___status 
FROM 
 _portal_guestbook _ 
WHERE 
 _.status = 1

below the snapshot from the exception:

Call to a member function getFieldName() on a non-object in /var/www/portal/lib/doctrine/Doctrine/Hydrator.php on line 293

call stack:
...
7	0.2288	12997676	Doctrine_Hydrator->hydrateResultSet( )	../Abstract.php:953
8	0.2319	13185000	Doctrine_Hydrator->_gatherRowData( )	../Hydrator.php:119

in my search,the error starting in Doctrine_Hydrator line 287 :

$e = explode('__', $key);

while tablename's first character is underscore '_' and Doctrine_Query use it as table alias; it makes ambiguation. i try to use table alias $record->getTable()->createQuery('p'); but not work.

Change History

Changed 16 months ago by purnama

  • keywords underscore added; undescore removed

after some research, i suggest to replace '__' chars as tablealias-field divider with another chars such as '_dc_dc_' or whatever.

the implementation :

add this line in Doctrine_Query_Abstract class :

const FIELD_DIVIDER = '_dc_dc_';

change __ chars with Doctrine_Query::FIELD_DIVIDER in these classes :

Doctrine_Query line : 516,521,573,653,892,961,1337,1344,1347

Doctrine_Hydrator line : 287, 289

Doctrine_RawSql line : 201,205,218

CMIIW.

Changed 16 months ago by jwage

I added a test case for this scenario in r4039 and r4040

Changed 16 months ago by jwage

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

(In [4098]) fixes #849

Note: See TracTickets for help on using tickets.