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 collection items with manually entered string primary keys #16472

Open
azrikahar opened this issue Nov 16, 2022 · 9 comments
Open
Labels

Comments

@azrikahar
Copy link
Contributor

azrikahar commented Nov 16, 2022

Describe the Bug

When we're updating the manually entered string as primary key of an item, it seems like the API request correctly sends the updated value, but the API response returns the old value:

chrome_BpF97sfBig.mp4

To Reproduce

  1. Create a collection with manually entered string as primary key.
  2. Create an item in said collection by entering a string as the primary key.
  3. Try to edit the item and update the ID and save it, but it seems like it is not being saved.

Errors Shown

No errors are shown.

What version of Directus are you using?

9.20.4 (45eb494)

What version of Node.js are you using?

18.10.0

What database are you using?

Postgres 14

What browser are you using?

Chrome

How are you deploying Directus?

running locally in dev

@licitdev
Copy link
Member

I believe this is due to the primary key being filtered from the update payload.

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

I am wondering when should changes to IDs be allowed.
Should the updating of primary key be allowed for integer / uuid PKs too? 🤔

@rijkvanzanten
Copy link
Member

rijkvanzanten commented Nov 16, 2022

Tricky.. When there's foreign keys in place to those primary keys, the database should ensure that the correct triggers are fired. That being said, there's most likely going to be databases that don't have foreign key constraints, in which case this might cause some serious issues if we don't reimplement foreign key checks in directus itself

@rijkvanzanten
Copy link
Member

Linear: ENG-137

@VladDigitalOriginal
Copy link

@rijkvanzanten are you planning to provide the ability to update manually entered primary keys, or has this feature/bug been forgotten?

@rijkvanzanten
Copy link
Member

are you planning to provide the ability to update manually entered primary keys

Eventually, yes! My comment above is still relevant: #16472 (comment)

As of right now, we don't allow updating PKs (auto-increment integers, UUIDs, or otherwise) because of that comment.

or has this feature/bug been forgotten?

Nope, it's an open issue 👍🏻 There hasn't been any activity on this issue (no upvotes or comments), so it's a lower priority for us

@VladDigitalOriginal
Copy link

Thank you, @rijkvanzanten !

There hasn't been any activity on this issue (no upvotes or comments)

Made more activity in the hope that you will reevaluate this issue :)

@jjeising
Copy link

Thank you! We're using this with key → value tables, e.g. for translations and would also welcome an improvement here.

@JonasGruenwald
Copy link

As I wrote in my closed issue:

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 shown, as the current behavior is confusing since the edit seems to succeed but does not

@mahendraHegde
Copy link
Contributor

@rijkvanzanten I was thinking, we have directus_relations with the relations metadata, so cant we do a find and update on all relational tables(for DBs that dont support cascade updates)? or am i missing something?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: 📋 Backlog
Development

No branches or pull requests

7 participants