按别名原则分组。错误还是功能?
我想强调之前讨论过的一个问题 这里,或者似乎已经解决了很长时间之前,但问题仍然存在。
实际上,不可能在 group by
子句中使用别名。 与提到的主题一样,我也收到“错误:'...'不指向类”。 但是,order by
子句中的别名可以完美地工作。
例如,此 DQL 请求有效:
SELECT j.id, DATE(j.start_at) AS date
FROM jobs j
ORDER BY date
但这无效(而它在 SQL 中有效):
SELECT COUNT(j.id), DATE(j.start_at) AS date
FROM jobs j
GROUP BY date
另外,我无法 GROUP BY DATE(j.start_at)
。
(我在 MySQL 数据库上尝试过,使用 Symfony PR9 提供的版本,以及 github.com/doctrine/doctrine2 中的最后一个版本 - 04/04/11)
因此,我想知道这是否是一个错误Doctrine2 的内容,或者是否需要?在第一种情况下,有人知道如何纠正它吗?
I'd like to highlight an issue that was previously discussed here, or seems to have been resolved a long time ago, but the problem still persists.
Actually, it's impossible to use an alias in a group by
clause.
Like the mentioned topic, I also get an "Error: '...' does not point to a Class".
However, aliases, in the order by
clause, work perfectly.
For instance, this DQL request works:
SELECT j.id, DATE(j.start_at) AS date
FROM jobs j
ORDER BY date
But this doesn't (whereas it works in SQL):
SELECT COUNT(j.id), DATE(j.start_at) AS date
FROM jobs j
GROUP BY date
Also, I can't GROUP BY DATE(j.start_at)
.
(I tryed it on a MySQL database, with the version delivered with Symfony PR9, and also the last version in github.com/doctrine/doctrine2 - 04/04/11)
Thus, I'd like to know if this is a bug of Doctrine2, or if it is wanted? In the first case, does somebody know how to correct it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论