-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Prevent publishing if duplicate identifier_field #2829
Comments
@TidyIQ have you found a solution to this? I'm experiencing the same issue - it doesn't stop me from publishing another entry with the same identifier field value. I'm using a gitlab backend |
I thought we fixed this in the past, might be a regression. cc/ @erezrokah |
Closing this, please re-open with more information if still experiencing the issue |
@vai0 So if the |
I am also having this issue. We are trying to have comments that live in a database to be tied to a post so we need a unique identifier on the posts and we are seeing that the default identifier_field 'title' is allowing duplicates. We can't find any way to work around this either, if anyone knows a workaround that would be great. |
I faced the same issue and solved the Id creation issue like mentioned in this post at the end (widget generates ID, not editable for user - used as identifier field instead of title): https://jozefm.dev/articles/2019/06/18/gridsome-netlify-cms-collection-relations/ BUT you must not use duplicate - there I am stuck at the moment because there is no way to identify this situation within the widget. It would be great if the identifier field would not be duplicated - if it would be just empty the component update could fill the field with new ID |
@saschatu we've used this same exact uuid solution for some of our collections, but for others collections where we'd like the user to add a slug, and have that slug be what's unique - since we don't want one page overwriting another, the auto-uuid generation doesn't really work :/ |
Hi @vai0 , But also with a generated ID I did not manage yet to ensure that after duplication a new ID is stored :( - issue #3205 |
This #1348 might serve as a solution once we enable modifying entry data in the hooks |
Unfortunately - using ID's or appending them to the slug would be a no-go given the importance of SEO for our use-case. Also - another big downside of setting a generated ID as the We can work a temp solution around a unique slug by setting a generated uid as the identifier field, and do a check for unique slugs when generating our static site; however - it'd be amazing if
this issue (along with a couple others, e.g., sorting entries by date / slow search) is what's holding us back from migrating our blog to netlify-cms |
@vai0 check the summary field (https://www.netlifycms.org/docs/configuration-options/) its purpose is defining the text to be shown in the list ;) |
It seems sensible to add a native uuid widget to Netlify CMS to help here. |
@saschatu thanks for your link. Is this still the only way to achieve a relationship using Gridsome (and Gatsby, which i'm not as familiar but looks like it also needs an ID)? |
Updates
As the original issue was to avoid duplication when using the relation widget, I think that issue is resolved. @vai0 and others, if your use case is still relevant either comment (if it's the same as the original issue) or open a new issue (if different than the original issue). |
@erezrokah However, regarding CMS Events: nice, but I miss some Event related to Duplication. That was the only open point regarding the ID: if an entity is duplicated we somehow need an option to avoid duplication of ID! But at the same time this ID must not change for the same entity (because relations will be broken). If I create the uuid during preSave, the entity get's a new ID with each save. Ok, checking for empty value would prevent this - but the "duplicate" case will lead to duplicate ID as well :( EDIT: just realized that the slug is always unique, even in duplicate case (-1 is added in slug for first duplicate) -> now I get the point of using slug as identifier!
|
For anyone who finds this through search like I did - a good way to ensure unique IDs are generated for duplicates during Brand new entries (i.e. a duplicate) don't have a I ended up using something like this:
|
Is your feature request related to a problem? Please describe.
Identifier fields should be unique. Duplicates should not be allowed to be published.
Describe the solution you'd like
Throw error if attempting to publish with an identifier field value that already exists.
Describe alternatives you've considered
There are no easy to use alternatives.
Additional context
I'm using a relation widget in a collection where the display/search/value field is set to the identifier_field of the collection it's related to. If a user has duplicate identifier_fields in that collection then the relation widget is useless as I can't lookup the correct field (since I have no idea which duplicate is the correct one).
Also, I'm unable to access the value of a field with duplicate identifier_fields as I have no idea which one is correct.
ID fields should always be unique. It doesn't make sense to allow duplicates.
The text was updated successfully, but these errors were encountered: