diff --git a/consul/mdb_table.go b/consul/mdb_table.go index 53c85d7cf3..592bce849a 100644 --- a/consul/mdb_table.go +++ b/consul/mdb_table.go @@ -427,6 +427,10 @@ func (t *MDBTable) getIndex(index string, parts []string) (*MDBIndex, []byte, er return nil, nil, tooManyFields } + if idx.CaseInsensitive { + parts = ToLowerList(parts) + } + // Construct the key key := idx.keyFromParts(parts...) return idx, key, nil @@ -614,6 +618,9 @@ func (i *MDBIndex) keyFromObject(obj interface{}) ([]byte, error) { if !i.AllowBlank && val == "" { return nil, fmt.Errorf("Field '%s' must be set: %#v", field, obj) } + if i.CaseInsensitive { + val = strings.ToLower(val) + } parts = append(parts, val) } key := i.keyFromParts(parts...)