Giter Site home page Giter Site logo

hasbolt's People

Contributors

epsilonhalbe avatar hvr avatar maksbotan avatar odanoburu avatar oddsome avatar ozzzzz avatar sebashack avatar zmactep avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hasbolt's Issues

variables as parameters

I defined a data type

data A = A B C D
type B = Text
type C = Bool
type D = Int

and i want to build a function that takes an A type and builds a node with label A and properties b,c and d out of it as follows

typeAtoNode pipe (A b c d) = run pipe $ query "create (n:A {B:b, C:c, D:d}) return n"

this however, rather understandably, throws an exception from Neo4j because the values of b,c, and d don't actually get interpolated into the query.

I tried also using queryP and also ran into a Neo4j exception there too as follows

typeAtoNode pipe (A b _ _) = run pipe $ queryP "create (n:A) where n.B contains {B} return n" (fromList [("B", T b)])

*** Exception: user error (code: "Neo.ClientError.Statement.SyntaxError", message: "Invalid input 'h': expected 'i/I' (line 1, column 18 (offset: 17))\n\"create (n:A) where n.B contains {B} return n\"\

How do I correctly use variables to interpolate node/relationship properties in the queries?

I suspect that the issue is with my understanding and not with the package itself, but I figured it'd be best to ask you for the clarification. Thanks for the help in advance!

Bolt protocol 4+ support (with poll)

Hi!

So, since the version 0.1.5.0 (see #28), we have initial support of Bolt Protocol v.3.
It contains:

  • New initial message during the client-server handshake.
  • New format of "run query" message.

You may choose { ... version = 3 ... } in BoltCfg, and everything should work even with the latest version of neo4j (4.2.6). But we still do not support the extra dictionary in "run query" and new transactions style (the old one from protocol v.2 seems to work). And of course, neo4j will drop the version 3 protocol soon, while version 4 has backward capability break again.

I see that I have to redesign a library a lot to support the newest features. So I have a question for all the users: should I still support the versions 1/2 of protocol or keep only the latest version? Or maybe I should make another library (like, hasbolt2 for the newest versions)? Or perhaps you are not interested in novel features and just need the basic statements supporting the latest versions of neo4j?

/polls "I need support of protocol versions 1/2" "I need the non-basic features of latest protocol versions" "I am ok to use the separate library for new/old protocol versions"

Show, Read instance to BoltCfg

would you mind adding a Read and Show instance to BoltCfg? if not, do you know a simple way of having an user specify the configuration? (there are many options, so anything I could think of would involve lots of boilerplate or adding a dependency on a specialized library)

Sending queries with parameters not in map hangs

import           Database.Bolt           hiding (Value)
import qualified Data.Map.Strict         as M

main :: IO ()
main = do pipe <- connect $ def {user = "neo4j", password = neo4j}
          result <- run pipe $ queryP "MATCH (d {prop: {prop}}) return d;" M.empty
          putStr "Result:"
          print result
          close pipe

With a neo4j db in default config the above program does not terminate

Support for transactions

Hi @zmactep , thanks for making this library!

I see that project looks a bit abandoned and I was wondering if you have thought at any point about introducing support for transactions?

I could give it a shot and see if I can implement it if you think it could be merged :)

MERGE ON CREATE ON MATCH with more than 12 properties seems to cause a subsequent binary format decode error

consider a query of form

MERGE (x:SomeTag{a:"val1",b:"val"2,c:"val3"})
ON MATCH SET x.d = "val7", x.e = "val8", ... , x.z = "val9"
ON CREATE SET x.d = "val4", x.e = "val5", ... , x.z = "val6"

I seem to be hitting a limit of about 12 properties set before subsequent queries for nodes thus initialised results in a binary format decoding error, all using the Haskell hasbolt library. Less than this and all works fine.

A typical failing query would be:

MATCH (x:SomeTag{a:"val1",b:"val"2,c:"val3"}) RETURN x

results in

Cannot fetch: wrong message format (Error while decoding binary format: expected text)

This also seems to happen with SET += {12+ properties}

Happy to did in to diagnose, but just want to seek some commentary/guidance before I do.

thanks, S.

Neo4j 4 drops bolt version 1, perhaps default to higher version?

I understand that neo4j 4 has dropped support for bolt version 1, which causes hasbolt connections to fail with the default version 1 requested.

Perhaps it's time to default to version 2?

I would also like to suggest that current error message be adjusted.

It presently reads "Cannot connect: unsupported server version".

I think that's misleading, and would suggest instead "Cannot connect: Requested Bolt protocol version unsupported".

thanks for the great work,
Stephen.

error: Variable not in scope: def

Hi, thanks for making this. I can't seem to access the 'def' function. I've installed using cabal install hasbolt.

$ ghci
GHCi, version 8.0.2: http://www.haskell.org/ghc/  :? for help
Prelude> import Database.Bolt
Prelude Database.Bolt> pipe <- connect $ def { user = "neo4j", password = "xxxxx" }

<interactive>:2:19: error: Variable not in scope: def :: BoltCfg

<interactive>:2:32: error:
    • Couldn't match expected type ‘Data.Text.Internal.Text’
                  with actual type ‘[Char]’
    • In the ‘user’ field of a record
      In the second argument of ‘($)’, namely
        ‘def {user = "neo4j", password = "zuhlke"}’
      In the first argument of ‘GHC.GHCi.ghciStepIO ::
                                  forall a. IO a -> IO a’, namely
        ‘connect $ def {user = "neo4j", password = "zuhlke"}’

<interactive>:2:52: error:
    • Couldn't match expected type ‘Data.Text.Internal.Text’
                  with actual type ‘[Char]’
    • In the ‘password’ field of a record
      In the second argument of ‘($)’, namely
        ‘def {user = "neo4j", password = "zuhlke"}’
      In the first argument of ‘GHC.GHCi.ghciStepIO ::
                                  forall a. IO a -> IO a’, namely
        ‘connect $ def {user = "neo4j", password = "zuhlke"}’
Prelude Database.Bolt> [Ctrl-D]
Leaving GHCi.
$ 

Cheers,

Rob

log output

Hi,

great driver. But would it be possible to remove the logging output recently added (that you refer to in code comments as 'useless' :) ).

thanks,
S.

Fragile Pipes Syndrome

I seem to have an affliction of fragile pipes. From what I've observed anytime I try to bind records returned by a query to a variable for later use, the pipe breaks immediately thereafter. Here's an example

>>>pipe <- connect $ def {user = "neo4j", password = "neo4j"}
(0.00 secs, 397,056 bytes)

>>>run pipe $ query "create (n) return n"
[fromList [("n",S (Structure {signature = 78, fields = [I 389,L [],M (fromList [])]}))]]
(0.00 secs, 567,568 bytes)

>>>run pipe $ query "match (n) return n"
[fromList [("n",S (Structure {signature = 78, fields = [I 389,L [],M (fromList [])]}))]]
(0.00 secs, 554,896 bytes)

>>>records <- run pipe $ query "create (n) return n"
(0.00 secs, 437,872 bytes)

>>>run pipe $ query "match (n) return n"
[]
(0.00 secs, 450,728 bytes)

>>>run pipe $ query "match (n) return n"
*** Exception: user error (Unknown error)

>>>run pipe $ query "match (n) return n"
*** Exception: sendBuf: resource vanished (Broken pipe)

>>>run pipe $ query "match (n) return n"
*** Exception: writev: resource vanished (Broken pipe)

>>>

How might I fix this issue?

Thanks again,
Kerim

Can't use Hasbolt with GrapheneDB

Trying to use Hasbolt to connect to a GrapheneDB database gives the error:

Network.Socket.recvBuf: resource vanished (Connection reset by peer)

I am using the following config:

demoUser :: BoltCfg
demoUser = def
  { user = "demo-user"
  , password = "..."
  , host = "hobby-jb...pl.dbs.graphenedb.com"
  , port = 24786
  }

Connecting with these credentials works fine with other Neo4j drivers.

Compiler error on versions > 0.1.1.3

I've been getting up and running with hasbolt today (thanks for creating the package by the way) and I've run into an issue which I've been able to solve. I felt that it'd be worth noting here.

If I simply set up the package with hasbolt as a dependency, then the following compiler error will be displayed on running stack build:

/home/oscarsouth/haskellProjects/theHarmonicAlgorithm/app/Main.hs:10:17: error: Variable not in scope: def :: BoltCfg
   |
10 | defaultConfig = def {user = "neo4j", password = "secret"}
   |                 ^^^


--  While building custom Setup.hs for package theHarmonicAlgorithm-0.1.0.0 using:
      /home/oscarsouth/.stack/setup-exe-cache/x86_64-linux-tinfo6/Cabal-simple_mPHDZzAJ_2.0.1.0_ghc-8.2.2 --builddir=.stack-work/dist/x86_64-linux-tinfo6/Cabal-2.0.1.0 build lib:theHarmonicAlgorithm exe:theHarmonicAlgorithm-exe --ghc-options " -ddump-hi -ddump-to-file -fdiagnostics-color=always"
    Process exited with code: ExitFailure 1

If I add the following version (or earlier) of hasbolt as an extra-dep, the project will compile successfully:

extra-deps:
- hasbolt-0.1.1.3

However, any version of hasbolt above this (or none specified at lts-11.8) will fail to compile and return the above error.

I'm currently working with the version specified above, in order to 'sidestep' this issue.

Hope that this is helpful,
Let me know if you'd like any more info.

Thanks,
Oscar South

Doesn't work for Neo4j version 5.7

Query gives the following error:
Neo.ClientError.Request.InvalidFormat: Illegal struct size: Expected struct to be 1 fields but got 0

This happens because the specification has been changed, the spec now expects elemIds on everything

Exposing ResponseError data type

I'm wondering if it would be a good idea to expose the ResponseError constructors to allow users to make smarter decisions about errors.

For example the error type "Neo.ClientError.Schema.ConstraintValidationFailed" can sometimes be used to determine if there should be a user input error vs an internal server error. Similar to 400 vs 500 http error codes.

Or am I missing some other method to be able to distinguish between the error types in the KnownResponseFailure?

`def` Cannot be found

Hello!

Since migrating from 0.1.1.2 to 0.1.2.1, the def function appears to have disappeared. What should we use instead?

Thanks for your help and the excellent package!

profiling Cypher queries

it's a bit difficult to detach my Haskell code from my cypher queries, so it's not easy for me to use cypher-shell for realistic profiling; so I wonder: what's the best practice for profiling queries when using this library? is there a way of getting the profiling results of queries run by hasbolt using the PROFILE keyword?

Problem with official example

Hi! I want to use Hasbolt, and I'm trying to run the simple example shown on the post in the Neo4J blog.

main :: IO ()
main = do pipe <- connect myConfiguration
          records <- run pipe $ query "MATCH (n:Person) WHERE n.name CONTAINS \"Tom\" RETURN n"
          let first = head records
          cruise <- first `at` "n" >>= exact :: IO Node
          print cruise
          close pipe

Everything works fine, and I do get the results, but I get an error when I try to use exact that I can't even begin to understand...

Couldn't match type ‘BoltError’ with ‘UnpackError’ arising from a functional dependency between:
          constraint ‘MonadError UnpackError (BoltActionT m0)’
            arising from a use of ‘exact’
          instance ‘MonadError BoltError (BoltActionT m)’
            at <no location info>
In the second argument of ‘(>>=)’, namely ‘exact’
      In a stmt of a 'do' block:
        cruise <- first `at` "n" >>= exact :: IO Node
      In the expression:
        do pipe <- connect myConfiguration
           records <- run pipe
                        $ query "MATCH (n:Person) WHERE n.root CONTAINS \"Tom\" RETURN n"
           let first = head records
           cruise <- first `at` "n" >>= exact :: IO Node

Any ideas?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.