瀏覽代碼

namespace: prefix comparison range_end

Anthony Romano 8 年之前
父節點
當前提交
7ff6e62c56
共有 1 個文件被更改,包括 4 次插入1 次删除
  1. 4 1
      clientv3/namespace/kv.go

+ 4 - 1
clientv3/namespace/kv.go

@@ -105,8 +105,11 @@ func (txn *txnPrefix) If(cs ...clientv3.Cmp) clientv3.Txn {
 	newCmps := make([]clientv3.Cmp, len(cs))
 	newCmps := make([]clientv3.Cmp, len(cs))
 	for i := range cs {
 	for i := range cs {
 		newCmps[i] = cs[i]
 		newCmps[i] = cs[i]
-		pfxKey, _ := txn.kv.prefixInterval(cs[i].KeyBytes(), nil)
+		pfxKey, endKey := txn.kv.prefixInterval(cs[i].KeyBytes(), cs[i].RangeEnd)
 		newCmps[i].WithKeyBytes(pfxKey)
 		newCmps[i].WithKeyBytes(pfxKey)
+		if len(cs[i].RangeEnd) != 0 {
+			newCmps[i].RangeEnd = endKey
+		}
 	}
 	}
 	txn.Txn = txn.Txn.If(newCmps...)
 	txn.Txn = txn.Txn.If(newCmps...)
 	return txn
 	return txn