Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions integration/firestore/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,21 +70,21 @@ if (typeof process === 'undefined') {
)
)
.pipe(
replace(
/**
* This regex is designed to match the Firebase import in our
* integration tests.
*/
/\s+from '\.(\.\/util)?\/pipeline_export';/,
` from '${resolve(__dirname, './pipeline_export')}';
replace(
/**
* This regex is designed to match the Firebase import in our
* integration tests.
*/
/\s+from '\.(\.\/util)?\/pipeline_export';/,
` from '${resolve(__dirname, './pipeline_export')}';

if (typeof process === 'undefined') {
process = { env: { INCLUDE_FIRESTORE_PERSISTENCE: '${isPersistenceEnabled()}' } } as any;
} else {
process.env.INCLUDE_FIRESTORE_PERSISTENCE = '${isPersistenceEnabled()}';
}
`
)
)
)
.pipe(
/**
Expand Down
24 changes: 20 additions & 4 deletions packages/firestore/lite/pipelines/pipelines.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,7 @@ export {
isError,
or,
divide,
isNotNan,
map,
isNotNull,
isNull,
mod,
documentId,
equal,
Expand All @@ -128,7 +125,6 @@ export {
logicalMaximum,
logicalMinimum,
exists,
isNan,
reverse,
byteLength,
charLength,
Expand Down Expand Up @@ -160,6 +156,26 @@ export {
timestampSubtract,
ascending,
descending,
arrayGet,
abs,
sum,
countDistinct,
ceil,
floor,
exp,
pow,
round,
collectionId,
ln,
log,
sqrt,
stringReverse,
log10,
concat,
currentTimestamp,
ifAbsent,
join,
arraySum,
AliasedExpression,
Field,
Constant,
Expand Down
28 changes: 1 addition & 27 deletions packages/firestore/src/api_pipelines.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,24 +53,6 @@ export {
SortStageOptions
} from './lite-api/stage_options';

export {
Stage,
AddFields,
Aggregate,
Distinct,
CollectionSource,
CollectionGroupSource,
DatabaseSource,
DocumentsSource,
Where,
FindNearest,
Limit,
Offset,
Select,
Sort,
RawStage
} from './lite-api/stage';

export {
field,
constant,
Expand Down Expand Up @@ -98,7 +80,6 @@ export {
logicalMaximum,
logicalMinimum,
exists,
isNan,
reverse,
byteLength,
charLength,
Expand Down Expand Up @@ -141,9 +122,6 @@ export {
isError,
ifError,
isAbsent,
isNull,
isNotNull,
isNotNan,
map,
mapRemove,
mapMerge,
Expand All @@ -164,7 +142,6 @@ export {
abs,
concat,
currentTimestamp,
error,
ifAbsent,
join,
log10,
Expand All @@ -175,10 +152,7 @@ export {
FunctionExpression,
Ordering,
BooleanExpression,
AggregateFunction
} from './lite-api/expressions';

export type {
AggregateFunction,
ExpressionType,
AliasedAggregate,
Selectable
Expand Down
147 changes: 66 additions & 81 deletions packages/firestore/src/core/pipeline-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import {
} from '../lite-api/expressions';
import { Pipeline } from '../lite-api/pipeline';
import { doc } from '../lite-api/reference';
import { isNanValue, isNullValue } from '../model/values';
import { fail } from '../util/assert';

import { Bound } from './bound';
Expand All @@ -53,90 +52,76 @@ import {
export function toPipelineBooleanExpr(f: FilterInternal): BooleanExpression {
if (f instanceof FieldFilterInternal) {
const fieldValue = field(f.field.toString());
if (isNanValue(f.value)) {
if (f.op === Operator.EQUAL) {
return and(fieldValue.exists(), fieldValue.isNan());
} else {
return and(fieldValue.exists(), fieldValue.isNotNan());
// Comparison filters
const value = f.value;
switch (f.op) {
case Operator.LESS_THAN:
return and(
fieldValue.exists(),
fieldValue.lessThan(Constant._fromProto(value))
);
case Operator.LESS_THAN_OR_EQUAL:
return and(
fieldValue.exists(),
fieldValue.lessThanOrEqual(Constant._fromProto(value))
);
case Operator.GREATER_THAN:
return and(
fieldValue.exists(),
fieldValue.greaterThan(Constant._fromProto(value))
);
case Operator.GREATER_THAN_OR_EQUAL:
return and(
fieldValue.exists(),
fieldValue.greaterThanOrEqual(Constant._fromProto(value))
);
case Operator.EQUAL:
return and(
fieldValue.exists(),
fieldValue.equal(Constant._fromProto(value))
);
case Operator.NOT_EQUAL:
return and(
fieldValue.exists(),
fieldValue.notEqual(Constant._fromProto(value))
);
case Operator.ARRAY_CONTAINS:
return and(
fieldValue.exists(),
fieldValue.arrayContains(Constant._fromProto(value))
);
case Operator.IN: {
const values = value?.arrayValue?.values?.map((val: any) =>
Constant._fromProto(val)
);
if (!values) {
return and(fieldValue.exists(), fieldValue.equalAny([]));
} else if (values.length === 1) {
return and(fieldValue.exists(), fieldValue.equal(values[0]));
} else {
return and(fieldValue.exists(), fieldValue.equalAny(values));
}
}
} else if (isNullValue(f.value)) {
if (f.op === Operator.EQUAL) {
return and(fieldValue.exists(), fieldValue.isNull());
} else {
return and(fieldValue.exists(), fieldValue.isNotNull());
case Operator.ARRAY_CONTAINS_ANY: {
const values = value?.arrayValue?.values?.map((val: any) =>
Constant._fromProto(val)
);
return and(fieldValue.exists(), fieldValue.arrayContainsAny(values!));
}
} else {
// Comparison filters
const value = f.value;
switch (f.op) {
case Operator.LESS_THAN:
return and(
fieldValue.exists(),
fieldValue.lessThan(Constant._fromProto(value))
);
case Operator.LESS_THAN_OR_EQUAL:
return and(
fieldValue.exists(),
fieldValue.lessThanOrEqual(Constant._fromProto(value))
);
case Operator.GREATER_THAN:
return and(
fieldValue.exists(),
fieldValue.greaterThan(Constant._fromProto(value))
);
case Operator.GREATER_THAN_OR_EQUAL:
return and(
fieldValue.exists(),
fieldValue.greaterThanOrEqual(Constant._fromProto(value))
);
case Operator.EQUAL:
return and(
fieldValue.exists(),
fieldValue.equal(Constant._fromProto(value))
);
case Operator.NOT_EQUAL:
return and(
fieldValue.exists(),
fieldValue.notEqual(Constant._fromProto(value))
);
case Operator.ARRAY_CONTAINS:
return and(
fieldValue.exists(),
fieldValue.arrayContains(Constant._fromProto(value))
);
case Operator.IN: {
const values = value?.arrayValue?.values?.map((val: any) =>
Constant._fromProto(val)
);
if (!values) {
return and(fieldValue.exists(), fieldValue.equalAny([]));
} else if (values.length === 1) {
return and(fieldValue.exists(), fieldValue.equal(values[0]));
} else {
return and(fieldValue.exists(), fieldValue.equalAny(values));
}
}
case Operator.ARRAY_CONTAINS_ANY: {
const values = value?.arrayValue?.values?.map((val: any) =>
Constant._fromProto(val)
);
return and(fieldValue.exists(), fieldValue.arrayContainsAny(values!));
}
case Operator.NOT_IN: {
const values = value?.arrayValue?.values?.map((val: any) =>
Constant._fromProto(val)
);
if (!values) {
return and(fieldValue.exists(), fieldValue.notEqualAny([]));
} else if (values.length === 1) {
return and(fieldValue.exists(), fieldValue.notEqual(values[0]));
} else {
return and(fieldValue.exists(), fieldValue.notEqualAny(values));
}
case Operator.NOT_IN: {
const values = value?.arrayValue?.values?.map((val: any) =>
Constant._fromProto(val)
);
if (!values) {
return and(fieldValue.exists(), fieldValue.notEqualAny([]));
} else if (values.length === 1) {
return and(fieldValue.exists(), fieldValue.notEqual(values[0]));
} else {
return and(fieldValue.exists(), fieldValue.notEqualAny(values));
}
default:
fail(0x9047, 'Unexpected operator');
}
default:
fail(0x9047, 'Unexpected operator');
}
} else if (f instanceof CompositeFilterInternal) {
switch (f.op) {
Expand Down
Loading
Loading