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

has_one association does not preserve schema integrity with ActiveRel #1560

Closed amitsuryavanshi closed 5 years ago

amitsuryavanshi commented 5 years ago

Additional information which could be helpful if relevant to your issue:

Code example (inline, gist, or repo)

class Person
  include Neo4j::ActiveNode

  has_many :in, :posts, rel_class: :OwnerRel
end

class Post
  include Neo4j::ActiveNode

  has_one :out, :owner, , rel_class: :OwnerRel
end

class OwnerRel
  include Neo4j::ActiveRel

  from_class :Post
  to_class :Person
  type :owner
end

post = Post.create
person_1 = Person.create
person_2 = Person.create

OwnerRel.create(from_node: post, to_node: person_1)
OwnerRel.create(from_node: post, to_node: person_2)

Runtime information:

Does not enforce the has_one :owner schema definition.

Neo4j database version: neo4j gem version: neo4j-core gem version: