Skip to content

Commit

Permalink
AddProperty doesn't work if you have "s in the string. (#9)
Browse files Browse the repository at this point in the history
@brugnara AddProperty doesn't work if you have `"`s in the string.
  • Loading branch information
damienstamates authored Dec 12, 2019
2 parents 65ff4bf + beb59d4 commit 4d6ca11
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions query/traversal/addproperty.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@

package traversal

import "github.com/northwesternmutual/grammes/query/cardinality"
import (
"strings"

"github.com/northwesternmutual/grammes/query/cardinality"
)

// http://tinkerpop.apache.org/docs/current/reference/#addproperty-step

Expand All @@ -47,7 +51,7 @@ func (g String) Property(objOrCard interface{}, obj interface{}, params ...inter

switch obj.(type) {
case string:
g = g.append(",\"" + obj.(string) + "\"")
g = g.append(",\"" + strings.ReplaceAll(obj.(string), "\"", "\\\"") + "\"")
default:
g = g.append(fmtStr(",%v", obj))
}
Expand All @@ -56,7 +60,7 @@ func (g String) Property(objOrCard interface{}, obj interface{}, params ...inter
for _, p := range params {
switch obj.(type) {
case string:
g = g.append(",\"" + p.(string) + "\"")
g = g.append(",\"" + strings.ReplaceAll(p.(string), "\"", "\\\"") + "\"")
default:
g = g.append(fmtStr(",%v", p))
}
Expand Down

0 comments on commit 4d6ca11

Please sign in to comment.