Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix: normal view (#13328)

Danny Xu2e01906526ee
diff --git a/backend/api/v1/branch_merge.go b/backend/api/v1/branch_merge.go
index f1b1cc0e3d..dcf3b0d66c 100644
--- a/backend/api/v1/branch_merge.go
+++ b/backend/api/v1/branch_merge.go
@@ -1256,7 +1256,7 @@ func equalViewDefinition(a, b string) bool {
return strings.EqualFold(a, b)
}
-var qualifiedRe = regexp.MustCompile("`" + `[^` + "`" + `]` + "`" + `\.` + "`")
+var qualifiedRe = regexp.MustCompile("`" + `[^` + "`" + `]+` + "`" + `\.` + "`")
func normalizeMySQLViewDefinition(query string) string {
query = strings.TrimSpace(query)
diff --git a/backend/api/v1/branch_merge_test.go b/backend/api/v1/branch_merge_test.go
index 4512dc89ad..a34cd65085 100644
--- a/backend/api/v1/branch_merge_test.go
+++ b/backend/api/v1/branch_merge_test.go
@@ -96,6 +96,10 @@ func TestNormalizeMySQLViewDefinition(t *testing.T) {
query: "select 12 AS `12`; ",
want: "select 12;",
},
+ {
+ query: "select `t1`.`id` AS `id` from `t1`;",
+ want: "select `id` from `t1`;",
+ },
} {
got := normalizeMySQLViewDefinition(test.query)
require.Equal(t, test.want, got, i)