Skip to content

Conditions with field number described but not supported #241

Closed
@DifferentialOrange

Description

@DifferentialOrange

#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

Metadata

Metadata

Labels

bugSomething isn't workingdocumentationImprovements or additions to documentation

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions