(v2.7) How to configure search filters for associations on resources with composite identifiers #7133
Unanswered
toby-griffiths
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
We have the resources CustomerOrder & CustomerOrderLine. The CustomerOrderLine has composite keys that consist of the order Id + line number. The CustomerOrderLine line also has an association with TicketType, for which we would like to filter results based on. We're having to use a custom search filter because we're using ULIDs and we need to convert the string values to binary strings ourselves (API Platform doesn't do this automatically), on the
GET /customer_order_lines
endpoint to retrieve all lines associated with a ticket type.The problem we have is that FilterEagerLoadingExtension, because our custom filter adds a JOIN to the query, and CustomerOrderLine has a composite key, is replacing the query WHERE clause with one that is
o.orderId IN (SELECT IDENTITY(o_a2.order) FROM App\Entity\Tenant\Common\CustomerOrderLine o_a2 INNER JOIN o_a2.ticketType ticketType_a3 WHERE ticketType_a3.id = :id_p1)
because the resource (order line) has a composite key. So instead of getting the matching order lines were getting all the order lines for any order that contains a matching order line.We've solved this by replacing the composite key with an ID column, but thought I'd ask if anyone is aware of this issue, and of the best way to resolve it?
Here is our custom filter…
And here are skeleton resource classes…
Beta Was this translation helpful? Give feedback.
All reactions