don't return false positives when searching for a prefix of a tag value (#2919)

Fixes #2908
This commit is contained in:
Anton Kaliaev
2018-11-27 17:12:28 +04:00
committed by Ethan Buchman
parent bef39f3346
commit 92dc5fc77a
3 changed files with 5 additions and 2 deletions

View File

@@ -37,6 +37,7 @@ program](https://hackerone.com/tendermint).
- [blockchain] \#2731 Retry both blocks if either is bad to avoid getting stuck during fast sync (@goolAdapter)
- [log] \#2868 fix module=main setting overriding all others
- [rpc] \#2808 RPC validators calls IncrementAccum if necessary
- [kv indexer] \#2908 don't return false positives when searching for a prefix of a tag value
- [kv indexer] \#2775 order results by index if height is the same
- [rpc] \#2759 fix tx.height range queries
- [rpc] \#2811 Allow integer IDs in JSON-RPC requests

View File

@@ -412,9 +412,9 @@ LOOP:
func startKey(c query.Condition, height int64) []byte {
var key string
if height > 0 {
key = fmt.Sprintf("%s/%v/%d", c.Tag, c.Operand, height)
key = fmt.Sprintf("%s/%v/%d/", c.Tag, c.Operand, height)
} else {
key = fmt.Sprintf("%s/%v", c.Tag, c.Operand)
key = fmt.Sprintf("%s/%v/", c.Tag, c.Operand)
}
return []byte(key)
}

View File

@@ -73,6 +73,8 @@ func TestTxSearch(t *testing.T) {
{"account.number = 1 AND account.owner = 'Ivan'", 1},
// search by exact match (two tags)
{"account.number = 1 AND account.owner = 'Vlad'", 0},
// search using a prefix of the stored value
{"account.owner = 'Iv'", 0},
// search by range
{"account.number >= 1 AND account.number <= 5", 1},
// search by range (lower bound)