From 1234979f56592ad4c3f795ae2a9a0c00f552e038 Mon Sep 17 00:00:00 2001 From: Syed Abdul Rahman <137684137+S-Abdul-Rahman@users.noreply.github.com> Date: Tue, 4 Jun 2024 11:09:29 +0530 Subject: [PATCH] fix : Delete column query throws error if the column name starts with uppercase in ToolJet database (#9877) * fix : while deleting a column if the column name starts with uppercase, it throws error * Added the query as parameterized query * fix : using query runner with creation in parameterized queries --- server/src/services/tooljet_db.service.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/server/src/services/tooljet_db.service.ts b/server/src/services/tooljet_db.service.ts index e5e7bcdf01..aebdb6082e 100644 --- a/server/src/services/tooljet_db.service.ts +++ b/server/src/services/tooljet_db.service.ts @@ -610,13 +610,17 @@ export class TooljetDbService { if (!internalTable) throw new NotFoundException('Internal table not found: ' + tableName); - const query = `ALTER TABLE "${internalTable.id}" DROP COLUMN ${column['column_name']}`; + // const query = `ALTER TABLE "${internalTable.id}" DROP COLUMN "${column['column_name']}"`; + const tjdbQueryRunnner = this.tooljetDbManager.connection.createQueryRunner(); + await tjdbQueryRunnner.connect(); try { - const result = await this.tooljetDbManager.query(query); + const result = await tjdbQueryRunnner.dropColumn(internalTable.id, column['column_name']); await this.tooljetDbManager.query("NOTIFY pgrst, 'reload schema'"); return result; } catch (error) { throw new TooljetDatabaseError(error.message, { origin: 'drop_column', internalTables: [internalTable] }, error); + } finally { + await tjdbQueryRunnner.release(); } }