From 7d63e6e1aeb82bea434bde31ef09021652a5b2f9 Mon Sep 17 00:00:00 2001 From: Jason Dobry Date: Tue, 19 Jun 2018 17:00:37 -0700 Subject: [PATCH] Delete unused Datastore samples. --- datastore/sample.rb | 55 ----------------------------------- datastore/spec/sample_spec.rb | 53 +-------------------------------- 2 files changed, 1 insertion(+), 107 deletions(-) diff --git a/datastore/sample.rb b/datastore/sample.rb index bfb25d70c..65b12840e 100644 --- a/datastore/sample.rb +++ b/datastore/sample.rb @@ -364,21 +364,7 @@ def keys_only_query select("__key__") # [END datastore_keys_only_query] - # [START datastore_run_keys_only_query] keys = datastore.run(query).map(&:key) - # [END datastore_run_keys_only_query] -end - -def distinct_query - datastore = Google::Cloud::Datastore.new - - # [START datastore_distinct_query] - query = datastore.query("Task"). - select("category", "priority"). - distinct_on("category", "priority"). - order("category"). - order("priority") - # [END datastore_distinct_query] end def distinct_on_query @@ -673,44 +659,3 @@ def property_filtering_run_query end # [END datastore_property_filtering_run_query] end - -def gql_run_query - # [START datastore_gql_run_query] - gql_query = Google::Cloud::Datastore::GqlQuery.new - gql_query.query_string = "SELECT * FROM Task ORDER BY created ASC" - tasks = datastore.run gql_query - # [END datastore_gql_run_query] -end - -def gql_named_binding_query - # [START datastore_gql_named_binding_query] - gql_query = Google::Cloud::Datastore::GqlQuery.new - gql_query.query_string = "SELECT * FROM Task " \ - "WHERE done = @done AND priority = @priority" - gql_query.named_bindings = { done: false, priority: 4 } - # [END datastore_gql_named_binding_query] - - gql_query -end - -def gql_positional_binding_query - # [START datastore_gql_positional_binding_query] - gql_query = Google::Cloud::Datastore::GqlQuery.new - gql_query.query_string = "SELECT * FROM Task " \ - "WHERE done = @1 AND priority = @2" - gql_query.positional_bindings = [false, 4] - # [END datastore_gql_positional_binding_query] - - gql_query -end - -def gql_literal_query - # [START datastore_gql_literal_query] - gql_query = Google::Cloud::Datastore::GqlQuery.new - gql_query.query_string = "SELECT * FROM Task " \ - "WHERE done = false AND priority = 4" - gql_query.allow_literals = true - # [END datastore_gql_literal_query] - - gql_query -end diff --git a/datastore/spec/sample_spec.rb b/datastore/spec/sample_spec.rb index 168a6e60a..67c3e9451 100644 --- a/datastore/spec/sample_spec.rb +++ b/datastore/spec/sample_spec.rb @@ -305,24 +305,13 @@ def delete_accounts expect(percent_completes.first).to eq(10.0) end - it "supports keys_only_query run_keys_only_query" do + it "supports keys_only_query" do keys = keys_only_query expect(keys.empty?).to be(false) expect(keys.first.kind).to eq("Task") end - it "supports distinct_query" do - query = distinct_on_query - tasks = datastore.run query - - expect(tasks.empty?).to be(false) - expect(tasks.first.key.kind).to eq("Task") - expect(tasks.first["category"]).to eq("Personal") - expect(tasks.first["priority"]).to eq(4) - expect(tasks.first.properties.to_h.size).to eq(2) - end - it "supports distinct_on_query" do query = distinct_on_query tasks = datastore.run query @@ -529,46 +518,6 @@ def delete_accounts expect(properties_by_kind["Task"]).to include "tag" end - it "supports gql_run_query" do - tasks = gql_run_query - - expect(tasks.empty?).to be(false) - tasks.each { |t| expect_basic_task t } - end - - it "supports gql_named_binding_query" do - gql_query = gql_named_binding_query - tasks = datastore.run gql_query - - expect(tasks.empty?).to be(false) - tasks.each do |t| - expect_basic_task t - expect(t["priority"]).to eq(4) - end - end - - it "supports gql_positional_binding_query" do - gql_query = gql_positional_binding_query - tasks = datastore.run gql_query - - expect(tasks.empty?).to be(false) - tasks.each do |t| - expect_basic_task t - expect(t["priority"]).to eq(4) - end - end - - it "supports gql_literal_query" do - gql_query = gql_literal_query - tasks = datastore.run gql_query - - expect(tasks.empty?).to be(false) - tasks.each do |t| - expect_basic_task t - expect(t["priority"]).to eq(4) - end - end - def expect_basic_task task expect(task.key.kind).to eq("Task") expect(task["category"]).to eq("Personal")