fix(orm): fix failing tests (#16023)

This commit is contained in:
Aaron Craelius
2023-05-04 15:26:57 +00:00
committed by GitHub
parent 96730a5f2b
commit b0c6941deb
7 changed files with 216 additions and 78 deletions
+3 -4
View File
@@ -247,20 +247,19 @@ func (cdc KeyCodec) CheckValidRangeIterationKeys(start, end []protoreflect.Value
y := end[i]
cmp = fieldCdc.Compare(x, y)
switch {
case cmp > 0:
if cmp > 0 {
return ormerrors.InvalidRangeIterationKeys.Wrapf(
"start must be before end for field %s",
cdc.fieldDescriptors[i].FullName(),
)
case !fieldCdc.IsOrdered() && cmp != 0:
} else if !fieldCdc.IsOrdered() && cmp != 0 {
descriptor := cdc.fieldDescriptors[i]
return ormerrors.InvalidRangeIterationKeys.Wrapf(
"field %s of kind %s doesn't support ordered range iteration",
descriptor.FullName(),
descriptor.Kind(),
)
case cmp < 0:
} else if cmp < 0 {
break
}
}
+2 -3
View File
@@ -160,9 +160,8 @@ func (u UniqueKeyCodec) EncodeEntry(entry Entry) (k, v []byte, err error) {
if !fieldOrder.inKey {
// goes in values because it is not present in the index key otherwise
values = append(values, value)
}
// does not go in values, but we need to verify that the value in index values matches the primary key value
if u.keyCodec.fieldCodecs[fieldOrder.i].Compare(value, indexEntry.IndexValues[fieldOrder.i]) != 0 {
} else if u.keyCodec.fieldCodecs[fieldOrder.i].Compare(value, indexEntry.IndexValues[fieldOrder.i]) != 0 {
// does not go in values, but we need to verify that the value in index values matches the primary key value
return nil, nil, ormerrors.BadDecodeEntry.Wrapf("value in primary key does not match corresponding value in index key")
}
}