mirror of
https://github.com/strapi/strapi.git
synced 2025-07-20 15:36:59 +00:00
parent
aab2f3e06c
commit
6143c3e1ca
24
packages/strapi-utils/lib/models.js
Executable file → Normal file
24
packages/strapi-utils/lib/models.js
Executable file → Normal file
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user