File tree Expand file tree Collapse file tree 2 files changed +22
-14
lines changed Expand file tree Collapse file tree 2 files changed +22
-14
lines changed Original file line number Diff line number Diff line change @@ -713,21 +713,12 @@ local function is_callable(object)
713
713
end
714
714
715
715
local function check_sharding_func_name (sharding_func_name )
716
- -- split sharding func name in dot notation by dot
717
- -- foo.bar.baz -> chunks: foo bar baz
718
- -- foo -> chunks: foo
719
- local chunks = string .split (sharding_func_name , ' .' )
720
-
721
- local sharding_func = _G
722
- -- check is the each chunk an identifier
723
- for _ , chunk in pairs (chunks ) do
724
- if not utils .check_name_isident (chunk ) or sharding_func == nil then
725
- return false
726
- end
727
- sharding_func = rawget (sharding_func , chunk )
716
+ local sharding_func = utils .get_G_function (sharding_func_name )
717
+ if sharding_func ~= nil then
718
+ return is_callable (sharding_func )
728
719
end
729
720
730
- return is_callable ( sharding_func )
721
+ return false
731
722
end
732
723
733
724
local function check_sharding_func (space )
Original file line number Diff line number Diff line change @@ -186,6 +186,23 @@ local function check_name_isident(name)
186
186
return true
187
187
end
188
188
189
+ -- split sharding func name in dot notation by dot
190
+ -- foo.bar.baz -> chunks: foo bar baz
191
+ -- foo -> chunks: foo
192
+ local function get_G_function (func_name )
193
+ local chunks = string .split (func_name , ' .' )
194
+ local sharding_func = _G
195
+ -- check is the each chunk an identifier
196
+ for _ , chunk in pairs (chunks ) do
197
+ if not check_name_isident (chunk ) or sharding_func == nil then
198
+ return nil
199
+ end
200
+ sharding_func = rawget (sharding_func , chunk )
201
+ end
202
+
203
+ return sharding_func
204
+ end
205
+
189
206
return {
190
207
deepcmp = deepcmp ,
191
208
is_array = is_array ,
@@ -194,5 +211,5 @@ return {
194
211
lj_char_isident = lj_char_isident ,
195
212
lj_char_isdigit = lj_char_isdigit ,
196
213
LUA_KEYWORDS = LUA_KEYWORDS ,
197
- check_name_isident = check_name_isident ,
214
+ get_G_function = get_G_function ,
198
215
}
You can’t perform that action at this time.
0 commit comments