0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00

Extended our knex mock to only return specific fields/columns

no issue
This commit is contained in:
kirrg001 2018-04-06 13:35:38 +02:00
parent 89e4201b67
commit fa4e2cf286

View file

@ -148,6 +148,21 @@ class KnexMock {
}));
if (dbEntry) {
// select fields
dbEntry = _.map(dbEntry, (obj) => {
let keys = query.sql.match(/select\s(\".*\"\,?)+\sfrom/);
if (keys) {
keys = keys[1];
keys = keys.replace(/"/g, '');
keys = keys.replace(/\s/g, '');
keys = keys.split(',');
return _.pick(obj, keys);
}
return obj;
});
query.response(dbEntry);
debug('#### Query end.\n');
} else {