From 8aa1eb1cfc05a4dc3cdc30091ebd68817238974c Mon Sep 17 00:00:00 2001 From: Akalanka Perera Date: Wed, 24 Jan 2024 11:39:02 +0530 Subject: [PATCH 1/2] Patch!: updated parsing of select and include --- packages/mongoose-filter-query/src/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/mongoose-filter-query/src/index.js b/packages/mongoose-filter-query/src/index.js index 2158959..f0f6282 100644 --- a/packages/mongoose-filter-query/src/index.js +++ b/packages/mongoose-filter-query/src/index.js @@ -31,8 +31,8 @@ const mongooseFilterQuery = (req, res, next) => { } else { req.query.sort = {}; } - req.query.include = req.query.include?.split(",") ?? []; - req.query.select = req.query.select?.split(",")?.join(" ") ?? ""; + req.query.include = req.query.include?.split(","); + req.query.select = req.query.select?.split(",")?.join(" "); } catch (e) { console.error("[ FilterQuery ] - Failed to parse query", e); } From f1aaef0a878ca5031050eb08828a5291baed1c91 Mon Sep 17 00:00:00 2001 From: Akalanka Perera Date: Wed, 24 Jan 2024 11:44:35 +0530 Subject: [PATCH 2/2] Patch!: updated unit tests to match previous change --- packages/mongoose-filter-query/test/index.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/mongoose-filter-query/test/index.test.js b/packages/mongoose-filter-query/test/index.test.js index e4b206d..d19eb7c 100644 --- a/packages/mongoose-filter-query/test/index.test.js +++ b/packages/mongoose-filter-query/test/index.test.js @@ -46,7 +46,7 @@ describe("test mongoose-filter-query", () => { }); test("undefined", async () => { mongooseFilterQuery(req, {}, () => {}); - expect(req.query.include).toEqual([]); + expect(req.query.include).toEqual(undefined); }); }); describe("select", () => { @@ -56,7 +56,7 @@ describe("test mongoose-filter-query", () => { }); test("undefined", async () => { mongooseFilterQuery(req, {}, () => {}); - expect(req.query.select).toEqual(""); + expect(req.query.select).toEqual(undefined); }); }); test("handle error", async () => {