Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions packages/cli/src/test/text-index.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,17 +233,27 @@ test('normalization preserves every printable ClickHouse string escape', async (
const { normalizeTextIndexSQL } = await import('@chkit/core')
const executor = createLiveExecutor(env)
try {
const checks: string[] = []
for (let code = 32; code < 127; code++) {
const sql = `'\\${String.fromCharCode(code)}'`
if (code === 120) {
expect(() => normalizeTextIndexSQL(sql)).toThrow('Invalid hexadecimal')
continue
}
const rows = await executor.query<{
original: string
normalized: string
}>(`SELECT hex(${sql}) AS original, hex(${normalizeTextIndexSQL(sql)}) AS normalized`)
expect(rows[0]?.normalized, `escape ${JSON.stringify(sql)}`).toBe(rows[0]?.original)
checks.push(
`SELECT ${code} AS code, hex(${sql}) AS original, hex(${normalizeTextIndexSQL(sql)}) AS normalized`,
)
}
// Keep the live checks in one request so remote round trips don't exhaust the test timeout.
const rows = await executor.query<{
code: number
original: string
normalized: string
}>(checks.join('\nUNION ALL\n'))
expect(rows).toHaveLength(checks.length)
for (const { code, original, normalized } of rows) {
const sql = `'\\${String.fromCharCode(code)}'`
expect(normalized, `escape ${JSON.stringify(sql)}`).toBe(original)
}
} finally {
await executor.close()
Expand Down
Loading