payload
payload copied to clipboard
Collection List View "Where and" query not working properly with relationships
Describe the Bug
For context, consider that I have an Order, Product and Customer collection. We're in the Order
collection, at the List View.
If I filter for "Customer", "equals" ..., it populates properly and allows me to select an existing Customer
.
If I filter for something else, like Payment Status, for example first, then add an additional filter (effectively a Where
and
query) and choose the Customer
again (a relationship field), it will not populate the select with existing customers, but in fact, with whatever the first relationship
field of the collection is. So, since Product
was defined before Customer
in my CollectionConfig
for Order
, it populates with the products, rather than the customers.
Works alone:
and with the and
filter, you can see it is not populated with customers, but products instead:
Link to the code that reproduces this issue
https://github.com/HarleySalas/payload-3-reproductions/tree/where-and-relationships-list
Reproduction Steps
clone the reproduction (database (sqlite) and data, as well as autoLogin
are pushed to git to make it super easy)
go to http://localhost:3000/admin/collections/order
Add a filter for "Payment Status", "equals" "Captured"
Add an additional filter for "Customer", "equals", but then observe that it is not customers populated, but the products.
If you switch the order of Customer
and Product
in the CollectionConfig
, you'll see that it is "fixed," except then, there is an issue with the Product
and so fourth, as you might imagine.
Which area(s) are affected? (Select all that apply)
area: core
Environment Info
Payload: 3.5.0
Next: 15.0.4
Node: 22.2.0