Commit 46ff94c
fix: 3 driver bugs found by adversarial testing (167 tests, 3 real failures)
Ran 167 adversarial tests against real ClickHouse Docker containers
covering SQL injection, unicode, NULLs, LIMIT edge cases, exotic types,
error handling, large data, MergeTree variants, views, system tables,
concurrent operations, and return value edge cases.
**Bugs found and fixed:**
1. **DESCRIBE/EXISTS get LIMIT appended** — `isSelectLike` regex matched
DESCRIBE/EXISTS but ClickHouse doesn't support LIMIT on these statements.
Fix: narrowed `supportsLimit` to only `SELECT` and `WITH` queries.
2. **`limit=0` returns 0 rows** — truncation check `rows.length > 0` was
always true, causing `slice(0, 0)` to return empty array.
Fix: guard with `effectiveLimit > 0 &&` before truncation check.
3. **`limit=0` treated as `limit=1000`** — `0 ?? 1000` returns 0 (correct)
but `limit === undefined ? 1000 : limit` properly distinguishes "not
provided" from "explicitly zero". Changed from `??` to explicit check.
**Regression tests added (5 tests in main E2E suite):**
- DESCRIBE TABLE without LIMIT error
- EXISTS TABLE without LIMIT error
- limit=0 returns all rows without truncation
- INSERT uses `client.command()` not `client.query()`
- WITH...INSERT does not get LIMIT appended
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 6c48729 commit 46ff94c
2 files changed
Lines changed: 68 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
| 64 | + | |
65 | 65 | | |
66 | | - | |
| 66 | + | |
| 67 | + | |
67 | 68 | | |
68 | 69 | | |
69 | 70 | | |
| |||
75 | 76 | | |
76 | 77 | | |
77 | 78 | | |
78 | | - | |
| 79 | + | |
| 80 | + | |
79 | 81 | | |
80 | 82 | | |
81 | 83 | | |
| |||
91 | 93 | | |
92 | 94 | | |
93 | 95 | | |
94 | | - | |
| 96 | + | |
95 | 97 | | |
96 | 98 | | |
97 | 99 | | |
| |||
Lines changed: 62 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
337 | 337 | | |
338 | 338 | | |
339 | 339 | | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
340 | 402 | | |
341 | 403 | | |
342 | 404 | | |
| |||
0 commit comments