Skip to content

Commit eef315c

Browse files
committed
Document EXCEPT and EXCEPT ALL set operations
Adds documentation for the new except() and exceptAll() methods on SelectQuery, covering supported platforms for EXCEPT ALL.
1 parent 7f1f801 commit eef315c

2 files changed

Lines changed: 37 additions & 0 deletions

File tree

docs/en/appendices/5-4-migration-guide.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ version is reported as `unknown`), the header is omitted.
9898
See [Query Builder](../orm/query-builder#advanced-conditions).
9999
- Added `inOrNull()` and `notInOrNull()` methods for combining `IN` conditions with `IS NULL`.
100100
- Added `isDistinctFrom()` and `isNotDistinctFrom()` methods for null-safe comparisons.
101+
- Added `except()` and `exceptAll()` methods on `SelectQuery` for `EXCEPT`
102+
and `EXCEPT ALL` set operations. `EXCEPT ALL` is supported on PostgreSQL
103+
and recent MySQL/MariaDB versions; it is not supported on SQLite or SQL Server.
104+
See [Query Builder](../orm/query-builder#except).
101105
- Added PostgreSQL index access method reflection. Non-btree indexes (`gin`,
102106
`gist`, `spgist`, `brin`, `hash`) are now reflected with an `accessMethod`
103107
field and regenerated with the correct `USING` clause. The `Index` class

docs/en/orm/query-builder.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2200,6 +2200,39 @@ $unpublished->intersectAll($inReview);
22002200
`intersect()` and `intersectAll()` were added.
22012201
:::
22022202

2203+
### Except
2204+
2205+
Except operations allow you to return rows from one query that do not appear
2206+
in another query. Except queries are created by composing one or more select
2207+
queries together:
2208+
2209+
```php
2210+
$allArticles = $articles->find();
2211+
2212+
$published = $articles->find()
2213+
->where(['published' => true]);
2214+
2215+
$allArticles->except($published);
2216+
```
2217+
2218+
You can create `EXCEPT ALL` queries using the `exceptAll()` method:
2219+
2220+
```php
2221+
$allArticles = $articles->find();
2222+
2223+
$published = $articles->find()
2224+
->where(['published' => true]);
2225+
2226+
$allArticles->exceptAll($published);
2227+
```
2228+
2229+
`EXCEPT ALL` is supported on PostgreSQL and recent MySQL/MariaDB versions.
2230+
It is not supported on SQLite or SQL Server.
2231+
2232+
::: info Added in version 5.4.0
2233+
`except()` and `exceptAll()` were added.
2234+
:::
2235+
22032236
### Subqueries
22042237

22052238
Subqueries enable you to compose queries together and build conditions and

0 commit comments

Comments
 (0)