Skip to content

Commit 9524b31

Browse files
support quote strings (#125)
* update util.py file * add test Co-authored-by: Guy Korland <gkorland@gmail.com>
1 parent 63d3fe3 commit 9524b31

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

redisgraph/util.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,4 @@ def quote_string(v):
2727

2828
v = v.replace('"', '\\"')
2929

30-
if v[0] != '"':
31-
v = '"' + v
32-
33-
if v[-1] != '"':
34-
v = v + '"'
35-
36-
return v
30+
return '"{}"'.format(v)

tests/unit/test_util.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,6 @@ def test_quote_string(self):
1414
self.assertEqual(util.quote_string(10), 10)
1515
self.assertEqual(util.quote_string("abc"), '"abc"')
1616
self.assertEqual(util.quote_string(""), '""')
17+
self.assertEqual(util.quote_string('\"'), '"\\\""')
18+
self.assertEqual(util.quote_string('"'), '"\\""')
1719
self.assertEqual(util.quote_string('a"a'), '"a\\"a"')

0 commit comments

Comments
 (0)