From 3f153873b2f74331184688f2b3cbbf028fed08af Mon Sep 17 00:00:00 2001 From: Rich Gowman Date: Fri, 14 Jun 2019 13:09:13 -0400 Subject: [PATCH 1/2] Minor fix to error message to match the admin sdk. In particular, it *is* allowed to have slashes, etc in field paths. --- .../src/main/java/com/google/firebase/firestore/FieldPath.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/firebase-firestore/src/main/java/com/google/firebase/firestore/FieldPath.java b/firebase-firestore/src/main/java/com/google/firebase/firestore/FieldPath.java index af3360926c3..ee8c1bc51ec 100644 --- a/firebase-firestore/src/main/java/com/google/firebase/firestore/FieldPath.java +++ b/firebase-firestore/src/main/java/com/google/firebase/firestore/FieldPath.java @@ -84,8 +84,7 @@ public static FieldPath documentId() { static FieldPath fromDotSeparatedPath(@NonNull String path) { checkNotNull(path, "Provided field path must not be null."); checkArgument( - !RESERVED.matcher(path).find(), - "Invalid field path (" + path + "). Paths must not contain '~', '*', '/', '[', or ']'"); + !RESERVED.matcher(path).find(), "Use FieldPath.of() for field names containing '~*/[]'."); try { // By default, split() doesn't return empty leading and trailing segments. This can be enabled // by passing "-1" as the limit. From e85e2a50cadb37e78c2c026e5361a703ae5ab7f6 Mon Sep 17 00:00:00 2001 From: Rich Gowman Date: Mon, 17 Jun 2019 14:33:59 -0400 Subject: [PATCH 2/2] Fix test --- .../java/com/google/firebase/firestore/ValidationTest.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/firebase-firestore/src/androidTest/java/com/google/firebase/firestore/ValidationTest.java b/firebase-firestore/src/androidTest/java/com/google/firebase/firestore/ValidationTest.java index 1990f7ccf06..8ce172c91f7 100644 --- a/firebase-firestore/src/androidTest/java/com/google/firebase/firestore/ValidationTest.java +++ b/firebase-firestore/src/androidTest/java/com/google/firebase/firestore/ValidationTest.java @@ -332,11 +332,7 @@ public void fieldPathsMustNotHaveInvalidSegments() { List badFieldPaths = asList("foo~bar", "foo*bar", "foo/bar", "foo[1", "foo]1", "foo[1]"); for (String fieldPath : badFieldPaths) { - String reason = - "Invalid field path (" - + fieldPath - + "). Paths must not contain '~', '*', '/', '[', or ']'"; - verifyFieldPathThrows(fieldPath, reason); + verifyFieldPathThrows(fieldPath, "Use FieldPath.of() for field names containing '~*/[]'."); } }