From 17de2b31f9450385e739bedeeaac6e1ec4f239a8 Mon Sep 17 00:00:00 2001 From: Google APIs Date: Wed, 19 Aug 2020 14:12:56 -0700 Subject: [PATCH] firestore: add `!=` support PiperOrigin-RevId: 327504150 --- google/firestore/v1/firestore.proto | 10 ++++-- google/firestore/v1/query.proto | 56 +++++++++++++++++++++++------ 2 files changed, 52 insertions(+), 14 deletions(-) diff --git a/google/firestore/v1/firestore.proto b/google/firestore/v1/firestore.proto index ee32c410..e035d1b4 100644 --- a/google/firestore/v1/firestore.proto +++ b/google/firestore/v1/firestore.proto @@ -533,14 +533,15 @@ message PartitionQueryRequest { // The query to partition. oneof query_type { // A structured query. - // Filters, order bys, limits, offsets, and start/end cursors are not - // supported. + // Query must specify collection with all descendants and be ordered by name + // ascending. Other filters, order bys, limits, offsets, and start/end + // cursors are not supported. StructuredQuery structured_query = 2; } // The desired maximum number of partition points. // The partitions may be returned across multiple pages of results. - // The number must be strictly positive. The actual number of partitions + // The number must be positive. The actual number of partitions // returned may be fewer. // // For example, this may be set to one fewer than the number of parallel @@ -589,6 +590,9 @@ message PartitionQueryResponse { // * query, end_at A // * query, start_at A, end_at B // * query, start_at B + // + // An empty result may indicate that the query has too few results to be + // partitioned. repeated Cursor partitions = 1; // A page token that may be used to request an additional set of results, up diff --git a/google/firestore/v1/query.proto b/google/firestore/v1/query.proto index 9c267fe6..eea1d117 100644 --- a/google/firestore/v1/query.proto +++ b/google/firestore/v1/query.proto @@ -115,6 +115,14 @@ message StructuredQuery { // The given `field` is equal to the given `value`. EQUAL = 5; + // The given `field` is not equal to the given `value`. + // + // Requires: + // + // * No other `NOT_EQUAL`, `NOT_IN`, `IS_NOT_NULL`, or `IS_NOT_NAN`. + // * That `field` comes first in the `order_by`. + NOT_EQUAL = 6; + // The given `field` is an array that contains the given `value`. ARRAY_CONTAINS = 7; @@ -123,7 +131,7 @@ message StructuredQuery { // Requires: // // * That `value` is a non-empty `ArrayValue` with at most 10 values. - // * No other `IN`, `ARRAY_CONTAINS_ANY`, or `NOT_IN`. + // * No other `IN` or `ARRAY_CONTAINS_ANY` or `NOT_IN`. IN = 8; // The given `field` is an array that contains any of the values in the @@ -132,8 +140,18 @@ message StructuredQuery { // Requires: // // * That `value` is a non-empty `ArrayValue` with at most 10 values. - // * No other `IN`, `ARRAY_CONTAINS_ANY`, or `NOT_IN`. + // * No other `IN` or `ARRAY_CONTAINS_ANY` or `NOT_IN`. ARRAY_CONTAINS_ANY = 9; + + // The value of the `field` is not in the given array. + // + // Requires: + // + // * That `value` is a non-empty `ArrayValue` with at most 10 values. + // * No other `IN`, `ARRAY_CONTAINS_ANY`, `NOT_IN`, `NOT_EQUAL`, + // `IS_NOT_NULL`, or `IS_NOT_NAN`. + // * That `field` comes first in the `order_by`. + NOT_IN = 10; } // The field to filter by. @@ -158,6 +176,22 @@ message StructuredQuery { // The given `field` is equal to `NULL`. IS_NULL = 3; + + // The given `field` is not equal to `NaN`. + // + // Requires: + // + // * No other `NOT_EQUAL`, `NOT_IN`, `IS_NOT_NULL`, or `IS_NOT_NAN`. + // * That `field` comes first in the `order_by`. + IS_NOT_NAN = 4; + + // The given `field` is not equal to `NULL`. + // + // Requires: + // + // * A single `NOT_EQUAL`, `NOT_IN`, `IS_NOT_NULL`, or `IS_NOT_NAN`. + // * That `field` comes first in the `order_by`. + IS_NOT_NULL = 5; } // The unary operator to apply. @@ -170,6 +204,15 @@ message StructuredQuery { } } + // An order on a field. + message Order { + // The field to order by. + FieldReference field = 1; + + // The direction to order by. Defaults to `ASCENDING`. + Direction direction = 2; + } + // A reference to a field, such as `max(messages.time) as max_time`. message FieldReference { string field_path = 2; @@ -184,15 +227,6 @@ message StructuredQuery { repeated FieldReference fields = 2; } - // An order on a field. - message Order { - // The field to order by. - FieldReference field = 1; - - // The direction to order by. Defaults to `ASCENDING`. - Direction direction = 2; - } - // A sort direction. enum Direction { // Unspecified.