Skip to content
Source
Sign inSign up
TanStack/db

feat(electric-db-collection): support nested property references in SQL queries #1514

Closedmiguelrk(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/1514/headopened

🎯 Changes

Extends @tanstack/electric-db-collection SQL compilation so multi-segment IR (intermediate representation) refs (nested property paths) work in WHERE and ORDER BY instead of throwing. Paths compile to PostgreSQL JSON / jsonb operators (-> for intermediate keys, ->> for the final key so the compared value is text).

Scope / limitations: nested paths assume JSON / jsonb extraction from a single root column; if the physical column isn’t JSON / jsonb, SQL may fail at runtime.

✅ Checklist

  • I have tested this code locally with pnpm test.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).
    1. Closing because this capability cannot be implemented solely in the TanStack Electric collection compiler. The generated nested-path filter uses PostgreSQL JSON operators (-> / ->>), but Electric's Shape server validates and evaluates WHERE expressions with its own expression engine, which does not support those JSON extraction operators. We are not planning the required Electric server work.\n\nThe current candidate also cannot safely land independently: final ->> extraction coerces JSON numbers to text, changing numeric filtering and ordering semantics. Thanks @miguelrk for exploring the compiler side and documenting the intended behavior.

Sign in to join this conversation.