From e792fd52204da89b86d77e088ddb4ac0edff927f Mon Sep 17 00:00:00 2001 From: Asdine El Hrychy Date: Sun, 27 Oct 2019 18:27:36 +0100 Subject: [PATCH] Use fieldname as key for the index map --- db.go | 2 +- db_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) 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) })