Skip to content
This repository has been archived by the owner on Dec 12, 2023. It is now read-only.

Commit

Permalink
removed readonly from qb func
Browse files Browse the repository at this point in the history
  • Loading branch information
erictg committed Sep 18, 2019
1 parent bf8b734 commit 05bf3ca
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
7 changes: 2 additions & 5 deletions cypher.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,14 @@ type QueryBuilder struct {
Start *queryPartNode
Current *queryPartNode
errors []error
readonly bool

preparedStatements []stmt

conn *neo.BoltConn
}

func QB(readonly bool) *QueryBuilder{
return &QueryBuilder{
readonly: readonly,
}
func QB() *QueryBuilder{
return &QueryBuilder{}
}

func (q *QueryBuilder) addNext(s string) {
Expand Down
14 changes: 7 additions & 7 deletions cypher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ func TestQueryBuilder(t *testing.T){
req := require.New(t)

//match (n) return n
cypher, err := QB(false).Match(Path().V(V{Name:"n"}).Build()).Return(false, ReturnPart{Name: "n"}).ToCypher()
cypher, err := QB().Match(Path().V(V{Name:"n"}).Build()).Return(false, ReturnPart{Name: "n"}).ToCypher()
req.Nil(err)
req.EqualValues("MATCH (n) RETURN n", cypher)

//MATCH (n) WHERE n.age = 21 RETURN n
cypher, err = QB(false).
cypher, err = QB().
Match(Path().V(V{Name: "n"}).Build()).Where(C(&ConditionConfig{
Name: "n",
Field: "age",
Expand All @@ -27,7 +27,7 @@ func TestQueryBuilder(t *testing.T){
req.EqualValues("MATCH (n) WHERE n.age = 21 RETURN n", cypher)

//MATCH (n) RETURN n ORDER BY n.age DESC LIMIT 5
cypher, err = QB(false).
cypher, err = QB().
Match(Path().V(V{Name: "n"}).Build()).
Return(false, ReturnPart{Name: "n"}).
OrderBy(OrderByConfig{Name: "n", Member: "age", Desc: true}).
Expand All @@ -44,7 +44,7 @@ func TestQueryBuilder(t *testing.T){
req.Nil(err)
req.NotNil(params)

cypher, err = QB(false).
cypher, err = QB().
Create(NewNode(Path().V(V{
Name: "n",
Type: "Type",
Expand All @@ -59,15 +59,15 @@ func TestQueryBuilder(t *testing.T){
req.Contains(cypher, "age:21")

//MATCH (n) DETACH DELETE n
cypher, err = QB(false).
cypher, err = QB().
Match(Path().V(V{Name:"n"}).Build()).
Delete(true, "n").
ToCypher()
req.Nil(err)
req.EqualValues("MATCH (n) DETACH DELETE n", cypher)

//MATCH (n) SET n.name=5
cypher, err = QB(false).
cypher, err = QB().
Match(Path().V(V{Name: "n"}).Build()).
Set(SetConfig{
Name: "n",
Expand All @@ -84,7 +84,7 @@ func TestQueryBuilder(t *testing.T){
req.Nil(err)

//MERGE (city:City) REMOVE city.name
cypher, err = QB(false).
cypher, err = QB().
Merge(&MergeConfig{
Path: path,
}).
Expand Down

0 comments on commit 05bf3ca

Please sign in to comment.