@@ -24,13 +24,11 @@ import {
24
24
andFunction ,
25
25
orFunction ,
26
26
Ordering ,
27
- And ,
28
27
lt ,
29
28
gt ,
30
29
lte ,
31
30
gte ,
32
- eq ,
33
- Or
31
+ eq
34
32
} from '../lite-api/expressions' ;
35
33
import { Pipeline } from '../lite-api/pipeline' ;
36
34
import { doc } from '../lite-api/reference' ;
@@ -61,9 +59,9 @@ export function toPipelineBooleanExpr(f: FilterInternal): BooleanExpr {
61
59
const field = Field . of ( f . field . toString ( ) ) ;
62
60
if ( isNanValue ( f . value ) ) {
63
61
if ( f . op === Operator . EQUAL ) {
64
- return andFunction ( field . exists ( ) , field . isNaN ( ) ) ;
62
+ return andFunction ( field . exists ( ) , field . isNan ( ) ) ;
65
63
} else {
66
- return andFunction ( field . exists ( ) , not ( field . isNaN ( ) ) ) ;
64
+ return andFunction ( field . exists ( ) , not ( field . isNan ( ) ) ) ;
67
65
}
68
66
} else if ( isNullValue ( f . value ) ) {
69
67
if ( f . op === Operator . EQUAL ) {
@@ -249,11 +247,11 @@ function whereConditionsFromCursor(
249
247
const filterFunc = position === 'before' ? lt : gt ;
250
248
const filterInclusiveFunc = position === 'before' ? lte : gte ;
251
249
252
- const orConditions = [ ] ;
250
+ const orConditions : BooleanExpr [ ] = [ ] ;
253
251
for ( let i = 1 ; i <= orderings . length ; i ++ ) {
254
252
const cursorSubset = cursors . slice ( 0 , i ) ;
255
253
256
- const conditions = cursorSubset . map ( ( cursor , index ) => {
254
+ const conditions : BooleanExpr [ ] = cursorSubset . map ( ( cursor , index ) => {
257
255
if ( index < cursorSubset . length - 1 ) {
258
256
return eq ( orderings [ index ] . expr as Field , cursor ) ;
259
257
} else if ( ! ! bound . inclusive && i === orderings . length ) {
@@ -266,13 +264,19 @@ function whereConditionsFromCursor(
266
264
if ( conditions . length === 1 ) {
267
265
orConditions . push ( conditions [ 0 ] ) ;
268
266
} else {
269
- orConditions . push ( new And ( conditions ) ) ;
267
+ orConditions . push (
268
+ andFunction ( conditions [ 0 ] , conditions [ 1 ] , ...conditions . slice ( 2 ) )
269
+ ) ;
270
270
}
271
271
}
272
272
273
273
if ( orConditions . length === 1 ) {
274
274
return orConditions [ 0 ] ;
275
275
} else {
276
- return new Or ( orConditions ) ;
276
+ return orFunction (
277
+ orConditions [ 0 ] ,
278
+ orConditions [ 1 ] ,
279
+ ...orConditions . slice ( 2 )
280
+ ) ;
277
281
}
278
282
}
0 commit comments