Skip to content

Commit

Permalink
docs: where clause limitations with feature request CTA. (#1773)
Browse files Browse the repository at this point in the history
Partly addresses #1769
although it would be much better to add more technical details.


https://deploy-preview-1773--electric-next.netlify.app/docs/guides/shapes#where-clause

---------

Co-authored-by: Oleksii Sholik <[email protected]>
  • Loading branch information
thruflo and alco authored Oct 8, 2024
1 parent 78eab76 commit 6607089
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions website/docs/guides/shapes.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,22 @@ You can use logical operators like `AND` and `OR` to group multiple conditions,
- `title='Electric' OR title='SQL'`
- `title='Electric' AND status='todo'`

Where clauses can only refer to columns in the target row; you can't perform joins or refer to other tables. Where clauses also can't use SQL functions like `count()`.
> [!WARNING] Limitations
> Electric needs to be able to evaluate where clauses outside of Postgres, so it only supports a limited set of SQL types and expressions right now.
> 1. you can use columns of numerical types, `boolean`, `uuid`, `text`, `interval`, date and time types (with the exception of `timetz`)
> 1. operators that work on those types: arithmetics, comparisons, boolean operators like `OR`, string operators like `LIKE`, etc.
> 1. [Arrays](https://github.com/electric-sql/electric/issues/1767) and [Enums](https://github.com/electric-sql/electric/issues/1709) are not yet supported in where clauses
>
> For the full and up-to-date list of supported types, operators and functions, see their implementation in [`known_functions.ex`](https://github.com/electric-sql/electric/blob/main/packages/sync-service/lib/electric/replication/eval/env/known_functions.ex), while some expressions are handled in the [parser](https://github.com/electric-sql/electric/blob/main/packages/sync-service/lib/electric/replication/eval/parser.ex) (look for the `do_parse_and_validate_tree()` function).
>
> ---
>
> Some general rules that shape where clauses abide by are:
> 1. where clauses can only refer to columns in the target row
> 1. where clauses can't perform joins or refer to other tables
> 1. where clauses can't use non-deterministic SQL functions like `count()` or `now()`
>
> If you need to use a data type or where clause feature that isn't yet supported, please feel free to [raise a Feature Request](https://github.com/electric-sql/electric/discussions/categories/feature-requests) on GitHub.
## Subscribing to shapes

Expand Down Expand Up @@ -180,4 +195,4 @@ When dropping a table from Postgres you need to *manually* delete all shapes tha
This is especially important if you intend to recreate the table afterwards (possibly with a different schema) as the shape will contain stale data from the old table.
Therefore, recreating the table only works if you first delete the shape.

Electric does not yet automatically delete shapes when tables are dropped because Postgres does not stream DDL statements (such as `DROP TABLE`) on the logical replication stream that Electric uses to detect changes. However, we are actively exploring approaches for automated shape deletion in this [GitHub issue](https://github.com/electric-sql/electric/issues/1733).
Electric does not yet automatically delete shapes when tables are dropped because Postgres does not stream DDL statements (such as `DROP TABLE`) on the logical replication stream that Electric uses to detect changes. However, we are actively exploring approaches for automated shape deletion in this [GitHub issue](https://github.com/electric-sql/electric/issues/1733).

0 comments on commit 6607089

Please sign in to comment.