Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
23 changes: 1 addition & 22 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 @@ -175,10 +157,7 @@ export {
FunctionExpression,
Ordering,
BooleanExpression,
AggregateFunction
} from './lite-api/expressions';

export type {
AggregateFunction,
ExpressionType,
AliasedAggregate,
Selectable
Expand Down
11 changes: 6 additions & 5 deletions packages/firestore/src/core/pipeline-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ import {
Ordering,
lessThan,
greaterThan,
field
field,
constant
} from '../lite-api/expressions';
import { Pipeline } from '../lite-api/pipeline';
import { doc } from '../lite-api/reference';
Expand Down Expand Up @@ -55,15 +56,15 @@ export function toPipelineBooleanExpr(f: FilterInternal): BooleanExpression {
const fieldValue = field(f.field.toString());
if (isNanValue(f.value)) {
if (f.op === Operator.EQUAL) {
return and(fieldValue.exists(), fieldValue.isNan());
return and(fieldValue.exists(), fieldValue.equal(constant(NaN)));
} else {
return and(fieldValue.exists(), fieldValue.isNotNan());
return and(fieldValue.exists(), fieldValue.notEqual(constant(NaN)));
}
} else if (isNullValue(f.value)) {
if (f.op === Operator.EQUAL) {
return and(fieldValue.exists(), fieldValue.isNull());
return and(fieldValue.exists(), fieldValue.equal(constant(null)));
} else {
return and(fieldValue.exists(), fieldValue.isNotNull());
return and(fieldValue.exists(), fieldValue.notEqual(constant(null)));
}
} else {
// Comparison filters
Expand Down
15 changes: 11 additions & 4 deletions packages/firestore/test/integration/api/pipeline.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,17 @@ const timestampDeltaMS = 1000;
expectedStructuredPipelineProto
);
});

it('performs validation', async () => {
expect(() => {
const pipeline = firestore
.pipeline()
.collection('customers')
.where(field('country').equal(new Map([])));

_internalPipelineToExecutePipelineRequestProto(pipeline);
}).to.throw();
});
});

describe('pipeline results', () => {
Expand Down Expand Up @@ -1218,7 +1229,6 @@ const timestampDeltaMS = 1000;
.select('title', 'author')
.sort(field('author').ascending())
.removeFields(field('author'))
.sort(field('author').ascending())
);
expectResults(
snapshot,
Expand Down Expand Up @@ -1259,7 +1269,6 @@ const timestampDeltaMS = 1000;
.removeFields({
fields: [field('author'), 'genre']
})
.sort(field('author').ascending())
);
expectResults(
snapshot,
Expand Down Expand Up @@ -1300,7 +1309,6 @@ const timestampDeltaMS = 1000;
.select('title', 'author')
.sort(field('author').ascending())
.removeFields(field('author'))
.sort(field('author').ascending())
);
expectResults(
snapshot,
Expand Down Expand Up @@ -1341,7 +1349,6 @@ const timestampDeltaMS = 1000;
.removeFields({
fields: [field('author'), 'genre']
})
.sort(field('author').ascending())
);
expectResults(
snapshot,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ import {
documentId,
addDoc,
getDoc,
or
or,
getDocs
} from '../util/firebase_export';
import {
apiDescribe,
Expand Down Expand Up @@ -647,7 +648,7 @@ const testUnsupportedFeatures: boolean | 'only' = false;
async (collRef, db) => {
const query1 = query(collRef, where('bar', '!=', NaN));
const snapshot = await execute(db.pipeline().createFrom(query1));
verifyResults(snapshot, { foo: 2, bar: 1 });
verifyResults(snapshot, { foo: 2, bar: 1 }, { foo: 3, bar: 'bar' });
}
);
});
Expand All @@ -661,8 +662,10 @@ const testUnsupportedFeatures: boolean | 'only' = false;
},
async (collRef, db) => {
const query1 = query(collRef, where('bar', '==', null));
const classicSnapshot = await getDocs(query1);
const classicData = classicSnapshot.docs.map(d => d.data());
const snapshot = await execute(db.pipeline().createFrom(query1));
verifyResults(snapshot, { foo: 1, bar: null });
verifyResults(snapshot, ...classicData);
}
);
});
Expand All @@ -676,8 +679,10 @@ const testUnsupportedFeatures: boolean | 'only' = false;
},
async (collRef, db) => {
const query1 = query(collRef, where('bar', '!=', null));
const classicSnapshot = await getDocs(query1);
const classicData = classicSnapshot.docs.map(d => d.data());
const snapshot = await execute(db.pipeline().createFrom(query1));
verifyResults(snapshot, { foo: 2, bar: 1 });
verifyResults(snapshot, ...classicData);
}
);
});
Expand Down
Loading