Skip to content

Commit

Permalink
utils: generate support check utils
Browse files Browse the repository at this point in the history
Generate `tarantool_supports_X` utils instead of creating a manual
function for each key with copypaste.

Part of #422
  • Loading branch information
DifferentialOrange committed Mar 15, 2024
1 parent 7b10250 commit b931b08
Showing 1 changed file with 9 additions and 20 deletions.
29 changes: 9 additions & 20 deletions crud/common/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit b931b08

Please sign in to comment.