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
+4 -3
View File
@@ -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
+9
View File
@@ -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)`,