From d28d94c7c89e0242d8246e9764364324f98f9e46 Mon Sep 17 00:00:00 2001 From: Sander Vocke Date: Fri, 4 Sep 2020 14:55:09 +0200 Subject: [PATCH] All works in Postgres! --- server/endpoints/QueryEndpointHandler.ts | 10 +++++++--- server/test/test.sh | 2 -- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/server/endpoints/QueryEndpointHandler.ts b/server/endpoints/QueryEndpointHandler.ts index d8bc861..4707b32 100644 --- a/server/endpoints/QueryEndpointHandler.ts +++ b/server/endpoints/QueryEndpointHandler.ts @@ -177,9 +177,13 @@ function constructQuery(knex: Knex, queryFor: ObjectType, queryElem: api.QueryEl joinObjects.delete(queryFor); // We are already querying this object in the base query. // Figure out what data we want to select from the results. - var columns: any[] = []; - joinObjects.forEach((obj: ObjectType) => columns.push(...objectColumns[obj])); - columns.push(...objectColumns[queryFor]); + var columns: any[] = objectColumns[queryFor]; + + // TODO: there was a line here to add columns for the joined objects. + // Could not get it to work with Postgres, which wants aggregate functions + // to specify exactly how duplicates should be aggregated. + // Not sure whether we need these columns in the first place. + // joinObjects.forEach((obj: ObjectType) => columns.push(...objectColumns[obj])); // First, we create a base query for the type of object we need to yield. var q = knex.select(columns) diff --git a/server/test/test.sh b/server/test/test.sh index 4273e5f..b5c72f8 100755 --- a/server/test/test.sh +++ b/server/test/test.sh @@ -3,8 +3,6 @@ # Wrapper around the Jasmine test scripts. # Can test with different types of databases. -set -x - SCRIPT=`realpath $0` SCRIPTPATH=`dirname $SCRIPT` SOURCEPATH="$SCRIPTPATH/.."