Ticket #1381 (closed defect: worksforme)

Opened 10 months ago

Last modified 10 months ago

Calculated columns don't live well with Identity Map

Reported by: francois Owned by: jwage
Priority: minor Milestone:
Component: Attributes Version: 0.11.0
Severity: Keywords:
Cc: Has Test: no
Status: Pending Core Response Has Patch: no

Description

When adding custom columns to the SELECT part of a DQL statement, Doctrine makes these columns available as property of the object they are related to.

Here is a DQL example:

//Article has many Comments
SELECT c.*, a.title ArticleTitle FROM Comment c INNER JOIN c.Article a LIMIT 1
// will hydrate a Comment object looking like
-
  id: 123
  body: I completely agree
  article_id: 456
  Article:
    id: ~
    title: ~
    body: ~
    ArticleTitle: Hello, world

So that works, since I can retrieve my custom ArticleTitle column by calling $comment['Article']['ArticleTitle'].

But if I already queried this Article or this Comment objects, IdentityMap? enters the dance, and the result of the query is:

-
  id: 123
  body: I completely agree
  article_id: 456
  Article:
    id: 456
    title: Hello, World
    body: Lorem Ipsum...

The bad news is that I can no longer access my custom column by its alias: $comment['Article']['ArticleTitle'] doesn't work.

This probably means that IdentityMap? should be deactivated on queries where custom columns are added. I don't know if there is a way to do that, all I could find was to clear the identity map prior to executing the query:

Doctrine::getTable('Article')->clear();
Doctrine::getTable('Comment')->clear();

This is less than ideal, and should be handled by Doctrine rather than by the user...

Change History

Changed 10 months ago by jwage

  • milestone changed from Unknown to 1.0.0-RC2

Changed 10 months ago by guilhermeblanco

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

Hi francois,

I'll have to mark this ticket as "works for me". I'm unable to reproduce the issue on svn branch 1.0.0.

I added coverage to all possibilities I've imagined, without success. Coverage to this ticket was added in r4870. Please provide a failing test case, otherwise I cannot address the issue.

Regards,

Changed 10 months ago by anonymous

  • milestone New deleted

Milestone New deleted

Note: See TracTickets for help on using tickets.