0

我正在寻找和作者阿尔伯特加缪。对于这位作者,我想检索他创作的所有艺术作品(他写了哪些书)。但我收到错误“NameError”。以下是详细信息:

Loading development environment (Rails 4.2.1)
irb(main):001:0> a = Author.find_by(author_name: 'Camus, Albert')
 CYPHER 1947ms MATCH (n:`Author`) WHERE (n.author_name = {n_author_name}) RETURN n LIMIT {limit_1} | {:n_author_name=>"Camus, Albert", :limit_1=>1}
=> #<Author uuid: "c48667c1-3c6e-11e5-8eb8-22000b18b199", author_name: "Camus, Albert">
irb(main):002:0> wa = a.wokas
NameError: uninitialized constant Neo4j::ActiveNode::Query::QueryProxy::ANSI
    from /Users/levi/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/neo4j-5.0.13/lib/neo4j/active_node/query/query_proxy.rb:54:in `inspect'

在第二次尝试中,我正在做:

irb(main):011:0* wa = a.wokas.to_a
 Author#wokas 1500ms MATCH author20415116 WHERE (ID(author20415116) = {ID_author20415116}) MATCH author20415116-[rel1:`AUTHORED_BY`]->(result_wokas:`Woka`) RETURN result_wokas | {:ID_author20415116=>20415116}
=> [#<Woka uuid: "3fa18fd6-3c6e-11e5-8eb8-22000b18b199", woka_title: "Postoronnij">, #<Woka uuid: "3ea359b6-3c6e-11e5-8eb8-22000b18b199", woka_title: "Chute / CD MP3, La">, #<Woka uuid: "335621a3-3c6e-11e5-8eb8-22000b18b199", woka_title: "First Man, The">, #<Woka uuid: "1a5d763c-3c6e-11e5-8eb8-22000b18b199", woka_title: "Caligula and Three Other Plays">,  ...

之后它正在工作,无需转换为数组:

irb(main):017:0* wa = a.wokas
=> [#<Woka uuid: "3fa18fd6-3c6e-11e5-8eb8-22000b18b199", woka_title: "Postoronnij">, #<Woka uuid: "3ea359b6-3c6e-11e5-8eb8-22000b18b199", woka_title: "Chute / CD MP3, La">, #<Woka uuid: "335621a3-3c6e-11e5-8eb8-22000b18b199", woka_title: "First Man, The">, #<Woka uuid: "1a5d763c-3c6e-11e5-8eb8-22000b18b199", woka_title: "Caligula and Three Other Plays">, #<Woka uuid: "ed76dd0d-3c6d-11e5-8eb8-22000b18b199", woka_title: "Exile and the Kingdom">, ...

更多细节:

irb(main):013:0* wa.count
=> 223
irb(main):014:0> wa.class
=> Neo4j::ActiveNode::HasN::AssociationProxy
irb(main):015:0> 

这是我的课程:

class Author
  include Neo4j::ActiveNode
  property :author_name, type: String

  has_many :out, :wokas, model_class: Woka, type: 'AUTHORED_BY'
end

class Woka
  include Neo4j::ActiveNode
  property :woka_title, type: String

  has_many :in,  :authors,      model_class: Author,      type: 'AUTHORED_BY'
  has_one  :in,  :publisher,    model_class: Publisher,   type: 'PUBLISHED_BY'
  has_many :out, :bisacs,       model_class: Bisac,       type: 'INCLUDED_IN'
  has_one  :in,  :language,     model_class: Language,    type: 'PUBLISHED_IN'
  has_many :out, :descriptions, model_class: Description, type: 'DESCRIBED_BY'
end

这里有什么问题?在 cypher 中测试关系时,一切正常。

4

1 回答 1

0

通过升级到修复:neo4j (5.0.14) neo4j-core (5.0.10)

于 2015-08-10T15:18:50.730 回答