From 0797ab7762a4a64f2dc89c754a6bb04216b96fe1 Mon Sep 17 00:00:00 2001 From: Serge Latyntcev Date: Fri, 25 Jan 2019 15:03:44 +1300 Subject: [PATCH] Fix GraphQL FolderTypeCreator::resolveChildrenConnection on PostgreSQL (#901) --- .travis.yml | 9 +++++++-- code/GraphQL/FolderTypeCreator.php | 6 +++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2563dcfef..b1557851c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -37,6 +37,10 @@ matrix: env: NPM_TEST=1 - php: 5.6 env: PHPCS_TEST=1 + - php: 5.6 + env: + - DB=PGSQL + - PHPUNIT_TEST=1 before_script: # Extra $PATH @@ -50,8 +54,9 @@ before_script: # Install composer - composer validate - - composer require silverstripe/recipe-testing:^1 silverstripe/recipe-cms 1.0.x-dev --no-update --prefer-dist - - composer install --prefer-dist --no-interaction --no-progress --no-suggest --optimize-autoloader --verbose --profile + - if [[ $DB == PGSQL ]]; then composer require --no-update silverstripe/postgresql:2.0.x-dev; fi + - composer require silverstripe/recipe-testing:^1 silverstripe/recipe-cms 1.0.x-dev --no-update + - composer install --prefer-source --no-interaction --no-progress --no-suggest --optimize-autoloader --verbose --profile # Start behat services - if [[ $BEHAT_TEST ]]; then mkdir artifacts; fi diff --git a/code/GraphQL/FolderTypeCreator.php b/code/GraphQL/FolderTypeCreator.php index fe1ba8e6c..2a07e1f28 100644 --- a/code/GraphQL/FolderTypeCreator.php +++ b/code/GraphQL/FolderTypeCreator.php @@ -13,6 +13,7 @@ use SilverStripe\GraphQL\Pagination\Connection; use SilverStripe\ORM\DataQuery; use SilverStripe\ORM\DataList; +use SilverStripe\ORM\DB; /** * @skipUpgrade @@ -159,7 +160,10 @@ public function resolveChildrenConnection( $list = $list->alterDataQuery(function (DataQuery $query, DataList $list) { $existingOrderBys = $query->query()->getOrderBy(); $query->sort( - '(CASE WHEN "ClassName"=\'SilverStripe\\\\Assets\\\\Folder\' THEN 1 ELSE 0 END)', + sprintf( + '(CASE WHEN "ClassName"=%s THEN 1 ELSE 0 END)', + DB::get_conn()->quoteString('SilverStripe\Assets\Folder') + ), 'DESC', true );