Skip to content

Untyped range comparator aliases bypass operand conversion #4118

Open

Description

@kriszyp

Code tracing on origin/main 9193b01 identifies a pre-existing operand-coercion mismatch in resources/Table.ts:coerceConditionValue.

The function resolves aliases when choosing an element type, but its untyped-field guard checks the original comparator in COERCIBLE_OPERATORS. Search subsequently resolves both comparators to the same operation. For an indexed untyped field containing numeric 10, gt with operand '5' casts to numeric 5, while alias greater_than retains string '5', producing different index bounds and different rows. Existing unitTests/resources/restConditionCoercion.test.js:245-266 explicitly preserves strict long comparator names, so the difference is an existing compatibility contract; do not treat normalization as a mechanical fix.

This is separate from string-pattern alias handling: the LIKE task's early return canonicalizes aliases and preserves text for ct/contains correctly. Do not expand its text exemption to range comparisons.

Reproduce through real Table searches on RocksDB and LMDB; compare gt/greater_than and the other canonical range comparators/aliases over numeric and text values. Resolve whether the public alias contract should preserve this distinction before changing the coercion lookup. Normalizing the raw lookup alone also changes eq, which maps to equals; the coercible set and lookup must be considered together. Preserve typed, array-element and string-pattern behavior.

Priority: P2. Contained silent query inconsistency requiring an alias, an untyped indexed field and a string operand; canonical comparator is a workaround. Effort: Low, one lookup plus real-Table regressions. Evidence is source tracing; the current regression suite confirms the distinction, while the desired alias contract still needs an explicit decision. No shipped version boundary or customer exposure was established.

Review-Deferral: 68e7674b3f15b89f severity=minor category=correctness

Filed by GPT-5 Codex during the dev-agent review workflow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Fields

    Priority

    P2

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions