From 4bfdcd371b9fac734d4b2ee8d8beae4f9f5e1aba Mon Sep 17 00:00:00 2001 From: Google APIs Date: Tue, 15 Mar 2022 12:27:13 -0700 Subject: [PATCH] feat: add IN/NOT_IN/NOT_EQUALS support to cloud datastore proto PiperOrigin-RevId: 434824722 --- google/datastore/v1/datastore.proto | 20 +++++++--- google/datastore/v1/entity.proto | 10 ++--- google/datastore/v1/query.proto | 61 ++++++++++++++++++++++++----- 3 files changed, 70 insertions(+), 21 deletions(-) diff --git a/google/datastore/v1/datastore.proto b/google/datastore/v1/datastore.proto index ad016194ab..6a29b0e984 100644 --- a/google/datastore/v1/datastore.proto +++ b/google/datastore/v1/datastore.proto @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. +// Copyright 2022 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -328,8 +328,9 @@ message Mutation { // with the current version of the entity on the server. Conflicting mutations // are not applied, and are marked as such in MutationResult. oneof conflict_detection_strategy { - // The version of the entity that this mutation is being applied to. If this - // does not match the current version on the server, the mutation conflicts. + // The version of the entity that this mutation is being applied + // to. If this does not match the current version on the server, the + // mutation conflicts. int64 base_version = 8; } } @@ -366,9 +367,16 @@ message ReadOptions { EVENTUAL = 2; } - // If not specified, lookups and ancestor queries default to - // `read_consistency`=`STRONG`, global queries default to - // `read_consistency`=`EVENTUAL`. + // For Cloud Datastore, if read_consistency is not specified, then lookups and + // ancestor queries default to `read_consistency`=`STRONG`, global queries + // default to `read_consistency`=`EVENTUAL`. + // + // For Cloud Firestore in Datastore mode, if read_consistency is not specified + // then lookups and all queries default to `read_consistency`=`STRONG`. + // + // Explicitly setting `read_consistency`=`EVENTUAL` will result in eventually + // consistent lookups & queries in both Cloud Datastore & Cloud Firestore in + // Datastore mode. oneof consistency_type { // The non-transactional read consistency to use. // Cannot be set to `STRONG` for global queries. diff --git a/google/datastore/v1/entity.proto b/google/datastore/v1/entity.proto index 61286cd7a2..befbcd7b65 100644 --- a/google/datastore/v1/entity.proto +++ b/google/datastore/v1/entity.proto @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. +// Copyright 2022 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -16,7 +16,6 @@ syntax = "proto3"; package google.datastore.v1; -import "google/api/annotations.proto"; import "google/protobuf/struct.proto"; import "google/protobuf/timestamp.proto"; import "google/type/latlng.proto"; @@ -47,8 +46,7 @@ option ruby_package = "Google::Cloud::Datastore::V1"; // // Foreign partition IDs (in which the project ID does // not match the context project ID ) are discouraged. -// Reads and writes of foreign partition IDs may fail if the project is not in -// an active state. +// Reads and writes of foreign partition IDs may fail if the project is not in an active state. message PartitionId { // The ID of the project to which the entities belong. string project_id = 2; @@ -146,8 +144,8 @@ message Value { Key key_value = 5; // A UTF-8 encoded string value. - // When `exclude_from_indexes` is false (it is indexed), may have at most - // 1500 bytes. Otherwise, may be set to at most 1,000,000 bytes. + // When `exclude_from_indexes` is false (it is indexed) , may have at most 1500 bytes. + // Otherwise, may be set to at most 1,000,000 bytes. string string_value = 17; // A blob value. diff --git a/google/datastore/v1/query.proto b/google/datastore/v1/query.proto index 4cb3ef99b8..3e64618393 100644 --- a/google/datastore/v1/query.proto +++ b/google/datastore/v1/query.proto @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. +// Copyright 2022 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -16,10 +16,8 @@ syntax = "proto3"; package google.datastore.v1; -import "google/api/annotations.proto"; import "google/datastore/v1/entity.proto"; import "google/protobuf/wrappers.proto"; -import "google/type/latlng.proto"; option csharp_namespace = "Google.Cloud.Datastore.V1"; option go_package = "google.golang.org/genproto/googleapis/datastore/v1;datastore"; @@ -190,23 +188,68 @@ message PropertyFilter { // Unspecified. This value must not be used. OPERATOR_UNSPECIFIED = 0; - // Less than. + // The given `property` is less than the given `value`. + // + // Requires: + // + // * That `property` comes first in `order_by`. LESS_THAN = 1; - // Less than or equal. + // The given `property` is less than or equal to the given `value`. + // + // Requires: + // + // * That `property` comes first in `order_by`. LESS_THAN_OR_EQUAL = 2; - // Greater than. + // The given `property` is greater than the given `value`. + // + // Requires: + // + // * That `property` comes first in `order_by`. GREATER_THAN = 3; - // Greater than or equal. + // The given `property` is greater than or equal to the given `value`. + // + // Requires: + // + // * That `property` comes first in `order_by`. GREATER_THAN_OR_EQUAL = 4; - // Equal. + // The given `property` is equal to the given `value`. EQUAL = 5; - // Has ancestor. + // The given `property` is equal to at least one value in the given array. + // + // Requires: + // + // * That `value` is a non-empty `ArrayValue` with at most 10 values. + // * No other `IN` or `NOT_IN` is in the same query. + IN = 6; + + // The given `property` is not equal to the given `value`. + // + // Requires: + // + // * No other `NOT_EQUAL` or `NOT_IN` is in the same query. + // * That `property` comes first in the `order_by`. + NOT_EQUAL = 9; + + // Limit the result set to the given entity and its descendants. + // + // Requires: + // + // * That `value` is an entity key. HAS_ANCESTOR = 11; + + // The value of the `property` is not in the given array. + // + // Requires: + // + // * That `value` is a non-empty `ArrayValue` with at most 10 values. + // * No other `IN`, `NOT_IN`, `NOT_EQUAL` is in the same query. + // * That `field` comes first in the `order_by`. + NOT_IN = 13; } // The property to filter by.