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

Entity-ID generation when creating new component entities within transaction #59

Closed
cigitia opened this issue Feb 16, 2015 · 2 comments
Closed

Comments

@cigitia
Copy link

cigitia commented Feb 16, 2015

Component entities can be implicitly created by nesting maps in a transaction. However, in DataScript 0.9.0, as far as I can tell:

  • If explicit :db/id vals are omitted from within the nested maps,
  • And if other non-component entities are also created elsewhere in the same transaction,
  • Then :db/id vals may be generated that unexpectedly refer to both the new component entities and the non-component entities.

This can create circular references: if a new entity is created simultaneously with its component entity, then they may end up sharing the same ID. (This also currently can thus result in an infinite loop when using the Pull API; see #58.)

Including an explicit temporary ID (e.g., -1) in the components' parent entity is enough to correct the problem and to cause the other components to receive disjunct IDs, but I'm assuming that implicit temporary IDs are intended to be supported, as per DataScript Chat’s code.

A demonstration script of this behavior is at https://gist.github.com/cigitia/feafd70768fcd551cd16.

DataScript is amazing; thank you for creating it.

@tonsky
Copy link
Owner

tonsky commented Feb 16, 2015

Thanks — it was a bug indeed!

@cigitia
Copy link
Author

cigitia commented Feb 23, 2015

Thanks!

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

No branches or pull requests

2 participants