Skip to content
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

A unique field on a component of a single-type leads to a faulty 'uniqueness check' #16918

Closed
maxbethke opened this issue Jun 5, 2023 · 6 comments
Assignees
Labels
fix:5 Fixed in Strapi 5 issue: bug Issue reporting a bug severity: medium If it breaks the basic use of the product but can be worked around source: core:database Source is core/database package source: core:strapi Source is core/strapi package status: confirmed Confirmed by a Strapi Team member or multiple community members

Comments

@maxbethke
Copy link

Bug report

Required System information

  • Node.js version: v16.17.1
  • NPM version: 9.1.2
  • Strapi version:
"dependencies": {
    "@strapi/plugin-i18n": "4.10.7",
    "@strapi/plugin-users-permissions": "4.10.7",
    "@strapi/strapi": "4.10.7",
    "mysql": "2.18.1"
  },
  • Database: MySQL Server 5.7.41-1.el7
  • Operating system: MacOS 12.6
  • Is your project Javascript or Typescript: TS

Describe the bug

A unique field on a component of a single-type leads to a faulty 'uniqueness check'

Steps to reproduce the behaviour

  • Create a new single-type with
    • a repeatable component on it
    • some other field, e.g. short text
  • Create a text field on the component (short text, unique)
  • Add a component to the single-type
  • Save the single-type
  • Put a value in the unique field of the component
  • Save the single-type
  • Edit any other field (just so you can hit save again)
  • Save the single type

At this point error gets displayed saying the value in the unique field of the component is not unique, even though it is.

Expected behavior

After the steps above, the single-type should be able save, because the unique field's value is unique.

Idea

I might be very well wrong, but to me it looks like on the update() of the single-type, the 'uniqueness check' for the unique field does not only look at array of components that would result from update, but at the old data merged with the new data. Thus resulting in the error, because the unique value now exists twice, once in the old record of the edited component and once in the new record.

@derrickmehaffy derrickmehaffy added issue: bug Issue reporting a bug severity: medium If it breaks the basic use of the product but can be worked around source: core:strapi Source is core/strapi package source: core:database Source is core/database package status: pending reproduction Waiting for free time to reproduce the issue, or more information labels Jun 5, 2023
@rbsam176
Copy link

rbsam176 commented Jun 6, 2023

If anyone has any workarounds (other than not making the field unique) while this is being fixed it would be great to hear them, it's affecting our app significantly.

@jhoward1994
Copy link
Contributor

Hi, thank you for the bug report. We are aware of this issue with unique fields and are actively working on it.

We also plan to extend the capabilities of unique fields in future, please see #12541 (comment)

@rbsam176
Copy link

Hi, thank you for the bug report. We are aware of this issue with unique fields and are actively working on it.

We also plan to extend the capabilities of unique fields in future, please see #12541 (comment)

Any idea on timeline? What priority is this on your roadmap?

@kasonde kasonde added status: confirmed Confirmed by a Strapi Team member or multiple community members and removed status: pending reproduction Waiting for free time to reproduce the issue, or more information labels Aug 4, 2023
@Kartik4152
Copy link

Any updates on this?

@DenuxPlays
Copy link

Also happens on collection-type.
Please update title!

@jhoward1994
Copy link
Contributor

This issue has been fixed in v5 from 5.0.0-beta.13 onwards via #20427

@jhoward1994 jhoward1994 added the fix:5 Fixed in Strapi 5 label Jun 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix:5 Fixed in Strapi 5 issue: bug Issue reporting a bug severity: medium If it breaks the basic use of the product but can be worked around source: core:database Source is core/database package source: core:strapi Source is core/strapi package status: confirmed Confirmed by a Strapi Team member or multiple community members
Projects
Status: Fixed/Shipped
Status: Fixed/Shipped
Status: Done
Development

No branches or pull requests

7 participants