Skip to content

Commit df40b59

Browse files
authored
Fix/allow count wildcard (supabase#29689)
* allow count wildcard * add a test
1 parent a7705d3 commit df40b59

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

apps/studio/components/interfaces/Settings/Logs/Logs.utils.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,8 @@ export function checkForILIKEClause(query: string) {
550550
export function checkForWildcard(query: string) {
551551
const queryWithoutComments = query.replace(/--.*$/gm, '').replace(/\/\*[\s\S]*?\*\//gm, '')
552552

553+
const queryWithoutCount = queryWithoutComments.replace(/count\(\*\)/gi, '')
554+
553555
const wildcardRegex = /\*/
554-
return wildcardRegex.test(queryWithoutComments)
556+
return wildcardRegex.test(queryWithoutCount)
555557
}

apps/studio/tests/pages/projects/Logs.utils.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,8 @@ describe('checkForWildcard', () => {
9191
expect(checkForWildcard('-- *\nSELECT column FROM table')).toBe(false)
9292
expect(checkForWildcard('/* * */\nSELECT column FROM table')).toBe(false)
9393
})
94+
95+
test('count(*)', () => {
96+
expect(checkForWildcard('SELECT count(*) FROM table')).toBe(false)
97+
})
9498
})

0 commit comments

Comments
 (0)