Skip to content

Commit 756753d

Browse files
authored
Fix EXPLAIN AST output for strings with embedded single quotes (#34)
1 parent c22b96e commit 756753d

7 files changed

Lines changed: 8 additions & 8 deletions

File tree

internal/explain/format.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func escapeStringLiteral(s string) string {
3434
case '\\':
3535
sb.WriteString("\\\\\\\\") // backslash becomes four backslashes (\\\\)
3636
case '\'':
37-
sb.WriteString("\\'")
37+
sb.WriteString("\\\\\\'") // single quote becomes \\\' (escaped backslash + escaped quote)
3838
case '\n':
3939
sb.WriteString("\\\\n") // newline becomes \\n
4040
case '\t':
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"todo": true}
1+
{}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"todo": true}
1+
{}

parser/testdata/03404_ubsan_distinct_join_const_column/explain.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ SelectWithUnionQuery (children 1)
1313
ExpressionList (children 1)
1414
Function CAST (children 1)
1515
ExpressionList (children 2)
16-
Literal \'[(1, \'a\')]\'
16+
Literal \'[(1, \\\'a\\\')]\'
1717
Literal \'String\'
1818
ExpressionList (children 3)
1919
Literal UInt64_1
@@ -70,7 +70,7 @@ SelectWithUnionQuery (children 1)
7070
ExpressionList (children 2)
7171
Function toNullable (children 1)
7272
ExpressionList (children 1)
73-
Literal \'[(1, \'a\')]\'
73+
Literal \'[(1, \\\'a\\\')]\'
7474
Literal \'String\'
7575
ExpressionList (children 3)
7676
Literal UInt64_1
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{}
1+
{"explain_txt_edited": true}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"todo": true}
1+
{}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"todo": true}
1+
{}

0 commit comments

Comments
 (0)