From 6f79b41bc12814f75ebc19956eb930fbc50e88b5 Mon Sep 17 00:00:00 2001 From: Michael Kane Juncker Date: Tue, 5 Apr 2022 19:03:35 +0200 Subject: [PATCH] feat(api): add match/imatch operators for regular expression support - refs PostgREST/postgrest#2236 --- docs/api.rst | 13 ++++++++++++- postgrest.dict | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/docs/api.rst b/docs/api.rst index d1503fd42..7ae36a41a 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -69,6 +69,8 @@ lte :code:`<=` less than or equal neq :code:`<>` or :code:`!=` not equal like :code:`LIKE` LIKE operator (use * in place of %) ilike :code:`ILIKE` ILIKE operator (use * in place of %) +match :code:`~` ~ operator, see :ref:`pattern_matching` +imatch :code:`~*` ~* operator, see :ref:`pattern_matching` in :code:`IN` one of a list of values, e.g. :code:`?a=in.(1,2,3)` – also supports commas in quoted strings like :code:`?a=in.("hi,there","yes,you")` @@ -146,6 +148,15 @@ You can also apply complex logic to the conditions: curl "http://localhost:3000/people?grade=gte.90&student=is.true&or=(age.eq.14,not.and(age.gte.11,age.lte.17))" +.. _pattern_matching: + +Pattern Matching +~~~~~~~~~~~~~~~~ + +The pattern-matching operators (:code:`like`, :code:`ilike`, :code:`match`, :code:`imatch`) exist to support filtering data using patterns instead of concrete strings, as described in the `PostgreSQL docs `__. + +To ensure best performance on larger data sets, an `appropriate index `__ should be used and even then, it depends on the pattern value and actual data statistics whether an existing index will be used by the query planner or not. + .. _fts: Full-Text Search @@ -272,7 +283,7 @@ Casting the columns is possible by suffixing them with the double colon ``::`` p JSON Columns ------------ -You can specify a path for a ``json`` or ``jsonb`` column using the arrow operators(``->`` or ``->>``) as per the `PostgreSQL docs `_. +You can specify a path for a ``json`` or ``jsonb`` column using the arrow operators(``->`` or ``->>``) as per the `PostgreSQL docs `__. .. code-block:: postgres diff --git a/postgrest.dict b/postgrest.dict index f9cc140fc..f9861cce2 100644 --- a/postgrest.dict +++ b/postgrest.dict @@ -60,6 +60,7 @@ HTTPS HV Ibarluzea ilike +imatch io IP JS