-
-
Notifications
You must be signed in to change notification settings - Fork 495
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
Faulty query on virtual relation #4759
Comments
The problem here is that you can't use an aliased expression in the join clause, so even if we fix that alias in there, we end up with this:
This would require a join on the subquery instead - which is actually something I added few days ago to v6: But you would have to use the query builder (and update to v6) |
Good to know. Since this is being implemented in query builder, does that mean that defining virtual entities this way will not be supported? It would be quite the change for me to move the codebase to use query builder for this, since I've got some quite complex filters on my entities that I'd prefer to reuse in stead of using query builder separately. If this won't be supported, what's the actual use-case for defining a formula on relation decorators? |
Well, it was never meant to be supported, formulas are tested only for scalar properties :] I am sure we can find a way to make this work in v6, its more about designing the right API, implementation wise it should be pretty simple to wire those two features. |
This was actually much simpler, and can be part of v5. |
Great, thank you! |
Was this implemented in v6 or 5? I don't see |
its part of 5.8.5 as you can see from the commit detail |
Describe the bug
When defining a virtual relation (by defining formula in a relation decorator), applying filters on that relation will result in a faulty query.
Stack trace
To Reproduce
Steps to reproduce the behavior:
Expected behavior
A working query is produced that filters on the virtual firstBook relation.
Actual behavior
The following query is produced:
Additional context
Not sure if defining virtual relations like this is officially supported, but I figured it was since it works nicely as long as you don't apply filters on the virtual relation.
Versions
The text was updated successfully, but these errors were encountered: