RedisGraph / redisgraph-go

A Golang client for redisgraph
https://redisgraph.io
BSD 3-Clause "New" or "Revised" License
132 stars 38 forks source link

List/Map types not supported in properties #30

Closed sankarvj closed 3 years ago

sankarvj commented 4 years ago

version : v2.0.2

issue: I'm not able to add list/map types as the property value.

example:

       japan := rg.Node{
        Label: "country",
        Properties: map[string]interface{}{
            "name":   "Japan",
            "states": []string{"Kanto", "Chugoku"},
        },
    }

error:

Unrecognized type to convert to string

the following block in utils.go throws the error during the properties encoding.

    switch i.(type) {
    case string:
        s := i.(string)
        return strconv.Quote(s)
    case int:
        return strconv.Itoa(i.(int))
    case float64:
        return strconv.FormatFloat(i.(float64), 'f', -1, 64)
    case bool:
        return strconv.FormatBool(i.(bool))
    case []interface {}:
        arr := i.([]interface{})
        return arrayToString(arr)
    default:
        panic("Unrecognized type to convert to string")
    }

Since the list/map is working via the Redis-CLI. I suspect this as a client library bug.

lorantpapp commented 3 years ago

Hi,

Is there any fix available for this bug? Specially interested in the fix after learning that starting from Redis graph 2.4 map datatypes are supported: "introducing map datatype #1514", https://github.com/RedisGraph/RedisGraph/pull/1514.

BR Lorant

filipecosta90 commented 3 years ago

reopening due to the requirement of supporting []string. map support has already been addressed by @AvitalFineRedis on #47