diff --git a/ghost/core/core/server/models/post.js b/ghost/core/core/server/models/post.js index 8490048cef..25111588cc 100644 --- a/ghost/core/core/server/models/post.js +++ b/ghost/core/core/server/models/post.js @@ -1290,11 +1290,13 @@ Post = ghostBookshelf.Model.extend({ options.withRelated = _.union(['authors', 'tags', 'post_revisions', 'post_revisions.author'], options.withRelated || []); } - const META_ATTRIBUTES = _.without(ghostBookshelf.model('PostsMeta').prototype.permittedAttributes(), 'id', 'post_id'); - // NOTE: only include post_meta relation when requested in 'columns' or by default // optimization is needed to be able to perform .findAll on large SQLite datasets - if (!options.columns || (options.columns && _.intersection(META_ATTRIBUTES, options.columns).length)) { + if (!options.columns + || ( + options.columns + && _.intersection(_.without(ghostBookshelf.model('PostsMeta').prototype.permittedAttributes(), 'id', 'post_id'), options.columns).length) + ) { options.withRelated = _.union(['posts_meta'], options.withRelated || []); }