From df40b598ff2c9fb1f00b9cbf42499c237afb027f Mon Sep 17 00:00:00 2001 From: Jordi Enric <37541088+jordienr@users.noreply.github.com> Date: Fri, 4 Oct 2024 22:10:59 +0200 Subject: [PATCH] Fix/allow count wildcard (#29689) * allow count wildcard * add a test --- apps/studio/components/interfaces/Settings/Logs/Logs.utils.ts | 4 +++- apps/studio/tests/pages/projects/Logs.utils.test.ts | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/studio/components/interfaces/Settings/Logs/Logs.utils.ts b/apps/studio/components/interfaces/Settings/Logs/Logs.utils.ts index d8ffa517b39..b4c4732ee15 100644 --- a/apps/studio/components/interfaces/Settings/Logs/Logs.utils.ts +++ b/apps/studio/components/interfaces/Settings/Logs/Logs.utils.ts @@ -550,6 +550,8 @@ export function checkForILIKEClause(query: string) { export function checkForWildcard(query: string) { const queryWithoutComments = query.replace(/--.*$/gm, '').replace(/\/\*[\s\S]*?\*\//gm, '') + const queryWithoutCount = queryWithoutComments.replace(/count\(\*\)/gi, '') + const wildcardRegex = /\*/ - return wildcardRegex.test(queryWithoutComments) + return wildcardRegex.test(queryWithoutCount) } diff --git a/apps/studio/tests/pages/projects/Logs.utils.test.ts b/apps/studio/tests/pages/projects/Logs.utils.test.ts index 5b60d52258a..b074f865b8a 100644 --- a/apps/studio/tests/pages/projects/Logs.utils.test.ts +++ b/apps/studio/tests/pages/projects/Logs.utils.test.ts @@ -91,4 +91,8 @@ describe('checkForWildcard', () => { expect(checkForWildcard('-- *\nSELECT column FROM table')).toBe(false) expect(checkForWildcard('/* * */\nSELECT column FROM table')).toBe(false) }) + + test('count(*)', () => { + expect(checkForWildcard('SELECT count(*) FROM table')).toBe(false) + }) })