# `Electric.Shapes.Filter.WhereCondition`
[🔗](https://github.com/electric-sql/electric/tree/%40core/sync-service%401.6.2/packages/sync-service/lib/electric/shapes/filter/where_condition.ex#L1)

Responsible for knowing which shapes are affected by a change to a specific table.

When `add_shape/4` is called, shapes are added to a tree stored in ETS. Each node on the tree represents
an optimised (indexed) condition in the shape's where clause, with shapes that share an optimised condition
being on the same branch.

Each WhereCondition is identified by a unique reference and stores:
- `index_keys`: MapSet of {field_key, operation} tuples for indexed conditions
- `other_shapes`: map of {shape_id, branch_key} -> where_clause for non-optimized shapes

The logic for specific indexes (equality, inclusion) is handled by dedicated modules that also use ETS.

# `add_shape`

# `affected_shapes`

# `all_shape_ids`

# `indexed_where?`

```elixir
@spec indexed_where?(Electric.Replication.Eval.Expr.t() | nil) :: boolean()
```

Returns `true` when the WHERE clause can use the filter's indexed routing
path instead of relying entirely on `other_shapes`.

# `init`

# `remove_shape`

```elixir
@spec remove_shape(
  Electric.Shapes.Filter.t(),
  reference(),
  String.t(),
  Electric.Replication.Eval.Expr.t() | nil
) :: :deleted | :ok
```

Remove a shape from a WhereCondition.

Returns `:deleted` if the condition is now empty and was deleted,
or `:ok` if the condition still has shapes.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
