Skip to content

Commit 5ba0f6c

Browse files
author
Kirill Fuks
committed
chore: document complex logic conditions and add new feature to changelog
1 parent 4301708 commit 5ba0f6c

File tree

2 files changed

+53
-1
lines changed

2 files changed

+53
-1
lines changed

CHANGELOG.rst

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,37 @@ Versioning <https://semver.org/spec/v2.0.0.html>`__.
1313
:depth: 1
1414

1515
`[Unreleased] <https://campoint.github.io/postgrest-php/latest>`_
16-
-----------------------------------------------------------
16+
-----------------------------------------------------------------
17+
18+
Added
19+
~~~~~
20+
21+
- Support for complex logic conditions using and/or (`#4 <https://github.com/Campoint/postgrest-php/pull/4>`_)
22+
23+
Changed
24+
~~~~~~~
25+
26+
- n/a
27+
28+
Deprecated
29+
~~~~~~~~~~
30+
31+
- n/a
32+
33+
Removed
34+
~~~~~~~
35+
36+
- n/a
37+
38+
Fixed
39+
~~~~~
40+
41+
- n/a
42+
43+
Security
44+
~~~~~~~~
45+
46+
- n/a
1747

1848
`[0.0.1] <https://campoint.github.io/postgrest-php/0.0.1>`_ - 2023-07-24
1949
------------------------------------------------------------------------

docs/guides/request-builder/index.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,28 @@ pass it to the ``run()`` method of the client.
3131
3232
$response = $client->run($query);
3333
34+
Complex logic conditions
35+
~~~~~~~~~~~~~~~~~~~~~~~~
36+
37+
The ``PostgrestRequestBuilder`` supports complex logic conditions using ``and``/ ``or``.
38+
Unfortunately, when using ``and``/ ``or`` the ``PostgrestRequestBuilder`` will not be able to,
39+
escape the values for you. You will have to escape the values yourself.
40+
41+
.. code:: php
42+
43+
$query = $client->from('schema_name', 'table_name')
44+
->select('*')
45+
->or(
46+
(new LogicOperatorCondition('a', FilterOperator::EQUAL, 42)),
47+
(new LogicOperatorCondition('b', FilterOperator::LESS_THAN, 2.0, negate: true)),
48+
// escape strings yourself
49+
(new LogicOperatorCondition('c', FilterOperator::IN, '("foo bar",bar)')),
50+
);
51+
52+
Nested complex logic conditions are not supported using the LogicOperatorCondition class.
53+
You will need to build the string yourself. You can implement your own logic condition class
54+
which implements the ``Stringable`` interface, as the functions ``or()`` and ``and()`` accept this interface.
55+
3456
Exceptions
3557
----------
3658

0 commit comments

Comments
 (0)