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

Support for natural key's #5237

Closed
hoIIer opened this issue Oct 22, 2017 · 9 comments · Fixed by #6272
Closed

Support for natural key's #5237

hoIIer opened this issue Oct 22, 2017 · 9 comments · Fixed by #6272

Comments

@hoIIer
Copy link

hoIIer commented Oct 22, 2017

Hello,

We've run into an issue with a model that uses a natural key for the id.

The issue can be summed up as:

If a record is created, then deleted, then a new record created with same natural key as previously deleted record, we get error.

Assertion Failed: 'natural-key-model' was saved to the server, but the response returned the new id 'foo|bar', which has already been used with another record. (ember-data 2.17.0-beta.1)

It seems like the ember-data store is retaining a reference to the supposedly deleted record which prevents a new one from being created.

It is explained more here

Does ember-data support natural key's or is it something ever talked about? Or, am I off and the issue from above link is unrelated to natural key?

Thanks

@bmac
Copy link
Member

bmac commented Oct 22, 2017

Hi @erichonkanen. This seems like a bug and it is something Ember Data should support.

@hoIIer
Copy link
Author

hoIIer commented Oct 22, 2017

@bmac thanks for the input, I'm not entirely familiar with the intimate details of ember-data but do you think a work-around is possible? also where in the code would a new feature for this target? I'd be interested to get more familiar and possibly contribute

@urbany
Copy link

urbany commented Oct 23, 2017

This looks like a duplicate of the unloadRecord open issues.
@erichonkanen Here is a work around for now: #4972 (comment)

@hoIIer
Copy link
Author

hoIIer commented Nov 12, 2017

@hjdivad @workmanw I just reverted our app to ember-data 2.12.1 after spending many hours trying to work around this issue and when I revert back to 2.12.1 our app works with no errors! not sure what happened after 2.12+... the issue happens when we remove a record that belongs to a model.hasMany and uses a composite id (natural key), and then we try to create a new record using the same composite id... so for now we have to go back to 2.12 until things stabilize :D

@hoIIer
Copy link
Author

hoIIer commented Dec 25, 2017

@bmac @hjdivad checking in if there has been any discussion on this issue? still outstanding as of 2.18.0-beta.1

"Assertion Failed: 'friendship' was saved to the server, but the response returned the new id 'burrito|taco', which has already been used with another record.'"```

@hoIIer
Copy link
Author

hoIIer commented Dec 25, 2017

related: #4972

@hoIIer
Copy link
Author

hoIIer commented Dec 25, 2017

related: #5006

@runspired
Copy link
Contributor

Closing this in favor of #1829

@hoIIer
Copy link
Author

hoIIer commented Jul 15, 2021

Running into this again in 2021 w/ember-data 3.20.5. It seems like using composite natural keys causes problems, particularly when creating/deleting/recreating a record with the same key (id) via websocket updates.

When a record is deleted via "record.destroyRecord()", and then later created again via "store.pushPayload(**recordData)", a new attempt to delete via "record.destroyRecord()" will throw with Error: Attempted to handle event deleteRecord on <record:test1::test2> while in state root.deleted.saved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants