-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Open
Labels
Milestone
Description
After #19360 I did a deep dive into other missing functionality
Some are postgres only, others are also not supported across multiple DBs.
The following seems to have enough viable traction to support IMO
Summary
Add support for EXCEPT and EXCEPT ALL set operations to complement the existing UNION, UNION ALL, INTERSECT, and INTERSECT ALL methods.
Database Support
| Operation | PostgreSQL | MySQL | SQLite | SQL Server |
|---|---|---|---|---|
EXCEPT |
✅ | ✅ (8.0.31+) | ✅ | ✅ |
EXCEPT ALL |
✅ | ❌ | ✅ (3.39+) | ✅ |
Proposed API
$query1 = $this->Users->find()->select(['email']);
$query2 = $this->Admins->find()->select(['email']);
// Users that are not admins
$query1->except($query2);
// With duplicates preserved
$query1->exceptAll($query2);Notes
EXCEPThas broad support across all major databasesEXCEPT ALLis not supported by MySQL - could either throw an exception or document the limitation- Implementation should follow the same pattern as existing
union(),unionAll(),intersect(),intersectAll()methods
Reactions are currently unavailable