refactor: remove directive errors comparison (#20344)
This commit is contained in:
@@ -2,6 +2,7 @@ package ormkv
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"io"
|
||||
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
@@ -64,7 +65,7 @@ func NewIndexKeyCodec(prefix []byte, messageType protoreflect.MessageType, index
|
||||
func (cdc IndexKeyCodec) DecodeIndexKey(k, _ []byte) (indexFields, primaryKey []protoreflect.Value, err error) {
|
||||
values, err := cdc.DecodeKey(bytes.NewReader(k))
|
||||
// got prefix key
|
||||
if err == io.EOF {
|
||||
if errors.Is(err, io.EOF) {
|
||||
return values, nil, nil
|
||||
} else if err != nil {
|
||||
return nil, nil, err
|
||||
|
||||
@@ -2,6 +2,7 @@ package ormkv
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"io"
|
||||
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
@@ -122,7 +123,7 @@ func (cdc *KeyCodec) DecodeKey(r *bytes.Reader) ([]protoreflect.Value, error) {
|
||||
values := make([]protoreflect.Value, 0, n)
|
||||
for i := 0; i < n; i++ {
|
||||
value, err := cdc.fieldCodecs[i].Decode(r)
|
||||
if err == io.EOF {
|
||||
if errors.Is(err, io.EOF) {
|
||||
return values, err
|
||||
} else if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -2,6 +2,7 @@ package ormkv
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"io"
|
||||
|
||||
"google.golang.org/protobuf/proto"
|
||||
@@ -38,7 +39,7 @@ func (p PrimaryKeyCodec) DecodeIndexKey(k, _ []byte) (indexFields, primaryKey []
|
||||
indexFields, err = p.DecodeKey(bytes.NewReader(k))
|
||||
|
||||
// got prefix key
|
||||
if err == io.EOF {
|
||||
if errors.Is(err, io.EOF) {
|
||||
return indexFields, nil, nil
|
||||
} else if err != nil {
|
||||
return nil, nil, err
|
||||
@@ -54,7 +55,7 @@ func (p PrimaryKeyCodec) DecodeIndexKey(k, _ []byte) (indexFields, primaryKey []
|
||||
|
||||
func (p PrimaryKeyCodec) DecodeEntry(k, v []byte) (Entry, error) {
|
||||
values, err := p.DecodeKey(bytes.NewReader(k))
|
||||
if err == io.EOF {
|
||||
if errors.Is(err, io.EOF) {
|
||||
return &PrimaryKeyEntry{
|
||||
TableName: p.messageType.Descriptor().FullName(),
|
||||
Key: values,
|
||||
|
||||
@@ -2,6 +2,7 @@ package ormkv
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"io"
|
||||
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
@@ -87,7 +88,7 @@ func (u UniqueKeyCodec) DecodeIndexKey(k, v []byte) (indexFields, primaryKey []p
|
||||
ks, err := u.keyCodec.DecodeKey(bytes.NewReader(k))
|
||||
|
||||
// got prefix key
|
||||
if err == io.EOF {
|
||||
if errors.Is(err, io.EOF) {
|
||||
return ks, nil, err
|
||||
} else if err != nil {
|
||||
return nil, nil, err
|
||||
|
||||
Reference in New Issue
Block a user