neo4jrb / activegraph

An active model wrapper for the Neo4j Graph Database for Ruby.
http://neo4jrb.io
MIT License
1.4k stars 276 forks source link

Properties/relations updates not propagated to other instances of ActiveNode representing the same node #1528

Closed rndprt closed 5 years ago

rndprt commented 5 years ago

When there are several instances of ActiveNode representing the same node, updates in values/properties in one instance is not propagated to the other instances.

I assume it's related to the ActiveNode instances caches not being reset. I would have somehow expected that the changes would be propagated to all instances.

Code example

 # assuming the following node
 class Tag
    include Neo4j::ActiveNode
    property :name, type: String
 end

 # test code
  tag = Tag.create name: 'foo'

  clone = Tag.find tag.uuid
  tag.name = 'bar'
  tag.save
  assert_equal Tag.find(tag.uuid).name, tag.name # SUCCEEDS
  assert_equal clone.name, tag.name # FAILS

Runtime information:

Neo4j database version: 3.4.9 Community neo4j gem version: 9.2.4 neo4j-core gem version: 8.1.4

rndprt commented 5 years ago

My mistake. I'm new to Ruby and didn't realise it was the intended behaviour and reload should be called manually.