Skip to content

Commit

Permalink
Use fieldname as key for the index map
Browse files Browse the repository at this point in the history
  • Loading branch information
asdine committed Oct 27, 2019
1 parent 50a6a6a commit e792fd5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion db.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down

0 comments on commit e792fd5

Please sign in to comment.