fixed index parsing error when no index name is provided

This commit is contained in:
Gani Georgiev
2026-09-02 10:48:24 +03:00
parent 3c9427667d
commit 522f9e0ab0
3 changed files with 15 additions and 3 deletions
+2
View File
@@ -4,6 +4,8 @@
- Minor UI autocomplete optimizations. - Minor UI autocomplete optimizations.
- Fixed harmless index parsing error when no index name is provided.
## v0.40.1 ## v0.40.1
+4 -3
View File
@@ -148,11 +148,12 @@ func ParseIndex(createIndexExpr string) Index {
nameTk.Separators('.') nameTk.Separators('.')
nameParts, _ := nameTk.ScanAll() 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.SchemaName = strings.Trim(nameParts[0], trimChars)
result.IndexName = strings.Trim(nameParts[1], trimChars) result.IndexName = strings.Trim(nameParts[1], trimChars)
} else {
result.IndexName = strings.Trim(nameParts[0], trimChars)
} }
// TableName // TableName
+9
View File
@@ -20,6 +20,15 @@ func TestParseIndex(t *testing.T) {
`invalid`, `invalid`,
dbutils.Index{}, dbutils.Index{},
}, },
// no names
{
`create index on ()`,
dbutils.Index{
IndexName: "",
TableName: "",
Columns: []dbutils.IndexColumn{},
},
},
// simple (multiple spaces between the table and columns list) // simple (multiple spaces between the table and columns list)
{ {
`create index indexname on tablename (col1)`, `create index indexname on tablename (col1)`,