diff --git a/db.go b/db.go index e3e5a55a4..fd534d314 100644 --- a/db.go +++ b/db.go @@ -636,7 +636,7 @@ func (t Table) Indexes() (map[string]Index, error) { return err } - indexes[opt.IndexName] = Index{ + indexes[opt.FieldName] = Index{ Index: index.New(s, index.Options{Unique: opt.Unique}), IndexName: opt.IndexName, TableName: opt.TableName, diff --git a/db_test.go b/db_test.go index c7e3b4218..3bd94ebee 100644 --- a/db_test.go +++ b/db_test.go @@ -595,10 +595,10 @@ func TestTableIndexes(t *testing.T) { m, err := tb.Indexes() require.NoError(t, err) require.Len(t, m, 2) - idx1a, ok := m["idx1a"] + idx1a, ok := m["a"] require.True(t, ok) require.NotNil(t, idx1a) - idx1b, ok := m["idx1a"] + idx1b, ok := m["b"] require.True(t, ok) require.NotNil(t, idx1b) })