virtualgraham / Neo4jBolt.jl

Neo4j Bolt driver for Julia supports Neo4j 3.0 and above
Other
29 stars 5 forks source link

ERROR: MethodError: Cannot `convert` an object of type Dict{Any, Any} to an object of type String #7

Open wjholden opened 3 years ago

wjholden commented 3 years ago

https://github.com/virtualgraham/Neo4jBolt.jl/blob/c55dc83379e97498d615889d2ba6670c222cb29c/src/julia_bolt/JuliaBolt.jl#L257

I am getting the following exception when I connect to my Neo4j Desktop 1.4.7/DBMS 4.3.1 database with Julia 1.6.1.

julia> driver = Neo4jBoltDriver("bolt://127.0.0.1:7687", auth=("neo4j", "password"))
ERROR: MethodError: Cannot `convert` an object of type Dict{Any, Any} to an object of type String
Closest candidates are:
  convert(::Type{String}, ::String) at essentials.jl:210
  convert(::Type{T}, ::T) where T<:AbstractString at strings/basic.jl:231
  convert(::Type{T}, ::AbstractString) where T<:AbstractString at strings/basic.jl:232
  ...
Stacktrace:
  [1] setindex!(h::Dict{String, String}, v0::Dict{Any, Any}, key::String)
    @ Base .\dict.jl:382
  [2] merge!(d::Dict{String, String}, others::Dict{Any, Any})
    @ Base .\abstractdict.jl:184
  [3] (::Neo4jBolt.JuliaBolt.var"#19#20"{Neo4jBolt.JuliaBolt.Connection})(r::Neo4jBolt.JuliaBolt.Response, m::Dict{Any, Any})
    @ Neo4jBolt.JuliaBolt C:\Users\wjhol\.julia\packages\Neo4jBolt\puMBY\src\julia_bolt\JuliaBolt.jl:257
  [4] handle_success(response::Neo4jBolt.JuliaBolt.Response, metadata::Dict{Any, Any})
    @ Neo4jBolt.JuliaBolt C:\Users\wjhol\.julia\packages\Neo4jBolt\puMBY\src\julia_bolt\JuliaBolt.jl:601
  [5] fetch(c::Neo4jBolt.JuliaBolt.Connection)
    @ Neo4jBolt.JuliaBolt C:\Users\wjhol\.julia\packages\Neo4jBolt\puMBY\src\julia_bolt\JuliaBolt.jl:449
  [6] bolt_sync(c::Neo4jBolt.JuliaBolt.Connection)
    @ Neo4jBolt.JuliaBolt C:\Users\wjhol\.julia\packages\Neo4jBolt\puMBY\src\julia_bolt\JuliaBolt.jl:526
  [7] hello(c::Neo4jBolt.JuliaBolt.Connection)
    @ Neo4jBolt.JuliaBolt C:\Users\wjhol\.julia\packages\Neo4jBolt\puMBY\src\julia_bolt\JuliaBolt.jl:259
  [8] handshake(socket::Sockets.TCPSocket; config::Base.Iterators.Pairs{Symbol, Any, Tuple{Symbol, Symbol}, NamedTuple{(:auth, :error_handler), Tuple{Tuple{String, String}, Neo4jBolt.JuliaBolt.ConnectionErrorHandler}}})
    @ Neo4jBolt.JuliaBolt C:\Users\wjhol\.julia\packages\Neo4jBolt\puMBY\src\julia_bolt\JuliaBolt.jl:914
  [9] bolt_connect(address::Neo4jBolt.JuliaBolt.Address; config::Base.Iterators.Pairs{Symbol, Any, Tuple{Symbol, Symbol}, NamedTuple{(:auth, :error_handler), Tuple{Tuple{String, String}, Neo4jBolt.JuliaBolt.ConnectionErrorHandler}}})
    @ Neo4jBolt.JuliaBolt C:\Users\wjhol\.julia\packages\Neo4jBolt\puMBY\src\julia_bolt\JuliaBolt.jl:930
 [10] (::Neo4jBolt.var"#connector#5"{Neo4jBolt.var"#connector#3#6"{Base.Iterators.Pairs{Symbol, Tuple{String, String}, Tuple{Symbol}, NamedTuple{(:auth,), Tuple{Tuple{String, String}}}}}})(address::Neo4jBolt.JuliaBolt.Address; kwargs::Base.Iterators.Pairs{Symbol, Neo4jBolt.JuliaBolt.ConnectionErrorHandler, Tuple{Symbol}, NamedTuple{(:error_handler,), Tuple{Neo4jBolt.JuliaBolt.ConnectionErrorHandler}}})
    @ Neo4jBolt C:\Users\wjhol\.julia\packages\Neo4jBolt\puMBY\src\Neo4jBolt.jl:88
 [11] acquire_direct(c::Neo4jBolt.JuliaBolt.ConnectionPool, address::Neo4jBolt.JuliaBolt.Address)
    @ Neo4jBolt.JuliaBolt C:\Users\wjhol\.julia\packages\Neo4jBolt\puMBY\src\julia_bolt\JuliaBolt.jl:742
 [12] acquire (repeats 2 times)
    @ C:\Users\wjhol\.julia\packages\Neo4jBolt\puMBY\src\julia_bolt\JuliaBolt.jl:773 [inlined]
 [13] Neo4jBoltDriver(uri::String; config::Base.Iterators.Pairs{Symbol, Tuple{String, String}, Tuple{Symbol}, NamedTuple{(:auth,), Tuple{Tuple{String, String}}}})
    @ Neo4jBolt C:\Users\wjhol\.julia\packages\Neo4jBolt\puMBY\src\Neo4jBolt.jl:94
 [14] top-level scope
    @ REPL[5]:1

I would also like to comment that for some reason I have to specify 127.0.0.1 to get this far; the hostname localhost does not work.

John-Boik commented 2 years ago

I have the same issue as @kinow for the simple UNWIND(RANGE(1, 10)) AS z RETURN z test. I'm using Neo4j version 4.4.3. The hack solution I found was to alter line 262 of JuliaBolt.jl from:

append(c, 0x01, [headers], Response(c, on_success=(r, m)->merge!(c.server.metadata, m), on_failure=on_init_failure))

to this:

append(c, 0x01, [headers], Response(c, on_success=(r, m)->merge!(c.server.metadata, Dict() ), on_failure=on_init_failure))

I simply pass in an empty dict for whatever was expected in Response. With this hack, the example tests in the readme run fine. The unit tests also run successfully, but the integration tests fail with the message KeyError: key "bookmark" not found.

Can anyone offer a better solution, or explain what I'm breaking? In my case I will use Cypher queries, as in the simple examples, so my hack might be workable. I can also verify that I can send parameters successfully.

John