Skip to content

Conditions with field number described but not supported #241

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

Closed
DifferentialOrange opened this issue Nov 24, 2021 · 0 comments · Fixed by #350
Closed

Conditions with field number described but not supported #241

DifferentialOrange opened this issue Nov 24, 2021 · 0 comments · Fixed by #350
Assignees
Labels
bug Something isn't working documentation Improvements or additions to documentation

Comments

@DifferentialOrange
Copy link
Member

#109 introduced a detailed guide on selects.

``CRUD`` allows to filter tuples by conditions. Each condition can use field name (or number) or index name. The first condition that uses index name is used to iterate over space. If there is no conditions that match index names, full scan is performed. Other conditions are used as additional filters. Search condition for the indexed field must be placed first to avoid a full scan.

describes field number as a valid conditions operand, but it is not.

local operand = user_condition[2]
if type(operand) ~= 'string' then
return nil, ParseConditionError:new(
"condition[2] should be string, got %q (condition %s)", type(operand), i
)
end

permits to use only string operands.

Adding a test case with field number also causes test run to fail

--- a/test/unit/parse_conditions_test.lua
+++ b/test/unit/parse_conditions_test.lua
@@ -12,6 +12,7 @@ g.test_parse = function()
         {'<=', 'dd', {1, 2, 3}},
         {'>', 'eeeeee', 666},
         {'>=', 'f', {3, 3, 4}},
+        {'==', 1, nil},
     }
 
     local conditions, err = compare_conditions.parse(user_conditions)
@@ -23,6 +24,7 @@ g.test_parse = function()
         cond_funcs.le('dd', {1, 2, 3}),
         cond_funcs.gt('eeeeee', 666),
         cond_funcs.ge('f', {3, 3, 4}),
+        cond_funcs.eq(1, nil),
     })
 end
./.rocks/bin/luatest ./test/unit/parse_conditions_test.lua 
"tuple.keydef" module is used
"tuple.merger" module is used
F..

Failed tests:
-------------

1) parse_conditions.test_parse
...hub/tarantool/crud///test/unit/parse_conditions_test.lua:19: expected: nil, actual: ParseConditionError: condition[2] should be string, got "number" (condition 7)
stack traceback:
	...opment/github/tarantool/crud/crud/compare/conditions.lua:123: in function 'parse'
	...hub/tarantool/crud///test/unit/parse_conditions_test.lua:18: in function 'method'
	...tarantool/crud/.rocks/share/tarantool/luatest/runner.lua:339: in function <...tarantool/crud/.rocks/share/tarantool/luatest/runner.lua:338>
	[C]: in function 'xpcall'
	...tarantool/crud/.rocks/share/tarantool/luatest/runner.lua:338: in function 'super'
	...antool/crud/.rocks/share/tarantool/luatest/capturing.lua:106: in function 'protected_call'
	...tarantool/crud/.rocks/share/tarantool/luatest/runner.lua:400: in function 'super'
	.../tarantool/crud/.rocks/share/tarantool/luatest/hooks.lua:175: in function 'invoke_test_function'
	...tarantool/crud/.rocks/share/tarantool/luatest/runner.lua:395: in function 'super'
	...antool/crud/.rocks/share/tarantool/luatest/capturing.lua:124: in function 'run_test'
	...
	[C]: in function 'xpcall'
	.../tarantool/crud/.rocks/share/tarantool/luatest/utils.lua:37: in function 'run_tests'
	...tarantool/crud/.rocks/share/tarantool/luatest/runner.lua:257: in function <...tarantool/crud/.rocks/share/tarantool/luatest/runner.lua:253>
	[C]: in function 'xpcall'
	...antool/crud/.rocks/share/tarantool/luatest/capturing.lua:74: in function <...antool/crud/.rocks/share/tarantool/luatest/capturing.lua:72>
	[C]: in function 'xpcall'
	...tarantool/crud/.rocks/share/tarantool/luatest/runner.lua:49: in function 'fn'
	...crud/.rocks/share/tarantool/luatest/sandboxed_runner.lua:14: in function 'run'
	...l/crud/.rocks/share/tarantool/luatest/cli_entrypoint.lua:4: in function <...l/crud/.rocks/share/tarantool/luatest/cli_entrypoint.lua:3>
	....rocks/share/tarantool/rocks/luatest/0.5.5-1/bin/luatest:3: in main chunk
@DifferentialOrange DifferentialOrange added bug Something isn't working documentation Improvements or additions to documentation labels Nov 24, 2021
@DifferentialOrange DifferentialOrange self-assigned this Mar 21, 2023
DifferentialOrange added a commit that referenced this issue Mar 21, 2023
DifferentialOrange added a commit that referenced this issue Mar 22, 2023
DifferentialOrange added a commit that referenced this issue Mar 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants