From 8e9085335830c57be1da1248b3df51ce047e6bb1 Mon Sep 17 00:00:00 2001 From: Joeri Aben Date: Wed, 1 Oct 2025 23:45:20 +0200 Subject: [PATCH] Unquote backticks in identifiers for sqlite --- internal/engine/sqlite/catalog_test.go | 17 +++++++++++++++++ internal/engine/sqlite/convert.go | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/internal/engine/sqlite/catalog_test.go b/internal/engine/sqlite/catalog_test.go index bf6dcd8316..0b1cff715f 100644 --- a/internal/engine/sqlite/catalog_test.go +++ b/internal/engine/sqlite/catalog_test.go @@ -230,6 +230,23 @@ func TestUpdate(t *testing.T) { }, }, }, + { + "CREATE TABLE `foo` (`bar` text);", + &catalog.Schema{ + Name: "main", + Tables: []*catalog.Table{ + { + Rel: &ast.TableName{Name: "foo"}, + Columns: []*catalog.Column{ + { + Name: "bar", + Type: ast.TypeName{Name: "text"}, + }, + }, + }, + }, + }, + }, } { test := tc t.Run(strconv.Itoa(i), func(t *testing.T) { diff --git a/internal/engine/sqlite/convert.go b/internal/engine/sqlite/convert.go index 658a9d7f33..74c9b92190 100644 --- a/internal/engine/sqlite/convert.go +++ b/internal/engine/sqlite/convert.go @@ -28,7 +28,7 @@ func todo(funcname string, n node) *ast.TODO { } func identifier(id string) string { - if len(id) >= 2 && id[0] == '"' && id[len(id)-1] == '"' { + if len(id) >= 2 && (id[0] == '"' && id[len(id)-1] == '"' || id[0] == '`' && id[len(id)-1] == '`') { unquoted, _ := strconv.Unquote(id) return unquoted }