mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
DDC-707: Discriminator column cannot be used in the query builder #874
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @doctrinebot on GitHub (Jul 21, 2010).
Jira issue originally created by user gedrox:
When having entities
The DQL "SELECT a FROM A a ORDER BY a.discr" cannot be run because of error "Class A has no field or association named discr".
This would be very useful when having to read both - B and C data using one query, but in particular order.
@doctrinebot commented on GitHub (Jul 21, 2010):
Comment created by gedrox:
Attached fast workaround for this issue
@doctrinebot commented on GitHub (Jul 21, 2010):
Comment created by romanb:
Duplicate of http://www.doctrine-project.org/jira/browse/DDC-482
Discriminator columns are not part of the object model and will thus not be available in DQL.
@doctrinebot commented on GitHub (Jul 21, 2010):
Issue was closed with resolution "Duplicate"
@doctrinebot commented on GitHub (Jul 21, 2010):
Comment created by gedrox:
If I redefine the "discr" as the column of the base class (and setting the default values in classes B and C for it) there are 2 places where exception is raised in Doctrine. Works after commenting them out.
Maybe there is some elegant solution for this problem without changing Doctrine?
@doctrinebot commented on GitHub (Jul 21, 2010):
Comment created by @beberlei:
Yes the elegant solution is described in DDC-482, its not yet implemented though.
@doctrinebot commented on GitHub (May 11, 2012):
Comment created by robmasters:
I see this was marked as duplicating a resolved thread, but I've just come across what I think is the same problem. Doctrine 2.1 isn't checking the discriminator column name when using the query builder (or in my case, a findBy method) - it only checks the columnNames and associationMappings arrays. See the following stackoverflow post for more information:
http://stackoverflow.com/questions/10550926/doctrine2-1-finding-by-discriminatorcolumn-results-in-unknown-field-exception
Thanks
@doctrinebot commented on GitHub (Dec 13, 2015):
Imported 1 attachments from Jira into https://gist.github.com/a7d6d5f84741cc4f012b
@jarrettj commented on GitHub (Aug 29, 2017):
Hi,
Good day.
Is there any documentation on how to use it in the findBy method? I've tried using the colon notation with no success. Maybe it is a zend framework 2 specific issue?
I’m trying to do a:
When I step through the code, it dies at Doctrine\ORM\Configuration line 195:
There are no values set in $this->_attributes['entityNamespaces'].
Thanks.
JJ
@Ocramius commented on GitHub (Aug 29, 2017):
You can't: you will need DQL and the
INSTANCEOFoperator.On 29 Aug 2017 10:02 AM, "jarrett jordaan" notifications@github.com wrote:
@jarrettj commented on GitHub (Aug 29, 2017):
Thanks @Ocramius.
Is this specific to zf2 though? Googling around seems it works for symphony.
@Ocramius commented on GitHub (Aug 29, 2017):
No, it is generally about D2. Also, this is the D2 repo: zf/sf specifics
are irrelevant.
On 29 Aug 2017 10:26 AM, "jarrett jordaan" notifications@github.com wrote:
@jarrettj commented on GitHub (Aug 29, 2017):
Awesome, thanks again for the speedy help @Ocramius! 👍