From bb16ca128cec4abdc3718ab65622ce344eb9fc5f Mon Sep 17 00:00:00 2001 From: Wu-Hui Date: Tue, 21 May 2024 10:33:09 -0400 Subject: [PATCH] Fix missing asAlias --- .../com/google/cloud/firestore/pipeline/Expressions.kt | 6 ++++++ .../java/com/google/cloud/firestore/pipeline/Stages.kt | 9 +++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt index 9ce8210ef..5923f487c 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt @@ -49,6 +49,8 @@ internal fun exprToValue(expr: Expr): Value { interface Projectable +internal class ExprWithAlias internal constructor(val alias: String, val expr: Expr) : Projectable + interface Expr { // Infix functions returning Function subclasses infix fun equal(other: Expr) = Equal(this, other) @@ -143,6 +145,10 @@ interface Expr { fun descending(): Ordering { return Ordering(this, Direction.DESCENDING) } + + fun asAlias(alias: String): Projectable { + return ExprWithAlias(alias, this) + } } // Convenient class for internal usage diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Stages.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Stages.kt index 43f72d2a9..f8f540b10 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Stages.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Stages.kt @@ -104,10 +104,15 @@ internal constructor( } } - class FindNearestOptions(val limit: Long, val output: Field? = null) { + class FindNearestOptions internal constructor( + val limit: Long, + val distanceMeasure: DistanceMeasure, + val output: Field? = null + ) { companion object { @JvmStatic - fun newInstance(limit: Long, output: Field? = null) = FindNearestOptions(limit, output) + fun newInstance(limit: Long, distanceMeasure: DistanceMeasure, output: Field? = null) = + FindNearestOptions(limit, distanceMeasure, output) } } }