diff --git a/packages/strapi-utils/lib/models.js b/packages/strapi-utils/lib/models.js old mode 100755 new mode 100644 index 4f416be13a..7af0be329f --- a/packages/strapi-utils/lib/models.js +++ b/packages/strapi-utils/lib/models.js @@ -457,11 +457,25 @@ module.exports = { _.forEach(params, (value, key) => { let result; let formattedValue; - - // Check if the value if a valid candidate to be converted to a number value - formattedValue = isNumeric(value) - ? _.toNumber(value) - : value; + let modelAttributes = models[model]['attributes']; + let fieldType; + // Get the field type to later check if it's a string before number conversion + if (modelAttributes[key]) { + fieldType = modelAttributes[key]['type']; + } else { + let splitKey = key.split('_').pop(); + if (modelAttributes[splitKey]) { + fieldType = modelAttributes[splitKey]['type']; + } + } + // Check if the value is a valid candidate to be converted to a number value + if (fieldType != 'string') { + formattedValue = isNumeric(value) + ? _.toNumber(value) + : value; + } else { + formattedValue = value; + } if (_.includes(['_start', '_limit'], key)) { result = convertor(formattedValue, key);