Skip to content

Commit 1645cd6

Browse files
committed
Cleanup
1 parent 03eb22e commit 1645cd6

File tree

7 files changed

+22
-49
lines changed

7 files changed

+22
-49
lines changed

packages/firestore/src/api_pipelines.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ export {
122122
rand,
123123
array,
124124
arrayOffset,
125-
currentContext,
126125
isError,
127126
ifError,
128127
isAbsent,

packages/firestore/src/core/pipeline-util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ export function toPipeline(query: Query, db: Firestore): Pipeline {
221221
);
222222
}
223223

224-
pipeline = pipeline._limit(query.limit!, true);
224+
pipeline = pipeline.limit(query.limit!, true);
225225
pipeline = pipeline.sort(orderings[0], ...orderings.slice(1));
226226
} else {
227227
pipeline = pipeline.sort(orderings[0], ...orderings.slice(1));

packages/firestore/src/lite-api/expressions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2134,7 +2134,7 @@ export class ExprWithAlias implements Selectable, UserData {
21342134
/**
21352135
* @internal
21362136
*/
2137-
class ListOfExprs extends Expr {
2137+
class ListOfExprs extends Expr implements UserData {
21382138
exprType: ExprType = 'ListOfExprs';
21392139

21402140
constructor(private exprs: Expr[]) {
@@ -2345,7 +2345,7 @@ export function constant(value: string): Constant;
23452345
* @param value The boolean value.
23462346
* @return A new `Constant` instance.
23472347
*/
2348-
export function constant(value: boolean): Constant;
2348+
export function constant(value: boolean): BooleanExpr;
23492349

23502350
/**
23512351
* Creates a `Constant` instance for a null value.

packages/firestore/src/lite-api/pipeline.ts

Lines changed: 5 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -339,21 +339,6 @@ export class Pipeline implements ProtoSerializable<ProtoPipeline> {
339339
return this._addStage(new Limit(limit));
340340
}
341341

342-
/**
343-
* Internal use only.
344-
* Helper to add a limit stage when converting from a Query.
345-
*
346-
* @internal
347-
* @private
348-
*
349-
* @param limit
350-
* @param convertedFromLimitToLast
351-
*/
352-
_limit(limit: number, convertedFromLimitToLast: boolean): Pipeline {
353-
return this._addStage(new Limit(limit, convertedFromLimitToLast));
354-
}
355-
356-
357342
/**
358343
* Returns a set of distinct values from the inputs to this stage.
359344
*
@@ -552,31 +537,11 @@ export class Pipeline implements ProtoSerializable<ProtoPipeline> {
552537
* @param additionalOrderings Optional additional {@link Ordering} instances specifying the additional sorting criteria.
553538
* @return A new {@code Pipeline} object with this stage appended to the stage list.
554539
*/
555-
sort(ordering: Ordering, ...additionalOrderings: Ordering[]): Pipeline;
556-
sort(
557-
optionsOrOrderings:
558-
| Ordering
559-
| {
560-
orderings: Ordering[];
561-
},
562-
...rest: Ordering[]
563-
): Pipeline {
564-
// Option object
565-
if (optionsOrOrderings && 'orderings' in optionsOrOrderings) {
566-
return this._addStage(
567-
new Sort(
568-
this.readUserData(
569-
'sort',
570-
this.readUserData('sort', optionsOrOrderings.orderings)
571-
)
572-
)
573-
);
574-
} else {
575-
// Ordering object
576-
return this._addStage(
577-
new Sort(this.readUserData('sort', [optionsOrOrderings, ...rest]))
578-
);
579-
}
540+
sort(ordering: Ordering, ...additionalOrderings: Ordering[]): Pipeline {
541+
// Ordering object
542+
return this._addStage(
543+
new Sort(this.readUserData('sort', [ordering, ...additionalOrderings]))
544+
);
580545
}
581546

582547
/**

packages/firestore/src/lite-api/stage.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -319,10 +319,7 @@ export class FindNearest implements Stage {
319319
export class Limit implements Stage {
320320
name = 'limit';
321321

322-
constructor(
323-
readonly limit: number,
324-
readonly convertedFromLimitTolast: boolean = false
325-
) {
322+
constructor(readonly limit: number) {
326323
hardAssert(
327324
!isNaN(limit) && limit !== Infinity && limit !== -Infinity,
328325
'Invalid limit value'

packages/firestore/test/integration/api/pipeline.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,6 +1139,18 @@ apiDescribe.only('Pipelines', persistence => {
11391139
{ title: "The Handmaid's Tale" }
11401140
);
11411141
});
1142+
1143+
it('where with boolean constant', async () => {
1144+
const snapshot = await execute(
1145+
firestore
1146+
.pipeline()
1147+
.collection(randomCol.path)
1148+
.where(constant(true))
1149+
.sort(ascending('__name__'))
1150+
.limit(2)
1151+
);
1152+
expectResults(snapshot, 'book1', 'book10');
1153+
});
11421154
});
11431155

11441156
describe('sort, offset, and limit stages', () => {

packages/firestore/test/integration/api/transactions.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import {
3333
runTransaction,
3434
setDoc
3535
} from '../util/firebase_export';
36-
import { apiDescribe, withTestDb } from '../util/helpers';
36+
import { apiDescribe, withTestCollection, withTestDb } from '../util/helpers';
3737

3838
apiDescribe('Database transactions', persistence => {
3939
type TransactionStage = (

0 commit comments

Comments
 (0)