From b931b083a2bca5fb6255e1f5c3ce5ebfda4f58ed Mon Sep 17 00:00:00 2001 From: Georgy Moiseev Date: Fri, 15 Mar 2024 18:14:28 +0300 Subject: [PATCH] utils: generate support check utils Generate `tarantool_supports_X` utils instead of creating a manual function for each key with copypaste. Part of #422 --- crud/common/utils.lua | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/crud/common/utils.lua b/crud/common/utils.lua index d06fb9a8..1f95b8aa 100644 --- a/crud/common/utils.lua +++ b/crud/common/utils.lua @@ -666,28 +666,17 @@ end determine_enabled_features() -function utils.tarantool_supports_fieldpaths() - return enabled_tarantool_features.fieldpaths -end - -function utils.tarantool_supports_uuids() - return enabled_tarantool_features.uuids -end - -function utils.tarantool_supports_jsonpath_indexes() - return enabled_tarantool_features.jsonpath_indexes -end - -function utils.tarantool_has_builtin_merger() - return enabled_tarantool_features.builtin_merger -end +for feature_name, feature_enabled in pairs(enabled_tarantool_features) do + local util_name + if feature_name == 'builtin_merger' then + util_name = ('tarantool_has_%s'):format(feature_name) + else + util_name = ('tarantool_supports_%s'):format(feature_name) + end -function utils.tarantool_supports_external_merger() - return enabled_tarantool_features.external_merger -end + local util_func = function() return feature_enabled end -function utils.tarantool_supports_netbox_skip_header_option() - return enabled_tarantool_features.netbox_skip_header_option + utils[util_name] = util_func end local function add_nullable_fields_recursive(operations, operations_map, space_format, tuple, id)