crud
crud copied to clipboard
Fetching nested structures in tuple fields
What about "bad input" tests? What if user specified some bad field name?
I believe that we should do as Tarantool does:
tarantool> box.tuple.new({1, {a = {b = 'c'}}})
---
- [1, {'a': {'b': 'c'}}]
...
tarantool> box.tuple.new({1, {a = {b = 'c'}}})['[1]']
---
- 1
...
tarantool> box.tuple.new({1, {a = {b = 'c'}}})['[2]']
---
- {'a': {'b': 'c'}}
...
tarantool> box.tuple.new({1, {a = {b = 'c'}}})['[2].a.b']
---
- c
...
tarantool> box.tuple.new({1, {a = {b = 'c'}}})['K']
---
- null
...
This makes this feature quite powerful and allows to fetch not only some tuple fields but some nested structures in tuple fields.
Originally posted by @olegrok in https://github.com/tarantool/crud/pull/118#discussion_r576381992
Am I understood right: the proposal is to support JSON path in fields option of crud operations and in crud.cut_rows() and crud.cut_objects() function?
the proposal is to support JSON path in fields option of crud operations
Yes
in crud.cut_rows() and crud.cut_objects() function
Initially there are no such functions in public API. However since currently it's so it should be done for consistency.
It's hard to evaluate, but I don't hear requests about this feature from customers, the product team or project developers (except @olegrok). I guess that the demain is small.
The implementation would either depend on https://github.com/tarantool/tarantool/issues/5203 (which is not implemented at the moment of writing) or would use an external module like https://github.com/olegrok/tarantool-jsonpath (which has pros and cons).
I'll put the task to the wishlist. It means that if someone is ready to work on it, we're open for design discussions (let's start them here) and pull requests. Of course, we can accept the implementation only if it is carefully designed, implemented, documented and tested.
The priority may raise in a future, if something important will depend on the feature.
Blocked by https://github.com/tarantool/tarantool/issues/5203