diff --git a/.gitignore b/.gitignore index 10e8d7ac..c3543d09 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ vendor go.sum +.idea \ No newline at end of file diff --git a/rawkv/rawkv.go b/rawkv/rawkv.go index 9d32b3b2..368b5783 100644 --- a/rawkv/rawkv.go +++ b/rawkv/rawkv.go @@ -263,7 +263,7 @@ func (c *Client) Scan(ctx context.Context, startKey, endKey []byte, limit int) ( return nil, nil, errors.WithStack(ErrMaxScanLimitExceeded) } - for len(keys) < limit { + for len(keys) < limit && (len(endKey) == 0 || bytes.Compare(startKey, endKey) < 0) { req := &rpc.Request{ Type: rpc.CmdRawScan, RawScan: &kvrpcpb.RawScanRequest{ @@ -307,7 +307,7 @@ func (c *Client) ReverseScan(ctx context.Context, startKey, endKey []byte, limit return nil, nil, errors.WithStack(ErrMaxScanLimitExceeded) } - for len(keys) < limit { + for len(keys) < limit && bytes.Compare(startKey, endKey) > 0 { req := &rpc.Request{ Type: rpc.CmdRawScan, RawScan: &kvrpcpb.RawScanRequest{