Skip to content

feat Uniform negation 1/2: ~ on leaf predicates — the tracer bullet #312

Description

@0x054

Parent

#310 (feat PRD: Uniform predicate negation — prefix ~ as a NOT wire node)

What to build

The tracer bullet for uniform negation: prefix ~ on any leaf predicate, working end-to-end — Python spelling through the wire IR to rendered SQL on both database backends.

~ on a predicate node wraps it in a new recursive not wire node kind (beside the existing leaf and compound kinds; QueryIR version bumps). The Rust condition builder gains one recursion case rendering SQL NOT (...) over the rebuilt child. No per-operator negative forms are added anywhere — ~t.col.in_(ids) and ~t.col.like(p) are the spellings that close the pre-existing NOT IN / NOT LIKE gap (ADR-0008).

A hand-authored golden vector pins the not-over-leaf wire shape, asserted from both the Python emitter and the Rust decoder — the contract-review moment for the wire change.

Demo: Txn.where(lambda t: ~t.category_id.in_(ids)) returns exactly the complement rows (modulo SQL NULL semantics) on SQLite and Postgres.

Acceptance criteria

  • ~ works on every leaf operator kind: equality, ordering comparisons, in_, like
  • Rendered SQL is a faithful NOT (...) over the child predicate; no operator rewriting
  • QueryIR version bumped; hand-authored golden vector for not-over-leaf asserted by Python emitter and Rust decoder
  • End-to-end result-set tests on both backends via the existing backend matrix, in the style of the existing per-feature query test files
  • NULL-row behavior under negation covered by a test (rows with NULL in the negated column are excluded, matching existing != behavior)
  • Negated predicates compose with &/|, order_by, limit (composition tests at the e2e seam)
  • No not_in/not_like methods introduced

Blocked by

None - can start immediately

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureready-for-agentUnblocked and fully specified; an agent may claim it

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions