Fix/allow count wildcard (#29689)

* allow count wildcard

* add a test
This commit is contained in:
Jordi Enric authored and GitHub committed 2024-10-04 20:10:59 +00:00
1 parent a7705d369c
commit df40b598ff
2 files changed
+7 -1

No files matched your search

@@ -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)
}
@@ -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)
})
})