From 0a77a869f78f2fee9794e438b2f4a044eec66737 Mon Sep 17 00:00:00 2001 From: Benjamin Toby Date: Fri, 27 Dec 2024 09:56:11 +0100 Subject: [PATCH] Updates --- .../functions/dsql/sql/sql-generator.js | 18 ++++++++++-------- package-shared/types/index.d.ts | 1 + package-shared/types/index.ts | 1 + package.json | 2 +- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/package-shared/functions/dsql/sql/sql-generator.js b/package-shared/functions/dsql/sql/sql-generator.js index c4df218..1b6577f 100644 --- a/package-shared/functions/dsql/sql/sql-generator.js +++ b/package-shared/functions/dsql/sql/sql-generator.js @@ -131,14 +131,16 @@ function sqlGenerator({ tableName, genObject }) { if (joinObj.selectFields) { return joinObj.selectFields - .map((slFld) => { - if (typeof slFld == "string") { - return `${joinTableName}.${slFld}`; - } else if (typeof slFld == "object") { - let aliasSlctFld = `${joinTableName}.${slFld.field}`; - if (slFld.alias) - aliasSlctFld += ` as ${slFld.alias}`; - return aliasSlctFld; + .map((selectField) => { + if (typeof selectField == "string") { + return `${joinTableName}.${selectField}`; + } else if (typeof selectField == "object") { + let aliasSelectField = selectField.count + ? `COUNT(${joinTableName}.${selectField.field})` + : `${joinTableName}.${selectField.field}`; + if (selectField.alias) + aliasSelectField += ` AS ${selectField.alias}`; + return aliasSelectField; } }) .join(","); diff --git a/package-shared/types/index.d.ts b/package-shared/types/index.d.ts index 2125294..cb2431c 100644 --- a/package-shared/types/index.d.ts +++ b/package-shared/types/index.d.ts @@ -955,6 +955,7 @@ export type ServerQueryParamsJoin