Skip to content

Commit d581aed

Browse files
committed
test(spec): name $empty among the flag operators in the number-comparand door's partition
The #20336 pin partitions FieldOperatorsSchema's keys into the judged positions, the text operators and the boolean flags; $empty is a flag (a boolean, not a value of the field), so it joins $null / $exists there, in the module's "Not judged" docblock and as an unjudged case row. The door's verdict logic is unchanged. Claude-Session: https://claude.ai/code/session_01B3TqpoQbTAfG7G74GMDWNW Co-authored-by: Claude <noreply@anthropic.com>
1 parent 859d9bd commit d581aed

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

‎packages/spec/src/data/filter-number-comparand-declared-type.test.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,10 @@ describe('[#20336] the judged fields', () => {
158158
// ── Which positions ──────────────────────────────────────────────────────────
159159

160160
describe('[#20336] the judged positions', () => {
161-
it('partition FieldOperatorsSchema\'s keys with the text operators and the two flag operators', () => {
161+
it('partition FieldOperatorsSchema\'s keys with the text operators and the three flag operators', () => {
162162
const judged = [...NUMBER_COMPARAND_DOOR_SCALAR_OPERATORS, ...NUMBER_COMPARAND_DOOR_LIST_OPERATORS];
163-
const partition = [...judged, ...TEXT_FILTER_OPERATORS, '$null', '$exists'];
163+
// [#20311] `$empty` is a boolean flag like `$null` / `$exists`, not a value of the field.
164+
const partition = [...judged, ...TEXT_FILTER_OPERATORS, '$null', '$exists', '$empty'];
164165
expect(new Set(partition).size, 'the four parts overlap').toBe(partition.length);
165166
expect(sorted(partition)).toEqual(sorted(Object.keys(FieldOperatorsSchema.shape)));
166167
});

‎packages/spec/src/data/filter-number-comparand-declared-type.ts‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118
* The implicit-equality comparand, `$eq` / `$ne` / `$gt` / `$gte` / `$lt` /
119119
* `$lte` ({@link NUMBER_COMPARAND_DOOR_SCALAR_OPERATORS}), and every MEMBER of
120120
* `$in` / `$nin` / `$between` ({@link NUMBER_COMPARAND_DOOR_LIST_OPERATORS}).
121-
* Not judged: `$null` / `$exists` (a boolean flag, not a value of the field),
121+
* Not judged: `$null` / `$exists` / `$empty` (a boolean flag, not a value of the field),
122122
* the text operators (their comparand is a substring or pattern, and over a
123123
* numeric field they are refused one door earlier by the text door, #15661),
124124
* a `{ $field }` reference (not a literal), and a DOTTED key (a dotted path
@@ -739,8 +739,8 @@ const JUDGED_SLOTS: readonly Slot[] = [
739739
* refused string, a narrowed numeric string, and a number (passes).
740740
* 3. **The grammar** — every {@link NUMERIC_STRING_GRAMMAR_CASES} row at `$eq`
741741
* on `f_number`.
742-
* 4. **The unjudged positions** — `$null`, `$exists` and a `{ $field }`
743-
* reference on `f_number` pass.
742+
* 4. **The unjudged positions** — `$null`, `$exists`, `$empty` and a
743+
* `{ $field }` reference on `f_number` pass.
744744
*/
745745
export const NUMBER_COMPARAND_DOOR_CASES: readonly NumberComparandDoorCase[] = [
746746
...NUMBER_COMPARAND_DOOR_FIXTURE_FIELDS.map((field) =>
@@ -756,6 +756,8 @@ export const NUMBER_COMPARAND_DOOR_CASES: readonly NumberComparandDoorCase[] = [
756756
'A null test takes a boolean flag, not a value of the field.'),
757757
caseFor('unjudged', fixtureField('f_number'), { kind: 'scalar', op: '$exists' }, false,
758758
'An existence test takes a boolean flag, not a value of the field.'),
759+
caseFor('unjudged', fixtureField('f_number'), { kind: 'scalar', op: '$empty' }, true,
760+
'An emptiness test takes a boolean flag, not a value of the field.'),
759761
caseFor('unjudged', fixtureField('f_number'), { kind: 'scalar', op: '$gt' }, { $field: 'f_currency' },
760762
'A field reference is not a literal.'),
761763
];

0 commit comments

Comments
 (0)