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

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

问题描述

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

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

我在使用 Doctrine 2.3 中引入的任意连接语法在作为层次结构根的实体类上构建 DQL 查询时遇到问题.

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 - 没有继承

B1 - 抽象,层次结构的根,鉴别器列被命名为类型"

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('EntityA', 'a')
    ->leftJoin('EntityB1', 'b', DoctrineORMQueryExprJoin::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')

问题在于 where 使得 left join 无用.

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

有没有办法强制将鉴别器列上的条件放在连接中?至少那会让它...

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天全站免登陆