Commit 40441a9
Generalize pitfall check to every field, not just
The empirical sweep of ``/collections/<svc>/queryables`` + sample
data shows 11+ string-typed-but-numeric-looking fields across the
OGC endpoints — ``value``, ``parameter_code``, ``statistic_id``,
``district_code``, ``county_code``, ``hydrologic_unit_code``,
``monitoring_location_number``, ``measurement_number``,
``channel_flow``, ``channel_width``, ``channel_velocity`` — and
zero-padded codes like ``parameter_code='00060'`` silently match
nothing on ``parameter_code = 60``.
Since *every* queryable on this API is typed as a string, there's
no such thing as a legitimate numeric comparison. The cleanest rule
is the universal one: flag any ``<identifier> <op> <unquoted
numeric literal>`` (or the reverse), regardless of which field.
Live-probed the server to confirm the failure mode: unquoted
numeric RHS doesn't silently lex — it returns HTTP 500. Quoted
literals (``value > '10'``) return 200 with real lex results. The
client-side check turns an opaque 500 into a clear ValueError with
the fix suggested inline, and also catches the silent-lex case
where users who *do* quote still get wrong semantics.
Dropped the ``_LEXICOGRAPHIC_NUMERIC_FIELDS`` watchlist and
widened the regex to match any identifier. Extended tests cover
all 11 real-world field types plus zero-padded codes,
multi-clause composites, and the original false-positive guards
(identifiers inside quoted string literals, quoted RHS bypasses).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>value
1 parent 3ff39db commit 40441a9
2 files changed
Lines changed: 78 additions & 51 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
246 | 246 | | |
247 | 247 | | |
248 | 248 | | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | | - | |
254 | | - | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | | - | |
259 | | - | |
260 | | - | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
261 | 265 | | |
262 | 266 | | |
263 | 267 | | |
264 | | - | |
| 268 | + | |
265 | 269 | | |
266 | 270 | | |
267 | 271 | | |
268 | 272 | | |
269 | 273 | | |
270 | | - | |
| 274 | + | |
271 | 275 | | |
272 | | - | |
| 276 | + | |
273 | 277 | | |
274 | 278 | | |
275 | 279 | | |
| |||
413 | 417 | | |
414 | 418 | | |
415 | 419 | | |
416 | | - | |
417 | | - | |
418 | | - | |
419 | | - | |
420 | | - | |
421 | | - | |
422 | | - | |
423 | | - | |
424 | | - | |
425 | | - | |
426 | | - | |
427 | | - | |
428 | | - | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
429 | 435 | | |
430 | | - | |
431 | | - | |
| 436 | + | |
| 437 | + | |
432 | 438 | | |
433 | 439 | | |
434 | 440 | | |
| |||
437 | 443 | | |
438 | 444 | | |
439 | 445 | | |
440 | | - | |
441 | | - | |
442 | | - | |
443 | | - | |
444 | | - | |
445 | | - | |
446 | | - | |
447 | | - | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
448 | 457 | | |
449 | 458 | | |
450 | 459 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
530 | 530 | | |
531 | 531 | | |
532 | 532 | | |
| 533 | + | |
533 | 534 | | |
534 | 535 | | |
535 | 536 | | |
| |||
538 | 539 | | |
539 | 540 | | |
540 | 541 | | |
541 | | - | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
542 | 553 | | |
543 | 554 | | |
544 | | - | |
| 555 | + | |
| 556 | + | |
545 | 557 | | |
| 558 | + | |
546 | 559 | | |
547 | 560 | | |
548 | 561 | | |
549 | | - | |
550 | | - | |
551 | | - | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
552 | 565 | | |
553 | 566 | | |
554 | 567 | | |
555 | 568 | | |
556 | 569 | | |
557 | 570 | | |
558 | 571 | | |
559 | | - | |
| 572 | + | |
560 | 573 | | |
561 | 574 | | |
562 | | - | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
563 | 579 | | |
564 | 580 | | |
565 | | - | |
566 | | - | |
567 | | - | |
568 | | - | |
569 | 581 | | |
570 | 582 | | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
571 | 589 | | |
572 | 590 | | |
573 | 591 | | |
574 | | - | |
575 | | - | |
| 592 | + | |
| 593 | + | |
576 | 594 | | |
577 | 595 | | |
578 | 596 | | |
| |||
0 commit comments