Skip to content

Commit 8e90853

Browse files
committed
Unquote backticks in identifiers for sqlite
1 parent 6389cdc commit 8e90853

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

internal/engine/sqlite/catalog_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,23 @@ func TestUpdate(t *testing.T) {
230230
},
231231
},
232232
},
233+
{
234+
"CREATE TABLE `foo` (`bar` text);",
235+
&catalog.Schema{
236+
Name: "main",
237+
Tables: []*catalog.Table{
238+
{
239+
Rel: &ast.TableName{Name: "foo"},
240+
Columns: []*catalog.Column{
241+
{
242+
Name: "bar",
243+
Type: ast.TypeName{Name: "text"},
244+
},
245+
},
246+
},
247+
},
248+
},
249+
},
233250
} {
234251
test := tc
235252
t.Run(strconv.Itoa(i), func(t *testing.T) {

internal/engine/sqlite/convert.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func todo(funcname string, n node) *ast.TODO {
2828
}
2929

3030
func identifier(id string) string {
31-
if len(id) >= 2 && id[0] == '"' && id[len(id)-1] == '"' {
31+
if len(id) >= 2 && (id[0] == '"' && id[len(id)-1] == '"' || id[0] == '`' && id[len(id)-1] == '`') {
3232
unquoted, _ := strconv.Unquote(id)
3333
return unquoted
3434
}

0 commit comments

Comments
 (0)