DDC-652: DQL with association property doesn't work (Undefined index in SqlWalker.php) #804

Closed
opened 2026-01-22 12:51:00 +01:00 by admin · 5 comments
Owner

Originally created by @doctrinebot on GitHub (Jun 24, 2010).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user jakajancar:

In my model, Users can have many Campaigns, each of which can have many Ads:

class User extends Entity
{
    /****
     * @OneToMany(targetEntity="Campaign", mappedBy="user")
     */
    private $campaigns;

    [...]
}
class Campaign extends Entity
{
    /****
     * @ManyToOne(targetEntity="User", inversedBy="campaigns")
     * @JoinColumn(name="userId", nullable=true)
     */
    private $user;

    /****
     * @OneToMany(targetEntity="Ad", mappedBy="campaign")
     */
    private $ads;

    [...]
}
class Ad extends Entity
{
    /****
     * @ManyToOne(targetEntity="Campaign", inversedBy="ads")
     * @JoinColumn(name="campaignId")
     */
    protected $campaign;

    [...]
}

Some campaigns do not belong to any user (user is NULL).

When trying to find ads in such campaigns using DQL such as:

    SELECT a FROM Ad a WHERE e.campaign.user IS NULL

I get:

E_NOTICE (8): Undefined index: user (/home/jaka/sites/jaka.kubje.org/htdocs/celtra/mab/server/library/Doctrine/ORM/Query/SqlWalker.php:469)

I would expect a LEFT JOIN to be done and campaign.userId IS NULL to be checked in the WHERE condition.

Is this not supported, or am I doing something wrong?

Originally created by @doctrinebot on GitHub (Jun 24, 2010). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user jakajancar: In my model, Users can have many Campaigns, each of which can have many Ads: ``` class User extends Entity { /**** * @OneToMany(targetEntity="Campaign", mappedBy="user") */ private $campaigns; [...] } ``` ``` class Campaign extends Entity { /**** * @ManyToOne(targetEntity="User", inversedBy="campaigns") * @JoinColumn(name="userId", nullable=true) */ private $user; /**** * @OneToMany(targetEntity="Ad", mappedBy="campaign") */ private $ads; [...] } ``` ``` class Ad extends Entity { /**** * @ManyToOne(targetEntity="Campaign", inversedBy="ads") * @JoinColumn(name="campaignId") */ protected $campaign; [...] } ``` Some campaigns do not belong to any user (user is NULL). When trying to find ads in such campaigns using DQL such as: ``` SELECT a FROM Ad a WHERE e.campaign.user IS NULL ``` I get: ``` E_NOTICE (8): Undefined index: user (/home/jaka/sites/jaka.kubje.org/htdocs/celtra/mab/server/library/Doctrine/ORM/Query/SqlWalker.php:469) ``` I would expect a LEFT JOIN to be done and campaign.userId IS NULL to be checked in the WHERE condition. Is this not supported, or am I doing something wrong?
admin added the Bug label 2026-01-22 12:51:00 +01:00
admin closed this issue 2026-01-22 12:51:02 +01:00
Author
Owner

@doctrinebot commented on GitHub (Jun 27, 2010):

Comment created by @beberlei:

First: Is that a typo in your DQL? You write e.campaign.user instead of a.campaign.user.

Can you rewrite the query to:

SELECT a FROM Ad a INNER JOIN a.campaign c WHERE c.user IS NULL
@doctrinebot commented on GitHub (Jun 27, 2010): Comment created by @beberlei: First: Is that a typo in your DQL? You write e.campaign.user instead of a.campaign.user. Can you rewrite the query to: ``` SELECT a FROM Ad a INNER JOIN a.campaign c WHERE c.user IS NULL ```
Author
Owner

@doctrinebot commented on GitHub (Jul 5, 2010):

Comment created by jakajancar:

Hi Benjamin,

It's a typo in the bug report, yes, but otherwise it's correct.

The inner join works, but shouldn't my example work too? Or is it not supported at all?

Considering

e.campaign.user = 3

is supported, i'd really expect

e.campaign.user IS NULL

to be too.

@doctrinebot commented on GitHub (Jul 5, 2010): Comment created by jakajancar: Hi Benjamin, It's a typo in the bug report, yes, but otherwise it's correct. The inner join works, but shouldn't my example work too? Or is it not supported at all? Considering ``` e.campaign.user = 3 ``` is supported, i'd really expect ``` e.campaign.user IS NULL ``` to be too.
Author
Owner

@doctrinebot commented on GitHub (Jul 5, 2010):

Comment created by @beberlei:

No, support for multidot or deep path expressions as they are called will be dropped for Beta 4.

@doctrinebot commented on GitHub (Jul 5, 2010): Comment created by @beberlei: No, support for multidot or deep path expressions as they are called will be dropped for Beta 4.
Author
Owner

@doctrinebot commented on GitHub (Jul 5, 2010):

Issue was closed with resolution "Won't Fix"

@doctrinebot commented on GitHub (Jul 5, 2010): Issue was closed with resolution "Won't Fix"
Author
Owner

@doctrinebot commented on GitHub (Jul 5, 2010):

Comment created by jakajancar:

Ahh, I see. Huge loss :( Thanks for pointing it out.

@doctrinebot commented on GitHub (Jul 5, 2010): Comment created by jakajancar: Ahh, I see. Huge loss :( Thanks for pointing it out.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#804