diff --git a/src/app/core/export/query.service.spec.ts b/src/app/core/export/query.service.spec.ts index 190e50ae7f..6e0a86c74b 100644 --- a/src/app/core/export/query.service.spec.ts +++ b/src/app/core/export/query.service.spec.ts @@ -618,6 +618,12 @@ describe("QueryService", () => { expect(result).toEqual([maleChild.gender]); }); + it("does not throw an error if no query is provided", () => { + return expectAsync( + service.queryData(undefined, new Date(), new Date()) + ).toBeResolvedTo({}); + }); + async function createChild( gender: "M" | "F" = "F", religion?: "muslim" | "christian" diff --git a/src/app/core/export/query.service.ts b/src/app/core/export/query.service.ts index af6571c403..ab3189e42d 100644 --- a/src/app/core/export/query.service.ts +++ b/src/app/core/export/query.service.ts @@ -167,7 +167,7 @@ export class QueryService { return this.queryStringMap .filter(([matcher]) => // matches query string without any alphanumeric characters before or after (e.g. so Child does not match ChildSchoolRelation) - query.match(new RegExp(`(^|\\W)${matcher}(\\W|$)`)) + query?.match(new RegExp(`(^|\\W)${matcher}(\\W|$)`)) ) .map(([_, entity]) => entity) .filter((entity) => {