crud icon indicating copy to clipboard operation
crud copied to clipboard

Fetching nested structures in tuple fields

Open AnaNek opened this issue 4 years ago • 4 comments

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

AnaNek avatar Feb 17 '21 11:02 AnaNek

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?

Totktonada avatar Sep 27 '21 08:09 Totktonada

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.

olegrok avatar Sep 27 '21 15:09 olegrok

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.

Totktonada avatar Jun 25 '22 13:06 Totktonada

Blocked by https://github.com/tarantool/tarantool/issues/5203

DifferentialOrange avatar Jul 21 '23 08:07 DifferentialOrange