From 522f9e0ab0330bb179919a7e89ff2f8e079858e1 Mon Sep 17 00:00:00 2001 From: Gani Georgiev Date: Wed, 2 Sep 2026 10:47:49 +0300 Subject: [PATCH] fixed index parsing error when no index name is provided --- CHANGELOG.md | 2 ++ tools/dbutils/index.go | 7 ++++--- tools/dbutils/index_test.go | 9 +++++++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 11390847..f47da378 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ - Minor UI autocomplete optimizations. +- Fixed harmless index parsing error when no index name is provided. + ## v0.40.1 diff --git a/tools/dbutils/index.go b/tools/dbutils/index.go index d71098fd..7ed02610 100644 --- a/tools/dbutils/index.go +++ b/tools/dbutils/index.go @@ -148,11 +148,12 @@ func ParseIndex(createIndexExpr string) Index { nameTk.Separators('.') nameParts, _ := nameTk.ScanAll() - if len(nameParts) == 2 { + switch len(nameParts) { + case 1: + result.IndexName = strings.Trim(nameParts[0], trimChars) + case 2: result.SchemaName = strings.Trim(nameParts[0], trimChars) result.IndexName = strings.Trim(nameParts[1], trimChars) - } else { - result.IndexName = strings.Trim(nameParts[0], trimChars) } // TableName diff --git a/tools/dbutils/index_test.go b/tools/dbutils/index_test.go index 895d35c6..2e3452ff 100644 --- a/tools/dbutils/index_test.go +++ b/tools/dbutils/index_test.go @@ -20,6 +20,15 @@ func TestParseIndex(t *testing.T) { `invalid`, dbutils.Index{}, }, + // no names + { + `create index on ()`, + dbutils.Index{ + IndexName: "", + TableName: "", + Columns: []dbutils.IndexColumn{}, + }, + }, // simple (multiple spaces between the table and columns list) { `create index indexname on tablename (col1)`,