@@ -71,25 +71,22 @@ const WITHHELD_POSITION = 'pos_finance_controller';
7171
7272type Row = Record < string , unknown > ;
7373
74- /** The equality / `$in` / `$nin` subset the tool's selections use; anything else is loud. */
74+ /**
75+ * The equality / `$in` / `$nin` subset the tool's selections use. Anything
76+ * else is loud: a combinator (`$and`, `$or`, …) is refused rather than read as
77+ * a field name, and so is an operator this double does not model.
78+ */
7579function matches ( row : Row , where : Record < string , unknown > | undefined ) : boolean {
76- for ( const [ key , cond ] of Object . entries ( where ?? { } ) ) {
80+ return Object . entries ( where ?? { } ) . every ( ( [ key , cond ] ) => {
81+ if ( key . startsWith ( '$' ) ) throw new Error ( `engine double: combinator ${ key } is not modelled` ) ;
7782 const cell = row [ key ] ;
78- if ( cond !== null && typeof cond === 'object' && ! Array . isArray ( cond ) ) {
79- for ( const [ op , operand ] of Object . entries ( cond as Record < string , unknown > ) ) {
80- if ( op === '$in' ) {
81- if ( ! ( operand as unknown [ ] ) . includes ( cell ) ) return false ;
82- } else if ( op === '$nin' ) {
83- if ( ( operand as unknown [ ] ) . includes ( cell ) ) return false ;
84- } else {
85- throw new Error ( `engine double: operator ${ op } is not modelled` ) ;
86- }
87- }
88- } else if ( cell !== cond ) {
89- return false ;
90- }
91- }
92- return true ;
83+ if ( cond === null || typeof cond !== 'object' || Array . isArray ( cond ) ) return cell === cond ;
84+ return Object . entries ( cond as Record < string , unknown > ) . every ( ( [ op , operand ] ) => {
85+ if ( op === '$in' ) return ( operand as unknown [ ] ) . includes ( cell ) ;
86+ if ( op === '$nin' ) return ! ( operand as unknown [ ] ) . includes ( cell ) ;
87+ throw new Error ( `engine double: operator ${ op } is not modelled` ) ;
88+ } ) ;
89+ } ) ;
9390}
9491
9592/** objectql's `SummaryRecomputeError`, as a write's caller reads it: by `code`, carrying `written`. */
0 commit comments