Comments (16)
@cheerfulstoic please, check that the Bolt.Sips is started before you try to query, example, https://github.com/sirko-io/engine/blob/master/lib/sirko.ex#L10. It should solve your first problem with the socket. The second problem should be solved by @florinpatrascu 's suggestion about strings.
from bolt_sips.
no worries, we all went through this :)
I'll close this one, and create a new issue for improving the error support. I have an idea about why the "socket is not connected". We're retrying the requests in case of errors, but there are some specific errors we shouldn't bother the server with, such as the one you encountered, encoding errors, and so on. I believe the "socket is not connected", is actually an artifact of trying a request with errors and for some reasons the connection is lost in "translation". I'll look into that this week-end. Thanks again!
from bolt_sips.
For background:
$ elixir -v
Erlang/OTP 20 [erts-9.0] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]
Elixir 1.5.1
And in my mix.lock
, neo4j_sips
is version 0.3.2 and boltex
is 0.3.0
from bolt_sips.
hi there - I'm pretty sure the params support is working. Are you trying to use the mix task? If yes, I am not sure it can be used for something else than simple queries, as it was scoped as a convenience only. I'll have a look though. And, regarding the query you show in the comment above, you should probably try using a String
value instead? Above you have a charlist
ie 'foo'
? ;P Try this:
Neo4j.query!(Neo4j.conn, "CREATE (report:Report) SET report.test = {props}", %{props: "foo"})
from bolt_sips.
Wait, are you referring to neo4j_sips
? neo4j_sips is not using Bolt; it's using the REST API, over http.
from bolt_sips.
plus socket is not connected
, in your initial report, seems to be a network issue, i.e. neo4j server port configuration, mix config, etc?
from bolt_sips.
Ah, sorry for the confusion. This is actually Bolt.Sips
, but I aliased that to Neo4j
because I saw it in this task:
https://github.com/florinpatrascu/bolt_sips/blob/master/lib/mix/tasks/cypher.ex#L30
Though I'm not using the built-in task, I'm using my own custom mix task that I've created.
I don't think it's a network issue because I do a Neo4j.query!(Neo4j.conn, "MATCH (n) DETACH DELETE n")
at the start of the task which works fine. And again, if I change it to a simple query without params it works fine.
Good catch about 'foo'
. Absolutely changing it to "foo"
fixed that, but I still can't set all of the properties at once by passing in a map as the parameter to Neo4j. Could it be something where the bolt driver doesn't yet support passing in maps as parameters?
from bolt_sips.
We actually have tests covering this, please see link. Excerpt:
test "executing a Cpyher query, with map parameters", context do
conn = context[:conn]
cypher = """
CREATE(n:User {props})
"""
assert {:ok, _} = Bolt.Sips.query(conn, cypher, %{props: %{name: "Mep", bolt_sips: true}})
end
from bolt_sips.
hmmm, I believe I understand what is going on. Boltex is throwing an exception for nested maps. Will try to look into it later as I am caught into a project for work, unless @mschae or @dnesteryuk have a quicker answer?! :) an anticipated thanks guys! Basically this:
# in boltex repo, run MIX_ENV=test iex -S mix
uri = Boltex.IntegrationCase.neo4j_uri
Boltex.test uri.host, uri.port, "CREATE (report:Report) SET report = {props}", %{props: %{foo: "bar", another_map: %{unu: 1, doi: 2}}}, uri.userinfo
%Boltex.Error{code: "Neo.ClientError.Statement.TypeError", connection_id: 43264,
function: :run_statement,
message: "Property values can only be of primitive types or arrays thereof",
type: :cypher_error}
will also try to see if we can throw better errors from our end, but we pretty much echo back boltex' error messages.
Good catch!
from bolt_sips.
for brevity, 1st test will pass, the 2nd one will fail (in Bolt.Sips)
defmodule NodesAndProperties.Test do
use ExUnit.Case, async: true
alias Bolt.Sips, as: Neo4j
@simple_map %{foo: "bar", bolt_sips: true}
@nested_map %{foo: "bar", bolt_sips: true, a_map: %{unu: 1, doi: 2, baz: "foo"}, a_list: [1, 2, 3.14]}
test "create a node using SET properties and a simple map" do
r = Neo4j.query!(Neo4j.conn, "CREATE (report:Report) SET report = {props}", %{props: @simple_map})
assert r = %{stats: %{"labels-added" => 1, "nodes-created" => 1, "properties-set" => 2}, type: "w"}
end
test "create a node using SET properties and a nested map" do
r = Neo4j.query!(Neo4j.conn, "CREATE (report:Report) SET report = {props}", %{props: @nested_map})
assert r = %{stats: %{"labels-added" => 1, "nodes-created" => 1, "properties-set" => 2}, type: "w"}
end
end
leaving this here as a bookmark, for later
from bolt_sips.
Hey,
You're right @florinpatrascu that's a Neo4J error and not much we can do about it.
Neo4J doesn't allow for nested maps. Neither via bolt nor via REST. It's a limitation to Neo4J. In our projects I've resorted to encoding and decoding nested maps to json.
I quite like the error message actually. :)
from bolt_sips.
Thank you, Michael!!!
I quite like the error message actually.
me too :)
And you also saved me for some pain, as I was planning later on to check the REST support for the nested maps. Thanks again!
@cheerfulstoic - is there something else we could help you with, for this issue? Thank you for your report though!
from bolt_sips.
for reference: https://stackoverflow.com/questions/25750016/nested-maps-and-collections-in-neo4j-2#25754628
One comment:
There is a way to do this by converting nested maps to json string
exactly as you said, @mschae
from bolt_sips.
I don't actually have a nested map, actually. It's just a plain map. I can't share the example I'm using, but I'll try to put together a version which still breaks
from bolt_sips.
understood, ty
from bolt_sips.
Oh, gosh. I figured it out and it's my Ruby habits again:
Neo4j.query!(Neo4j.conn, "CREATE (:Report {props})", %{props: %{'foo' => "test" }})
It's because of the single quotes for the key in the map being a charlist. So I'm able to fix my issue. I don't know if there's a way to validate values going in so that users get a better error message than "socket is not connected"
. I'll let you decide if you want to tackle that ;)
Thanks!
from bolt_sips.
Related Issues (20)
- Config field for `timeout` not reflected in query timeouts HOT 12
- Just need some clarity about Bolt.Sips.conn
- Connection difficulty -- Bolt.Sips.Internals.Error Port #Port<0.n> is closed HOT 7
- Connection loses after a while: ** (Bolt.Sips.Exception) Port {:sslsocket, {:gen_tcp, #Port<0.25>, :tls_connection, :undefined}, [#PID<0.2789.0>, #PID<0.2786.0>]} is closed HOT 5
- Is routing mode enabled with neo4j+s protocol? HOT 6
- Prepared statements for queries when not possible to use parameters HOT 3
- Looking for new maintainers HOT 10
- Neo4j version 4 support HOT 5
- Going forward HOT 5
- Consistent bad connection state after malformed query: "... You need to\n`ACK_FAILURE` or `RESET` ..." HOT 7
- Road to neo4j 4 and streaming HOT 5
- Bolt.Sips.Protocol disconnected: ** (DBConnection.ConnectionError) HOT 13
- Unable to connect when using authentication HOT 14
- No write operations are allowed directly on this database. Writes must pass through the leader. The role of this server is: FOLLOWER HOT 3
- Hiding credentials in `Bolt.Sips.info`? HOT 3
- Request: guidance on parameterized queries HOT 4
- Response.profile is empty with a query with "PROFILE"
- (Bolt.Sips.Exception) unable to encode value: -128 HOT 1
- Outgoing SSL connection hangs, cannot be dropped and re-established HOT 2
- Feature request: auto reconnect HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bolt_sips.