mirror of
https://github.com/pocketbase/pocketbase.git
synced 2026-09-08 15:41:18 +02:00
fixed index parsing error when no index name is provided
This commit is contained in:
@@ -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
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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)`,
|
||||||
|
|||||||
Reference in New Issue
Block a user