Skip to content

Commit 77dfc07

Browse files
committed
Fixes
1 parent bbe85f4 commit 77dfc07

File tree

5 files changed

+32
-37
lines changed

5 files changed

+32
-37
lines changed

firebase-firestore/src/main/java/com/google/firebase/firestore/model/Document.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ public interface Document {
3535
*/
3636
SnapshotVersion getVersion();
3737

38+
SnapshotVersion getCreateTime();
39+
3840
/**
3941
* Returns the timestamp at which this document was read from the remote server. Returns
4042
* `SnapshotVersion.NONE` for documents created by the user.

firebase-firestore/src/main/java/com/google/firebase/firestore/model/FieldPath.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@
2222
/** A dot separated path for navigating sub-objects with in a document */
2323
public final class FieldPath extends BasePath<FieldPath> {
2424

25+
public static final String UPDATE_TIME_NAME = "__update_time__";
26+
public static final String CREATE_TIME_NAME = "__create_time__";
27+
2528
public static final FieldPath KEY_PATH = fromSingleSegment(DocumentKey.KEY_FIELD_NAME);
29+
public static final FieldPath UPDATE_TIME_PATH = fromSingleSegment(UPDATE_TIME_NAME);
30+
public static final FieldPath CREATE_TIME_PATH = fromSingleSegment(CREATE_TIME_NAME);
2631
public static final FieldPath EMPTY_PATH = new FieldPath(Collections.emptyList());
2732

2833
private FieldPath(List<String> segments) {

firebase-firestore/src/main/java/com/google/firebase/firestore/model/MutableDocument.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ private enum DocumentState {
6363
private DocumentType documentType;
6464
private SnapshotVersion version;
6565
private SnapshotVersion readTime;
66+
private SnapshotVersion createTime;
6667
private ObjectValue value;
6768
private DocumentState documentState;
6869

@@ -173,6 +174,11 @@ public DocumentKey getKey() {
173174
return key;
174175
}
175176

177+
@Override
178+
public SnapshotVersion getCreateTime() {
179+
return createTime;
180+
}
181+
176182
@Override
177183
public SnapshotVersion getVersion() {
178184
return version;

firebase-firestore/src/main/java/com/google/firebase/firestore/pipeline/evaluation.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,7 @@ import kotlin.math.log10
4343
import kotlin.math.pow
4444
import kotlin.math.sqrt
4545

46-
internal class EvaluationContext(
47-
val db: FirebaseFirestore,
48-
val userDataReader: UserDataReader
49-
)
46+
internal class EvaluationContext(val db: FirebaseFirestore, val userDataReader: UserDataReader)
5047

5148
internal typealias EvaluateDocument = (input: MutableDocument) -> EvaluateResult
5249

firebase-firestore/src/main/java/com/google/firebase/firestore/pipeline/expressions.kt

Lines changed: 18 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ import com.google.firebase.firestore.Pipeline
2323
import com.google.firebase.firestore.UserDataReader
2424
import com.google.firebase.firestore.VectorValue
2525
import com.google.firebase.firestore.model.DocumentKey
26+
import com.google.firebase.firestore.model.FieldPath as ModelFieldPath
2627
import com.google.firebase.firestore.model.FieldPath.CREATE_TIME_PATH
2728
import com.google.firebase.firestore.model.FieldPath.KEY_PATH
2829
import com.google.firebase.firestore.model.FieldPath.UPDATE_TIME_PATH
29-
import com.google.firebase.firestore.model.FieldPath as ModelFieldPath
3030
import com.google.firebase.firestore.model.MutableDocument
3131
import com.google.firebase.firestore.model.Values
3232
import com.google.firebase.firestore.model.Values.encodeValue
@@ -1022,8 +1022,7 @@ abstract class Expr internal constructor() {
10221022
* @return A new [BooleanExpr] representing the 'IN' comparison.
10231023
*/
10241024
@JvmStatic
1025-
fun eqAny(expression: Expr, values: List<Any>): BooleanExpr =
1026-
eqAny(expression, array(values))
1025+
fun eqAny(expression: Expr, values: List<Any>): BooleanExpr = eqAny(expression, array(values))
10271026

10281027
/**
10291028
* Creates an expression that checks if an [expression], when evaluated, is equal to any of the
@@ -1047,8 +1046,7 @@ abstract class Expr internal constructor() {
10471046
* @return A new [BooleanExpr] representing the 'IN' comparison.
10481047
*/
10491048
@JvmStatic
1050-
fun eqAny(fieldName: String, values: List<Any>): BooleanExpr =
1051-
eqAny(fieldName, array(values))
1049+
fun eqAny(fieldName: String, values: List<Any>): BooleanExpr = eqAny(fieldName, array(values))
10521050

10531051
/**
10541052
* Creates an expression that checks if a field's value is equal to any of the elements of
@@ -2780,8 +2778,7 @@ abstract class Expr internal constructor() {
27802778
* @return A new [BooleanExpr] representing the arrayContainsAll operation.
27812779
*/
27822780
@JvmStatic
2783-
fun arrayContainsAll(array: Expr, values: List<Any>) =
2784-
arrayContainsAll(array, array(values))
2781+
fun arrayContainsAll(array: Expr, values: List<Any>) = arrayContainsAll(array, array(values))
27852782

27862783
/**
27872784
* Creates an expression that checks if [array] contains all elements of [arrayExpression].
@@ -2803,12 +2800,7 @@ abstract class Expr internal constructor() {
28032800
*/
28042801
@JvmStatic
28052802
fun arrayContainsAll(arrayFieldName: String, values: List<Any>) =
2806-
BooleanExpr(
2807-
"array_contains_all",
2808-
evaluateArrayContainsAll,
2809-
arrayFieldName,
2810-
array(values)
2811-
)
2803+
BooleanExpr("array_contains_all", evaluateArrayContainsAll, arrayFieldName, array(values))
28122804

28132805
/**
28142806
* Creates an expression that checks if array field contains all elements of [arrayExpression].
@@ -2830,12 +2822,7 @@ abstract class Expr internal constructor() {
28302822
*/
28312823
@JvmStatic
28322824
fun arrayContainsAny(array: Expr, values: List<Any>) =
2833-
BooleanExpr(
2834-
"array_contains_any",
2835-
evaluateArrayContainsAny,
2836-
array,
2837-
array(values)
2838-
)
2825+
BooleanExpr("array_contains_any", evaluateArrayContainsAny, array, array(values))
28392826

28402827
/**
28412828
* Creates an expression that checks if [array] contains any elements of [arrayExpression].
@@ -2857,12 +2844,7 @@ abstract class Expr internal constructor() {
28572844
*/
28582845
@JvmStatic
28592846
fun arrayContainsAny(arrayFieldName: String, values: List<Any>) =
2860-
BooleanExpr(
2861-
"array_contains_any",
2862-
evaluateArrayContainsAny,
2863-
arrayFieldName,
2864-
array(values)
2865-
)
2847+
BooleanExpr("array_contains_any", evaluateArrayContainsAny, arrayFieldName, array(values))
28662848

28672849
/**
28682850
* Creates an expression that checks if array field contains any elements of [arrayExpression].
@@ -4194,14 +4176,17 @@ class Field internal constructor(private val fieldPath: ModelFieldPath) : Select
41944176
internal fun toProto(): Value =
41954177
Value.newBuilder().setFieldReferenceValue(fieldPath.canonicalString()).build()
41964178

4197-
override fun evaluateContext(context: EvaluationContext) = block@{ input: MutableDocument ->
4198-
EvaluateResultValue(when (fieldPath) {
4199-
KEY_PATH -> encodeValue(DocumentReference.forPath(input.key.path, context.db))
4200-
CREATE_TIME_PATH -> encodeValue(input.createTime.timestamp)
4201-
UPDATE_TIME_PATH -> encodeValue(input.version.timestamp)
4202-
else -> input.getField(fieldPath) ?: return@block EvaluateResultUnset
4203-
})
4204-
}
4179+
override fun evaluateContext(context: EvaluationContext) =
4180+
block@{ input: MutableDocument ->
4181+
EvaluateResultValue(
4182+
when (fieldPath) {
4183+
KEY_PATH -> encodeValue(DocumentReference.forPath(input.key.path, context.db))
4184+
CREATE_TIME_PATH -> encodeValue(input.createTime.timestamp)
4185+
UPDATE_TIME_PATH -> encodeValue(input.version.timestamp)
4186+
else -> input.getField(fieldPath) ?: return@block EvaluateResultUnset
4187+
}
4188+
)
4189+
}
42054190
}
42064191

42074192
/**

0 commit comments

Comments
 (0)