This repository was archived by the owner on Aug 2, 2022. It is now read-only.
Repository navigation
fixed cleos get_kv_table_rows bugs - #9595
Merged
Merged
Conversation
linhuang-blockone
approved these changes
Oct 23, 2020
| EOS_ASSERT(has_lower_bound && has_upper_bound, chain::contract_table_query_exception, "Unknown range: ${t} ${i}", ("t", p.table)("i", p.index_name)); | ||
| unbounded = !has_lower_bound || !has_upper_bound; | ||
| // reverse mode has upper_bound value, non-reverse and point query has lower bound value | ||
| EOS_ASSERT((p.reverse && has_upper_bound) || (!p.reverse && has_lower_bound) || (has_lower_bound && point_query), chain::contract_table_query_exception, "Unknown/Invalid range: ${t} ${i}", ("t", p.table)("i", p.index_name)); |
Contributor
There was a problem hiding this comment.
Maybe you can change (!p.reverse && has_lower_bound) || (has_lower_bound && point_query) to (!p.reverse || point_query) && has_lower_bound) to match the comment and be consistent with (p.reverse && has_upper_bound)
| @@ -33,10 +33,10 @@ using namespace eosio::chain; | |||
| using namespace eosio::testing; | |||
| using namespace fc; | |||
|
|
|||
Contributor
There was a problem hiding this comment.
Why not this file in unittests directory? I thought test directory was for integration testing and they were all python files.
1 of 7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change Description
Fixed get_kv_table_rows bugs:
-Made upper_bound optional when reverse option is not set
-Made lower_bound optional when reverse option is set
-Fixed when upper_bound value is not found, the iterator points to end value
-Changed --index can return multiple rows
-Changed next_key format to hex string so that the next call can be called easily using "--encode-type bytes"
-Replaced -k option with -i and --index in order to be in sync with get_table_rows
Change Type
Select ONE
Consensus Changes
API Changes
cleos
-k option removed
-i, --input added.
Positionals:
account TEXT REQUIRED The account who owns the table
table TEXT REQUIRED The name of the kv_table as specified by the contract abi
index_name TEXT REQUIRED The name of the kv_table index as specified by the contract abi
Options:
-h,--help Print this help message and exit
-l,--limit UINT The maximum number of rows to return
-i,--index TEXT Index value
-L,--lower TEXT JSON representation of lower bound value of key, defaults to first
-U,--upper TEXT JSON representation of upper bound value of key, defaults to last
--encode-type TEXT The encoding type of index_value, lower bound, upper bound 'bytes' for hexdecimal encoded bytes 'string' for string value 'dec' for decimal encoding of (uint[64|32|16|8], int[64|32|16|8], float64) 'hex' for hexdecimal encoding of (uint[64|32|16|8], int[64|32|16|8], sha256, ripemd160
-b,--binary Return the value as BINARY rather than using abi to interpret as JSON
-r,--reverse Iterate in reverse order
--show-payer Show RAM payer
Documentation Additions
When --reverse option is not set, --upper is optional, If --upper is not set, the result includes the end of the matching rows.
When --reverse option is set , --lower is optional, if --lower is not set, the result includes the begning of the matchin rows.
-k is replaced by -i/--input option to be in sync. with get_table_rows() call
When result has more = true and next_key is set, the following call to get_kv_table_rows should set --encode-type bytes and
set the next_key value to index or lower/upper value.
When --index is used to search non unique secondary index, result can return multiple rows.