From 737db4b0b1554adce8b6f856079748dc9801152f Mon Sep 17 00:00:00 2001 From: Katharina Irrgang Date: Tue, 11 Dec 2018 11:53:40 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=20Fixed=20all=20known=20filter?= =?UTF-8?q?=20limitations=20(#10159)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit refs #10105, closes #10108, closes https://github.com/TryGhost/Ghost/issues/9950, refs https://github.com/TryGhost/Ghost/issues/9923, refs https://github.com/TryGhost/Ghost/issues/9916, refs https://github.com/TryGhost/Ghost/issues/9574, refs https://github.com/TryGhost/Ghost/issues/6345, refs https://github.com/TryGhost/Ghost/issues/6309, refs https://github.com/TryGhost/Ghost/issues/6158, refs https://github.com/TryGhost/GQL/issues/16 - removed GQL dependency - replaced GQL with our brand new NQL implementation - fixed all known filter limitations - GQL suffered from some underlying filter bugs, which NQL tried to fix - the bugs were mostly in how we query the database for relation filtering - the underlying problem was caused by a too simple implementation of querying the relations - mongo-knex has implemented a more robust and complex filtering mechanism for relations - replaced logic in our bookshelf filter plugin - we pass the custom, default and override filters from Ghost to NQL, which then are getting parsed and merged into a mongo JSON object. The mongo JSON is getting attached by mongo-knex. NQL: https://github.com/NexesJS/NQL mongo-knex: https://github.com/NexesJS/mongo-knex --- .../bookshelf-pagination/lib/bookshelf-pagination.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/bookshelf-pagination/lib/bookshelf-pagination.js b/packages/bookshelf-pagination/lib/bookshelf-pagination.js index 8841c77f..93cddb1d 100644 --- a/packages/bookshelf-pagination/lib/bookshelf-pagination.js +++ b/packages/bookshelf-pagination/lib/bookshelf-pagination.js @@ -199,6 +199,16 @@ pagination = function pagination(bookshelf) { throw err; }); + }).catch((err) => { + // CASE: SQL syntax is incorrect + if (err.errno === 1054 || err.errno === 1) { + throw new common.errors.BadRequestError({ + message: common.i18n.t('errors.models.general.sql'), + err: err + }); + } + + throw err; }); } });