Skip to content

Commit 7f218bd

Browse files
Copilothotlong
andcommitted
fix: Remove unsupported $not operator and clarify limitations
- Remove incomplete $not operator implementation - Throw clear error if $not is used - Update documentation to reflect limitation - Recommend using $ne for field-level negation instead - All 290 tests still passing Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 5cbfbc4 commit 7f218bd

2 files changed

Lines changed: 14 additions & 12 deletions

File tree

docs/filter-syntax.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,20 @@ const results = await repo.find({
190190

191191
### NOT
192192

193+
> **Note**: The `$not` operator is not currently supported when using the backward-compatible translation layer. Use `$ne` (not equal) for field-level negation instead.
194+
193195
```typescript
196+
// ❌ Not supported
197+
const results = await repo.find({
198+
filters: {
199+
$not: { status: 'deleted' }
200+
}
201+
});
202+
203+
// ✅ Use $ne instead
194204
const results = await repo.find({
195205
filters: {
196-
$not: {
197-
status: 'deleted'
198-
}
206+
status: { $ne: 'deleted' }
199207
}
200208
});
201209
```
@@ -297,7 +305,6 @@ const urgentTasks = await repo.find({
297305
| `$exist` | Field exists | `{ metadata: { $exist: true } }` |
298306
| `$and` | Logical AND | `{ $and: [{...}, {...}] }` |
299307
| `$or` | Logical OR | `{ $or: [{...}, {...}] }` |
300-
| `$not` | Logical NOT | `{ $not: {...} }` |
301308

302309
## Migration Guide
303310

packages/foundation/core/src/repository.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,10 @@ export class ObjectRepository {
8989
nodes.push(...this.interleaveWithOperator(orNodes, 'or'));
9090
}
9191

92+
// Note: $not operator is not currently supported in the legacy FilterNode format
93+
// Users should use $ne (not equal) instead for negation on specific fields
9294
if (filter.$not) {
93-
// NOT operator: convert to array of negated conditions
94-
// This is a simplification - proper implementation would need driver support
95-
const notNode = this.convertFilterToNode(filter.$not);
96-
if (nodes.length > 0) {
97-
nodes.push('and');
98-
}
99-
// Wrap in array to indicate it's a NOT group
100-
nodes.push(['not', notNode]);
95+
throw new Error('$not operator is not supported. Use $ne for field negation instead.');
10196
}
10297

10398
// Process field conditions

0 commit comments

Comments
 (0)