Skip to content

Commit

Permalink
Fix GraphQL FolderTypeCreator::resolveChildrenConnection on PostgreSQL (
Browse files Browse the repository at this point in the history
  • Loading branch information
dnsl48 committed Jan 25, 2019
1 parent c3fa7a4 commit 0797ab7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
9 changes: 7 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 5 additions & 1 deletion code/GraphQL/FolderTypeCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use SilverStripe\GraphQL\Pagination\Connection;
use SilverStripe\ORM\DataQuery;
use SilverStripe\ORM\DataList;
use SilverStripe\ORM\DB;

/**
* @skipUpgrade
Expand Down Expand Up @@ -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
);
Expand Down

0 comments on commit 0797ab7

Please sign in to comment.