From ee35543885a953425e188ff415389a72401514f5 Mon Sep 17 00:00:00 2001 From: Benjamin Toby Date: Thu, 14 Nov 2024 06:52:23 +0100 Subject: [PATCH] Update Types and SQL generator function --- functions/sql/sql-generator.js | 8 ++++++++ package-shared/types/index.d.ts | 2 +- package.json | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/functions/sql/sql-generator.js b/functions/sql/sql-generator.js index f1668cc..8e018f1 100644 --- a/functions/sql/sql-generator.js +++ b/functions/sql/sql-generator.js @@ -105,10 +105,17 @@ function sqlGenerator({ tableName, genObject }) { } if (genObject.join) { + /** @type {string[]} */ + const existingJoinTableNames = [tableName]; + str += "," + genObject.join .map((joinObj) => { + if (existingJoinTableNames.includes(joinObj.tableName)) + return null; + existingJoinTableNames.push(joinObj.tableName); + if (joinObj.selectFields) { return joinObj.selectFields .map((slFld) => { @@ -126,6 +133,7 @@ function sqlGenerator({ tableName, genObject }) { return `${joinObj.tableName}.*`; } }) + .filter((_) => Boolean(_)) .join(","); } diff --git a/package-shared/types/index.d.ts b/package-shared/types/index.d.ts index 0899ecb..544dda3 100644 --- a/package-shared/types/index.d.ts +++ b/package-shared/types/index.d.ts @@ -1172,7 +1172,7 @@ export type FetchDataParams = { }; export type AuthFetchQuery = ServerQueryParam & { - [key: string]: string | number | { [key: string]: any }; + [key: string]: any; }; export type ServerQueryParamsJoin< diff --git a/package.json b/package.json index 9e6c191..e3c7126 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@moduletrace/datasquirel", - "version": "2.6.3", + "version": "2.6.4", "description": "Cloud-based SQL data management tool", "main": "index.js", "bin": {