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
When defining a has_many relationship with more than one model classes, and the model classes have defined custom id properties, QueryProxy replace_with fails to correctly delete the old relationships.
This is because QueryProxyLink#converted_key converts :id to :uuid when no model class is given. Due to this issue,pluck(:id) returns an array of nils in this scenario.
Suggested actions:
refactor replace_with to get the right ids for the various model classes
change converted_key to raise an error in this situation, instead of returning uuid. This may cause some breakage, but it will change some already-broken code from failing silently to failing with an exception, which is an improvement in my opinion.
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=[Magazine.create!(issue_id: "1234"),Book.create!(isbn: "098512=25")]publisher=Publisher.create!publisher.published_things=originalreplacement=[Magazine.create!(issue_id: "09820685")]publisher.published_things=replacement# leads to replace_with being calledpublisher.reloadputspublisher.published_things.count# puts 3
note: I ran into this problem while also using an ActiveGraph::Relationship. I'm pretty sure that's not relevant to the issue, but I could be wrong.
When defining a has_many relationship with more than one model classes, and the model classes have defined custom id properties, QueryProxy replace_with fails to correctly delete the old relationships.
This is because QueryProxyLink#converted_key converts
:id
to:uuid
when no model class is given. Due to this issue,pluck(:id)
returns an array of nils in this scenario.Suggested actions:
Code example (inline, gist, or repo)
note: I ran into this problem while also using an
ActiveGraph::Relationship
. I'm pretty sure that's not relevant to the issue, but I could be wrong.Runtime information:
Neo4j database version:
neo4j
gem version: 10.1.0neo4j-ruby-driver
gem version: 1.7.5The text was updated successfully, but these errors were encountered: