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

Save as copy not working with autoincrement primary key #15771

Closed
lluishi93 opened this issue Sep 27, 2022 · 7 comments · Fixed by #16966
Closed

Save as copy not working with autoincrement primary key #15771

lluishi93 opened this issue Sep 27, 2022 · 7 comments · Fixed by #16966
Labels

Comments

@lluishi93
Copy link

lluishi93 commented Sep 27, 2022

Describe the Bug

Save as copy has stopped working. It seems that it fails when creating the new record because Directus is trying to use the existing ID.

To Reproduce

  • Create collection A with Auto-incremented integer primary key type
  • Create a string field in collection A
  • Create an item for collection A
  • Enter the previously created item details page, edit the string field, and try to "Save as copy" it

Errors Shown

{
  "errors": [
    {
      "message": "Field has to be unique.",
      "extensions": {
        "code": "RECORD_NOT_UNIQUE",
        "collection": "PRIMARY",
        "field": null,
        "invalid": "2226"
      }
    }
  ]
}

What version of Directus are you using?

9.18.0

What version of Node.js are you using?

16.14.0

What database are you using?

MySQL 5.7

What browser are you using?

Chrome

How are you deploying Directus?

Docker

@azrikahar
Copy link
Contributor

azrikahar commented Sep 28, 2022

Preface: The field null value is related to #15033, so that should be addressed over there.

This might be related to the change in #14947 (released in 9.18.0), particularly the check for is_generated to delete the primary key during Save as Copy: https://github.com/directus/directus/pull/14947/files#diff-4ca9afb518ec3f7957e6a2723f01f557c177987383e93bda1ce02918b73b27fcR172

as is_generated is false for autoincrement id, at least for Postgres from my local test:
chrome_WIxjVJT4Wc

so the id is being sent during save as copy now.

@azrikahar azrikahar changed the title Save as copy not working - Field has to be unique Save as copy not working with autoincrement primary key Sep 28, 2022
@WuGGu
Copy link

WuGGu commented Oct 14, 2022

Same problem with 9.18.1. Going back to 9.17.4 fixed it for me.

@azrikahar
Copy link
Contributor

Note: #16186 reported this for UUID as well, so it should also be tested alongside autoincrement primary keys.

@AaronBeaudoin
Copy link

I feel that this issue deserves more attention. It's been a month now that the "Save as Copy" button just doesn't work. Maybe, at the very least, the button should be removed entirely in the meantime while this issue remains unresolved?

@rijkvanzanten
Copy link
Member

Linear: ENG-179

@ricricucit

This comment was marked as off-topic.

@br41nslug
Copy link
Member

@ricricucit Hiding this comment as unrelated as it was answered here #10418 (comment)

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants