You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While investigating #1652, I noticed that QueryProxy replace_with compares IDs for all models to determine which relationships to delete and insert.
Assuming the id in question is a uuid, this probably works out fine, but when using multiple model classes, there could be some overlap of ids between the two model classes.
Note: the problem in the example below is currently hidden by the bug reported in #1652 . If pluck(:id) is were fixed, but no other changes were applied, then #1652 could be considered fixed, while this issue would not be.
Probably the best course of action is to fix this and #1652 at the same time.
Code example (inline, gist, or repo)
classBookincludeActiveGraph::Nodeid_property:isbnhas_one:in,:publisher,origin: :published_things,model_class: %w(Publisher)endclassMagazineincludeActiveGraph::Nodeid_property:issue_idhas_one:in,:publisher,origin: :published_things,model_class: %w(Publisher)endclassPublisherincludeActiveGraph::Nodehas_many:out,:published_things,type: :published,model_class: %w(BookMagazine)endoriginal_zine,book=[Magazine.create!(issue_id: "1234"),Book.create!(isbn: "098512=25")]publisher=Publisher.create!publisher.published_things=[original_zine,book]replacement_zine=Magazine.create!(issue_id: "098512=25")# same as book isbnpublisher.published_things=[replacement_zine]# leads to replace_with being called# replacement_zine did not get a rel, since it has the same id as bookreplacement_zine.reloadputsreplacement.publisher# puts nil# book was not removed, since it has the same id as replacement_zinebook.reloadputsbook.publisher# puts non-nil
@yourpalal do you currently have overlapping ids between models? I know that requiring global uniqueness is unnecessarily strong, but it is best practice. What id generator are you using?
We do have some overlapping ids between models. We import various external datasets and use the IDs used in those datasets as id_properties. Often, one data set will have several data types, which then become different models in activegraph.
In some cases, there is overlap of IDs within a single dataset, and in others there is overlap between these datasets.
Many datasets we import use integer ids (probably AUTOINT in their database) which can increase the likelihood of overlap between datasets.
Generally, any non-uuid ID property could end up running into this issue. If universally-unique IDs are required by ActiveGraph, that would be pretty easy to achieve by always using a uuid property, but I don't believe this is stated anywhere in the documentation.
While investigating #1652, I noticed that QueryProxy replace_with compares IDs for all models to determine which relationships to delete and insert.
Assuming the id in question is a
uuid
, this probably works out fine, but when using multiple model classes, there could be some overlap of ids between the two model classes.Note: the problem in the example below is currently hidden by the bug reported in #1652 . If
pluck(:id)
is were fixed, but no other changes were applied, then #1652 could be considered fixed, while this issue would not be.Probably the best course of action is to fix this and #1652 at the same time.
Code example (inline, gist, or repo)
Runtime information:
Neo4j database version:
neo4j gem version: 10.1.0
neo4j-ruby-driver gem version: 1.7.5
The text was updated successfully, but these errors were encountered: