Skip to content

Commit aba6f9d

Browse files
authored
Select with not valid value error handing (#64)
Before this patch we incorrectly created errors objects instead of errors classes. This led to "attempt to call method 'new'" when select returned an error. This patch fixes such behaviour and creates error classes. Closes #61
1 parent e5eb7ca commit aba6f9d

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
99

1010
### Fixed
1111
* Select by primary index name
12+
* Fix error handling select with invalid type value
1213

1314
## [0.2.0] - 2020-10-07
1415

crud/select/iterator.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ local fiber = require('fiber')
44
local dev_checks = require('crud.common.dev_checks')
55
local utils = require('crud.common.utils')
66

7-
local UpdateTuplesError = errors.new('UpdateTuplesError')
8-
local GetTupleError = errors.new('GetTupleError')
7+
local UpdateTuplesError = errors.new_class('UpdateTuplesError')
8+
local GetTupleError = errors.new_class('GetTupleError')
99

1010
local Heap = require('crud.common.heap')
1111

test/integration/select_test.lua

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,23 @@ add('test_non_existent_space', function(g)
123123
t.assert_str_contains(err.err, "Space non_existent_space doesn't exist")
124124
end)
125125

126+
add('test_not_valid_value_type', function(g)
127+
local conditions = {
128+
{'=', 'id', 'not_number'}
129+
}
130+
131+
local obj, err = g.cluster.main_server.net_box:eval([[
132+
local crud = require('crud')
133+
local conditions = ...
134+
135+
local result, err = crud.select('customers', conditions)
136+
return result, err
137+
]], {conditions})
138+
139+
t.assert_equals(obj, nil)
140+
t.assert_str_contains(err.err, "Supplied key type of part 0 does not match index part type: expected unsigned")
141+
end)
142+
126143
add('test_select_all', function(g)
127144
local customers = insert_customers(g, {
128145
{

0 commit comments

Comments
 (0)