Skip to content

HasMany relationship with localized:true failes to empty the relationship #8132

Closed as not planned

Description

@michel-jump

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

  1. Create 2 collections
  2. Add a relationship from one collection to the other with the following properties:
    • localized: true
    • required: false
    • hasMany: true
  3. Go to admin panel
  4. Add a couple docs in the 2 collections
  5. Go to one doc, select a couple options in the relationship field
  6. Save the doc
  7. Edit the relationship field, remove all the selected docs
  8. Save the doc

Payload Version

2.28.0

Adapters and Plugins

db-postgres, plugin-nested-docs, richtext-lexical, bundler-webpack

Activity

  1. added
    status: needs-triage
    on Sep 9, 2024
  2. github-actions commented on Dec 6, 2024

    @github-actions
    Contributor

    This issue was automatically closed due to lack of activity.
    If this issue is still relevant against the latest codebase, please create a new issue.

  3. github-actions commented on Dec 10, 2024

    @github-actions
    Contributor

    This issue has been automatically locked.
    Please open a new issue if this issue persists with any additional detail.

  4. locked as resolved and limited conversation to collaborators on Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: needs-triagev2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions