Doctrine2:任意加入和单表继承 [英] Doctrine2: Arbitrary join and single table inheritance

查看:126
本文介绍了Doctrine2:任意加入和单表继承的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

注意:这是一个ORM限制在项目问题跟踪器上报告

Note: This is an ORM limitation reported on the project's issue tracker

我正在使用 Doctrine 2.3 中引入的任意连接语法来构建一个 查询的问题一个实体类是层次结构的根。

I'm facing an issue building a DQL query using the arbitrary join syntax introduced in Doctrine 2.3 on an entity class which is the root of a hierarchy.

给定这些类:


A - 无继承

A - no inheritance

B1 - 抽象,层次结构的根,discriminator列命名为类型

B1 - abstract, root of a hierarchy, discriminator column is named 'type'

我设置了一个这样的查询构建器:

I setup a query builder like this:

$qb->select('a.id AS idA, b.id AS idB')
    ->from('\Entity\A', 'a')
    ->leftJoin('\Entity\B1', 'b', \Doctrine\ORM\Query\Expr\Join::WITH, 'a.something=b.something');

SQL Doctrine生成的是这样的:

And the SQL Doctrine generates is something like this:

SELECT a.id, b.id FROM a LEFT JOIN b ON (a.something=b.something) WHERE b.type IN ('1', '2', '3')

问题在于,使左加入没有用的。

The problems is that the where makes the left join useless.

有没有办法强制将discriminator列上的条件放在连接中?至少这会使它...

Is there a way to force the condition on the discriminator column to be placed in the join? At least that would make it...

我应该填写错误报告吗?

Should I fill a bug report?

推荐答案

这个错误是在Doctrine 2.4中修复的。

This bug is fixed in Doctrine 2.4

https://github.com/doctrine/doctrine2/issues/2934

这篇关于Doctrine2:任意加入和单表继承的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆