-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
INSTANCE OF
support in Criteria API Expressions
#5908
Comments
@skornev |
It does not work.
|
I want to use |
Ah, I thought this was about DQL only (and the DQL expression builder), not about the criteria API, sorry. Re-opening and renaming issue. |
INSTANCE OF
support in Criteria API Expressions
+1 for an instanceOf() Expression in the Criteria API. |
Yes please! |
it would be awesome! |
👍 Yes please. |
+1 |
3 similar comments
+1 |
+1 |
+1 |
+1 Definitely! 👍 |
+1 (and nothing since june 2016 ???) |
Yep, nothing since then.
On 7 Mar 2017 3:47 a.m., "Thomas Véquaud" <[email protected]> wrote:
+1 (and nothing since june 2016 ???)
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#5908 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAJakI22Iz3iMJ8l89l47GUewz8OAC47ks5rjRmYgaJpZM4JCJiN>
.
|
So sad.... |
+1 |
The interested has been clearly shown already so stop +1 and do a PR if you're interested... |
Apologies -- my +1 was not intended to aggravate anyone. Some projects embrace +1 as a way to gauge interest in features in the absence of voting. |
@theofidry I made a brief research on this issue. "INSTANCE OF" expression is based on Entity annotations and QueryBuilder, which resolves expressions to DQL. But Criteria expressions resolved to raw SQL. As I understand, Criteria expression resolver (BAsicEntityPersister) should be rewritten to use QueryBuilder. That would be a huge PR and I doubt that it will pass CR by Doctrine team. |
@imunhatep thanks for looking into it. I guess then it's up to the core team to determine if this can be done in 3.x in which case it can be added to the 3.0 milestone or if this feature won't be implemented |
I were thinking a little bit on this problem and probably i was wrong. There is no need to rewite Context expression resolver to use QueryBuilder it would be overkill. A simplier approach would be just add a similar logic for resolving INSTANCE OF expression from QueryBuilder to Context expression resolver. Or to not duplicate business logic.. Move INSTANCE OF expression resolving logic to a separate handler. And add filtering for collections. It's still not an easy task.. But at least possible. |
Hey, two years have gone since the last post. Any news about this issue? I stumbled upon the same problem as described in doctrine/collections#113 and didn't find another smart solution: Cannot use the discriminator column directly ("Unrecognized field"), cannot use the specific properties of the subclasses ("Unrecognized field" as they are ManyToOne-relations which isn't supported by the Criteria), cannot use instanceOf, cannot hydrate the whole Collection to filter it (it can be very huge in my case as it is an activity log). How did others solve that? For now I avoid the Collection and have a repository method to get the count of log entries of a specific type. This is suboptimal, because all my other entities can handle their isDeletable() state on their own counting their restricting relations. |
I did a dirty workaround in my case, since I only wanted to enable a user to be deleted, if it only has activities editing a User entity (itself in most cases) and preventing deletion if it has activities of any other type. So when there are less than 20 activities, I hydrate them all with a filter() and when there are 20 or more, I assume that there will be at least one of another type and the user cannot be deleted. So if one creates a new user, logs in as this user and edits this user 20 times, it is incorrectly considered undeletable and thus can only be hidden. I can live with that. |
Of course Pull Requests are always welcome and your time and effort is appreciated. |
any news there? |
You can you use "Instance" of in DQL and QB. Maybe I missed something but it looks like there is no way to use it in Expression?
The text was updated successfully, but these errors were encountered: