Skip to content

Commit

Permalink
Add new type that can be parametrized.
Browse files Browse the repository at this point in the history
This commit adds new type: "int64" that can be used by
(*Graph).ParameterizedQuery method. According to the
"Cypher Coverage" section from RedisGraph documentation:
64-bit signed integer is supported literal type.

This change will allow, for example, to use time.Now().Unix()
as parameter for previously mentioned ParameterizedQuery.

Before this change, using int64 as parameter for ParameterizedQuery
result with panic, although using int64 is very common when writing
go code.
  • Loading branch information
thinkofher committed Jul 23, 2021
1 parent f906451 commit 5cff083
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 6 additions & 3 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,10 +420,13 @@ func TestUtils(t *testing.T) {
res = ToString(true)
assert.Equal(t, res, "true")

var arr = []interface{}{1,2,3,"boom"}
res = ToString(int64(10))
assert.Equal(t, res, "10")

var arr = []interface{}{1, 2, 3, int64(4), "boom"}
res = ToString(arr)
assert.Equal(t, res, "[1,2,3,\"boom\"]")
assert.Equal(t, res, "[1,2,3,4,\"boom\"]")

jsonMap := make(map[string]interface{})
jsonMap["object"] = map[string]interface{} {"foo": 1}
res = ToString(jsonMap)
Expand Down
2 changes: 2 additions & 0 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ func ToString(i interface{}) string {
return strconv.Quote(s)
case int:
return strconv.Itoa(i.(int))
case int64:
return strconv.FormatInt(i.(int64), 10)
case float64:
return strconv.FormatFloat(i.(float64), 'f', -1, 64)
case bool:
Expand Down

0 comments on commit 5cff083

Please sign in to comment.