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

Open
opened 2026-01-22 12:50:57 +01:00 by admin · 0 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:50:57 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#802