Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

json path schema issue, test lies or bug #5673

Closed
R-omk opened this issue Dec 30, 2020 · 3 comments
Closed

json path schema issue, test lies or bug #5673

R-omk opened this issue Dec 30, 2020 · 3 comments

Comments

@R-omk
Copy link

R-omk commented Dec 30, 2020

Tarantool version: 2.5.2 (2.1 +)

Bug description:

https://github.com/tarantool/tarantool/blob/2.5.2/test/engine/tuple.test.lua#L229-L233

first: the string contains a typo

format[5] = {name = "[2][6]['привет中国world']['中国a']", type = 'string'}  --- actual 
format[5] = {name = "[2][6]['привет中国world']['中国']", type = 'string'}  --- must be 

second:

in fact, the above type does not affect the nested document in filed2, but the raw field in tuple at number 5

-- this works even though changed the string to a number (after fix typo in format )
field2 = {1, 2, 3, "4", {5,6,7}, {привет中国world={中国=9}, key="value1", value="key1"}}  
t = s:replace{1, field2, field3, "123456", "yes, this", {key = 100}}  
-- this does not work because the format actually affects the type in the other field
field2 = {1, 2, 3, "4", {5,6,7}, {привет中国world={中国=9}, key="value1", value="key1"}}  
t = s:replace{1, field2, field3, "123456", 9, {key = 100}}  

doc:
https://github.com/tarantool/doc/blame/2.5/doc/reference/reference_lua/box_tuple.rst#L318

@Gerold103
Copy link
Collaborator

Thanks for the feedback.

first: the string contains a typo

Why do you think it is a typo? The name is correct. It is used in the test later. Line 256 in tuple.test.lua.

in fact, the above type does not affect the nested document in filed2, but the raw field in tuple at number 5

Yes, like it should. It is stored as a fifth field of the format: format[5] = .... Not second field. The string in the name key of the format field is just a string, even if it looks like a JSON path with [2] in the beginning. The test is about checking that if there is a field whose name looks exactly like a JSON path, it is treated as a name. It is done on the line 256 in tuple.test.lua.

As for the documentation link you attached, I am not sure I follow what it changes. It shows that you can 1) define fields with names which look like JSON paths, 2) when you use a JSON path in a tuple field access and there is no a field name matching it exactly, it is treated as a real JSON path. Both points are correct.

@Gerold103 Gerold103 added the needs feedback Something is unclear with the issue label Jul 22, 2021
@R-omk
Copy link
Author

R-omk commented Jul 22, 2021

The example from the documentation completely confused me and I got it all wrong.
It seemed to me that there should be some meaning in such a field name, but this is just a string scalar copy pasted from the test.

@Gerold103
Copy link
Collaborator

Feel free to open a ticket in doc/ repository to make them use better examples.

@Gerold103 Gerold103 added invalid and removed needs feedback Something is unclear with the issue labels Jul 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants