Ticket #1257 (closed defect: fixed)

Opened 12 months ago

Last modified 10 months ago

Mssql: Unknown table alias [r] when using leftJoin

Reported by: pr0f3t Owned by: romanb
Priority: minor Milestone:
Component: Query/Hydration Version: 1.0.0
Severity: Keywords: Mssql
Cc: Has Test: yes
Status: Pending Core Response Has Patch: no

Description

The query:

Doctrine_Query::create()->select('u.fname, u.id')->from("User u")->leftJoin('u.Role r')->addSelect('r.longname, r.description')->execute()

will trigger the error:

Doctrine_Query_Exception: Unknown table alias [r] in ...DoctrineDoctrineQueryAbstract.php on line 907

It seems the alias is stored as r (No square brackets) but the look-up uses [r], which fails.

Change History

Changed 11 months ago by jwage

  • version changed from 0.11 to 1.0
  • milestone changed from Unknown to 1.0.0-RC1

Changed 11 months ago by jwage

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

I added coverage for your query you are trying in r4748. As you can see, everything passes. I am not able to produce the issue. We will need some more information, until then I am marking this ticket as invalid.

Changed 11 months ago by pr0f3t

  • status changed from closed to reopened
  • resolution invalid deleted

More information: This happens when I have

$connection->setAttribute(Doctrine::ATTR_QUOTE_IDENTIFIER, true);

The issue seems to be in Doctrine_Query_Abstract::getComponentAlias(...) - the identifier is seen as [r], while in the _tableAliasMap, it's stored simply as r.

Changed 11 months ago by desfrenes

I get the exact same issue under the same circumstances:

$user = Doctrine_Query::create()
		->from('User u')
		->leftJoin('u.Roles r')
		->where('u.nickname = ? and u.password = ?',array($username, $pass))
		->fetchOne();

I also have Doctrine::ATTR_QUOTE_IDENTIFIER enabled.

Changed 11 months ago by desfrenes

Sorry, I forgot the error message (only the delimiters change) : Unknown table alias r

Changed 11 months ago by desfrenes

Delimiters don't show here, it's the normal mysql delimiter

Unknown table alias `r`

Changed 10 months ago by jwage

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

(In [4809]) fixes #1257

Changed 10 months ago by anonymous

  • milestone New deleted

Milestone New deleted

Note: See TracTickets for help on using tickets.