accept multiple values types in queries log

This commit is contained in:
Simon Martín 2019-02-27 10:07:56 +01:00
parent feb3a21dfd
commit 9e25cc9501

View File

@ -17,5 +17,24 @@ module.exports = function log() {
};
function prepareSQL(sql) {
return (sql && sql.substring(0, MAX_SQL_LENGTH)) || null;
if (!sql) {
return null;
}
if (typeof sql === 'string') {
return {
simple: sql.substring(0, MAX_SQL_LENGTH)
}
}
if (Array.isArray(sql)) {
return {
multiple: sql.map(q => q.substring(0, MAX_SQL_LENGTH))
}
}
return {
other: sql
}
}