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

Unable to update primary key column, succeeds without error but no update applied #21101

Closed
JonasGruenwald opened this issue Jan 16, 2024 · 3 comments

Comments

@JonasGruenwald
Copy link

Describe the Bug

When trying to update an entry in a collection with the primary key column set up as "manually entered string", the operation appears to succeed (directus shows no error) but the primary key column is not changed.

To Reproduce

  • Set up directus with the latest version as described here: https://docs.directus.io/self-hosted/quickstart.html#create-a-docker-compose-file
  • Create a collection test with the primary key field (id) set to "Manually entered string"
  • Create an entry in test, set id to foo
  • Edit the entry, change id to bar, click save
  • The entry appears to save successfully but the id of the entry is still foo (note if there are other fields in the entry, they are updated correctly)

I have no problems updating the primary key column of the same table with a regular SQL query like

UPDATE "test" SET id='bar' WHERE "id"='foo';

So it does not appear to be an issue/constraint with the database or schema.

I understand that directus may not want to allow updating primary keys for some internal reason, but I think in that case an error message should be show, as the current behaviour is confusing since the edit seems to succeed but does not

Directus Version

10.8.3

Hosting Strategy

Self-Hosted (Docker Image)

@mahendraHegde
Copy link
Contributor

@br41nslug is there a reason to exclude pk while updating? or as a part of this fix should we allow updating PK as long as its not auto increment/generated

const payloadWithoutAliasAndPK = pick(payloadWithA2O, without(fields, primaryKeyField, ...aliases));

@br41nslug
Copy link
Member

br41nslug commented Jan 18, 2024

is there a reason to exclude pk while updating?

If there was i would have closed the issue instead of marking it as issue.

@ComfortablyCoding
Copy link
Contributor

ComfortablyCoding commented Jan 19, 2024

Thanks for opening this issue! However this is a duplicate of an existing issue #16472, so I'll proceed to close this but if you think this is actually a different issue, then please do not hesitate to comment. Otherwise you may subscribe to #16472 for future updates.

Per #16472 (comment) we do not allow updating the PK at this time for the reasons stated there.

@ComfortablyCoding ComfortablyCoding closed this as not planned Won't fix, can't repro, duplicate, stale Jan 19, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants