summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorHarel Ben-Attia <harelba@gmail.com>2015-12-08 10:33:58 +0200
committerHarel Ben-Attia <harelba@gmail.com>2015-12-08 10:33:58 +0200
commit9167ea05fb56c878c33684e52c842c7ff59c42a2 (patch)
treeabb041259c194832a6ab31d912e9f24c3c6df48f /bin
parent55d062b61a5b84ff8bc1ca883c452628afa417d3 (diff)
Fixed bug in escaping double-quotes (#115) + #116
Diffstat (limited to 'bin')
-rwxr-xr-xbin/q15
1 files changed, 11 insertions, 4 deletions
diff --git a/bin/q b/bin/q
index 3c09901..f9fdab4 100755
--- a/bin/q
+++ b/bin/q
@@ -1271,6 +1271,10 @@ class QTextAsData(object):
return q_output
+def escape_double_quotes_if_needed(v):
+ x = v.replace('"','""')
+ return x
+
def quote_none_func(output_delimiter,v):
return v
@@ -1278,19 +1282,22 @@ def quote_minimal_func(output_delimiter,v):
if v is None:
return v
t = type(v)
- if t == str or t == unicode and output_delimiter in v:
- return '"%s"' % (v)
+ if t == str or t == unicode and ((output_delimiter in v) or ('"' in v)):
+ return '"%s"' % (escape_double_quotes_if_needed(v))
return v;
def quote_nonnumeric_func(output_delimiter,v):
if v is None:
return v
if type(v) == str or type(v) == unicode:
- return '"%s"' % (v)
+ return '"%s"' % (escape_double_quotes_if_needed(v))
return v;
def quote_all_func(output_delimiter,v):
- return '"%s"' % (v)
+ if type(v) == str or type(v) == unicode:
+ return '"%s"' % (escape_double_quotes_if_needed(v))
+ else:
+ return '"%s"' % v
class QOutputParams(object):
def __init__(self,