Commit 7002420
Document filters.py scope; fix three edge-case pitfall gaps
Document the scope explicitly in the module docstring — what gets
parsed vs what passes through to the server untouched — since a
reviewer came away from the previous version wondering "are we only
handling OR?" (answer: yes for chunking, three forms for pitfall
detection, everything else passes through).
While adding the docs I swept more CQL-text shapes and found three
real gaps in the pitfall check:
1. Leading-dot decimals (``value > .5``, ``value > -.5``,
``value > .5e-3``) bypassed the numeric regex because it required
``\d+`` before the decimal point. Users writing fractions this way
were getting server 500s instead of the client-side ValueError.
Extend ``_NUM`` to also accept ``\.\d+``.
2. ``NOT IN`` / ``NOT BETWEEN`` misattributed the field. The regexes
matched with ``field='NOT'`` and the error said
``against 'NOT' (``NOT IN (…)``)``, which is confusing. Add a
``(?!NOT\b)`` lookahead so ``NOT`` can't be captured as a field,
and an optional ``(?P<negated>NOT\s+)?`` before the keyword so the
error reports ``against 'value' (``value NOT IN (…)``)`` instead.
3. Consequence-free guard: ``NOTES = 'hello'`` (a real field name
starting with "NOT") continues to pass — the ``(?!NOT\b)``
lookahead uses a word boundary so only the bare keyword is
excluded.
Tests: +18 cases on the raise/allow parametrize lists; +5 cases on a
new ``test_pitfall_error_names_real_field_not_NOT_keyword`` that
pins the attribution contract. 176 non-live tests pass.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 194c0b2 commit 7002420
2 files changed
Lines changed: 98 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
11 | 46 | | |
12 | 47 | | |
13 | 48 | | |
| |||
22 | 57 | | |
23 | 58 | | |
24 | 59 | | |
25 | | - | |
26 | | - | |
27 | | - | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
28 | 65 | | |
29 | 66 | | |
30 | 67 | | |
| |||
93 | 130 | | |
94 | 131 | | |
95 | 132 | | |
96 | | - | |
97 | | - | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
98 | 139 | | |
99 | 140 | | |
100 | 141 | | |
| |||
113 | 154 | | |
114 | 155 | | |
115 | 156 | | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
121 | 164 | | |
122 | | - | |
| 165 | + | |
123 | 166 | | |
124 | 167 | | |
125 | 168 | | |
126 | | - | |
127 | | - | |
| 169 | + | |
| 170 | + | |
128 | 171 | | |
129 | | - | |
| 172 | + | |
| 173 | + | |
130 | 174 | | |
131 | 175 | | |
132 | 176 | | |
| |||
323 | 367 | | |
324 | 368 | | |
325 | 369 | | |
326 | | - | |
| 370 | + | |
| 371 | + | |
327 | 372 | | |
328 | 373 | | |
329 | 374 | | |
330 | 375 | | |
331 | | - | |
| 376 | + | |
| 377 | + | |
332 | 378 | | |
333 | 379 | | |
334 | 380 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
480 | 480 | | |
481 | 481 | | |
482 | 482 | | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
483 | 487 | | |
484 | 488 | | |
485 | 489 | | |
486 | 490 | | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
487 | 494 | | |
488 | 495 | | |
489 | 496 | | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
490 | 500 | | |
491 | 501 | | |
492 | 502 | | |
| |||
529 | 539 | | |
530 | 540 | | |
531 | 541 | | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
532 | 546 | | |
533 | 547 | | |
534 | 548 | | |
| |||
537 | 551 | | |
538 | 552 | | |
539 | 553 | | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
540 | 575 | | |
541 | 576 | | |
542 | 577 | | |
| |||
0 commit comments