Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Correct the field mask when adding labels to an instance that had none previously #114

Merged
merged 2 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions google-cloud-spanner/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Documentation:
Metrics/BlockLength:
Exclude:
- "acceptance/**/*"
- ".toys.rb"
Metrics/MethodLength:
Exclude:
- "acceptance/**/*"
Expand Down
59 changes: 59 additions & 0 deletions google-cloud-spanner/.toys.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# frozen_string_literal: true

# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

toys_version! ">= 0.15.6"

if ENV["RUBY_COMMON_TOOLS"]
common_tools_dir = File.expand_path ENV["RUBY_COMMON_TOOLS"]
load File.join(common_tools_dir, "toys", "gapic")
else
load_git remote: "https://github.com/googleapis/ruby-common-tools.git",
path: "toys/gapic",
update: true
end

tool "benchmark" do
tool "gen-protos" do
include :exec, e: true
include :gems
include :git_cache

def run
setup
generate_spanner_bench
end

def setup
gem "grpc-tools", "~> 1.65"
@googleapis_dir = git_cache.get "https://github.com/googleapis/googleapis.git", update: true
Dir.chdir context_directory
end

def generate_spanner_bench
Dir.chdir "benchmark/benchwrapper" do
cmd = [
"grpc_tools_ruby_protoc",
"--ruby_out", ".",
"--grpc_out", ".",
"-I", ".",
"-I", @googleapis_dir,
"spanner_bench/spanner.proto"
]
exec cmd
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

require 'optparse'
require 'grpc'
require 'spanner_services_pb'
require 'spanner_bench/spanner_services_pb'
require "google/cloud/spanner"

include SpannerBench
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 0 additions & 55 deletions google-cloud-spanner/benchmark/benchwrapper/spanner_pb.rb

This file was deleted.

7 changes: 4 additions & 3 deletions google-cloud-spanner/lib/google/cloud/spanner/instance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -258,12 +258,13 @@ def save
ensure_service!

field_mask = []
@current_values.each do |field, value|
field_mask << field unless @grpc[field.to_s] == value
new_values = @grpc.to_h
(@current_values.keys + new_values.keys).uniq.each do |field|
field_mask << field unless new_values[field] == @current_values[field]
end

job_grpc = service.update_instance @grpc, field_mask: field_mask
@current_values = @grpc.to_h
@current_values = new_values
Instance::Job.from_grpc job_grpc, service
end
alias update save
Expand Down