-
Notifications
You must be signed in to change notification settings - Fork 3.5k
HasMany relationship with localized:true failes to empty the relationship #8132
Description
Link to reproduction
No response
Describe the Bug
Relationship
So I have an relationship field which looks like this:
{
admin: {
position: "sidebar"
},
name: "userGroups",
label: "Gebruikersgroepen",
type: "relationship",
relationTo: UserGroups.slug,
localized: true,
required: false,
hasMany: true,
index: true,
}
When I remove all the selected userGroups in de Admin panel and save the document it gives a green success toast, but it resets the relationship to the old value.
Some steps I took to test:
- Select 2 options, save -> ✅
- Deselect 1 option, 1 option remaining, save -> ✅
- Deselect 1 option, 0 options remaining, save -> 🚫 (although the toast message says success, it resets the selected options)
createParentField
I have another field, named parent, which is created by the createParentField.
When I query the collection, with that field, with ?where[parent][exists]=false it returns 0 docs, where it should have returned 2 docs.
?where[parent][exists]=true works however..
When it started
It started when I added localized: true. When I remove localized it works again, I can empty the field and query the collection successfully.
What happens here with localized: true?
To Reproduce
- Create 2 collections
- Add a relationship from one collection to the other with the following properties:
- localized: true
- required: false
- hasMany: true
- Go to admin panel
- Add a couple docs in the 2 collections
- Go to one doc, select a couple options in the relationship field
- Save the doc
- Edit the relationship field, remove all the selected docs
- Save the doc
Payload Version
2.28.0
Adapters and Plugins
db-postgres, plugin-nested-docs, richtext-lexical, bundler-webpack