Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,24 @@ jobs:
task: "--test"
- os: ubuntu-latest
ruby: "3.0"
task: "--rubocop --build --test"
- os: ubuntu-latest
ruby: "3.0"
task: "--yard --linkinator"
task: "--test"
- os: ubuntu-latest
ruby: "3.1"
task: "--test"
- os: ubuntu-latest
ruby: "3.2"
task: "--test"
task: "--test"
- os: ubuntu-latest
ruby: "3.3"
task: "--test"
- os: ubuntu-latest
ruby: "3.3"
task: "--rubocop --build --yard --linkinator"
- os: macos-latest
ruby: "3.2"
ruby: "3.3"
task: "--test"
- os: windows-latest
ruby: "3.2"
ruby: "3.3"
task: "--test"
fail-fast: false
runs-on: ${{ matrix.os }}
Expand Down
14 changes: 13 additions & 1 deletion google-cloud-spanner/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,22 @@ source "http://rubygems.org"

gemspec

gem "autotest-suffix", "~> 1.1"
gem "gapic-common", ">= 0.11.0"
gem "google-cloud-core", "~> 1.6.0"
gem "google-cloud-errors", "~> 1.3.0"
gem "google-cloud-spanner-admin-database-v1", ">= 0.11.0"
gem "google-cloud-spanner-admin-instance-v1", ">= 0.7.0"
gem "google-cloud-spanner-v1", ">= 0.19.0"

gem "google-style", "~> 1.27.1"
gem "grpc", "~> 1.36"
gem "grpc-tools", "~> 1.36"
gem "minitest", "~> 5.16"
gem "minitest-autotest", "~> 1.0"
gem "minitest-focus", "~> 1.1"
gem "minitest-rg", "~> 5.2"
gem "rake"
gem "redcarpet", "~> 3.0"
gem "simplecov", "~> 0.9"
gem "yard", "~> 0.9"
gem "yard-doctest", "~> 0.1.13"
16 changes: 1 addition & 15 deletions google-cloud-spanner/google-cloud-spanner.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,11 @@ Gem::Specification.new do |gem|
["OVERVIEW.md", "AUTHENTICATION.md", "LOGGING.md", "CONTRIBUTING.md", "TROUBLESHOOTING.md", "CHANGELOG.md", "CODE_OF_CONDUCT.md", "LICENSE", ".yardopts"]
gem.require_paths = ["lib"]

gem.required_ruby_version = ">= 2.6"
gem.required_ruby_version = ">= 2.7"

gem.add_dependency "google-cloud-core", "~> 1.5"
gem.add_dependency "google-cloud-spanner-admin-database-v1", "~> 0.1"
gem.add_dependency "google-cloud-spanner-admin-instance-v1", "~> 0.1"
gem.add_dependency "google-cloud-spanner-v1", "~> 0.2"
gem.add_dependency "concurrent-ruby", "~> 1.0"

gem.add_development_dependency "gapic-common", ">= 0.11.0"
gem.add_development_dependency "google-style", "~> 1.26.1"
gem.add_development_dependency "minitest", "~> 5.16"
gem.add_development_dependency "minitest-autotest", "~> 1.0"
gem.add_development_dependency "minitest-focus", "~> 1.1"
gem.add_development_dependency "minitest-rg", "~> 5.2"
gem.add_development_dependency "autotest-suffix", "~> 1.1"
gem.add_development_dependency "redcarpet", "~> 3.0"
gem.add_development_dependency "simplecov", "~> 0.9"
gem.add_development_dependency "yard", "~> 0.9"
gem.add_development_dependency "yard-doctest", "~> 0.1.13"
gem.add_development_dependency "grpc", "~> 1.36"
gem.add_development_dependency "grpc-tools", "~> 1.36"
end
9 changes: 6 additions & 3 deletions google-cloud-spanner/lib/google-cloud-spanner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@ module Cloud
# spanner = gcloud.spanner scope: platform_scope
#
def spanner scope: nil, timeout: nil, lib_name: nil, lib_version: nil
timeout ||= @timeout
Google::Cloud.spanner @project, @keyfile, scope: scope,
timeout: (timeout || @timeout),
timeout: timeout,
lib_name: lib_name,
lib_version: lib_version
end
Expand Down Expand Up @@ -130,8 +131,10 @@ def self.spanner project_id = nil, credentials = nil, scope: nil,
require "google/cloud/spanner"
Google::Cloud::Spanner.new project_id: project_id,
credentials: credentials,
scope: scope, timeout: timeout,
lib_name: lib_name, lib_version: lib_version
scope: scope,
timeout: timeout,
lib_name: lib_name,
lib_version: lib_version
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ def batch_snapshot strong: nil, timestamp: nil, read_timestamp: nil,
snp_session = session
snp_grpc = @project.service.create_snapshot \
snp_session.path, strong: strong,
timestamp: (timestamp || read_timestamp),
staleness: (staleness || exact_staleness)
timestamp: timestamp || read_timestamp,
staleness: staleness || exact_staleness
BatchSnapshot.from_grpc snp_grpc, snp_session, directed_read_options: @directed_read_options
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def partition_query sql, params: nil, types: nil,
partition_token: grpc.partition_token,
query_options: query_options,
data_boost_enabled: data_boost_enabled,
directed_read_options: (directed_read_options || @directed_read_options)
directed_read_options: directed_read_options || @directed_read_options
}.compact
)
Partition.from_execute_sql_grpc execute_sql_grpc
Expand Down Expand Up @@ -365,7 +365,7 @@ def partition_read table, columns, keys: nil, index: nil,
transaction: tx_selector,
partition_token: grpc.partition_token,
data_boost_enabled: data_boost_enabled,
directed_read_options: (directed_read_options || @directed_read_options)
directed_read_options: directed_read_options || @directed_read_options
}.compact
)
Partition.from_read_grpc read_grpc
Expand Down Expand Up @@ -704,7 +704,7 @@ def execute_query sql, params: nil, types: nil, query_options: nil,
transaction: tx_selector,
query_options: query_options,
call_options: call_options,
directed_read_options: (directed_read_options || @directed_read_options)
directed_read_options: directed_read_options || @directed_read_options
end
alias execute execute_query
alias query execute_query
Expand Down Expand Up @@ -780,7 +780,7 @@ def read table, columns, keys: nil, index: nil, limit: nil,
session.read table, columns, keys: keys, index: index, limit: limit,
transaction: tx_selector,
call_options: call_options,
directed_read_options: (directed_read_options || @directed_read_options)
directed_read_options: directed_read_options || @directed_read_options
end

##
Expand Down
8 changes: 4 additions & 4 deletions google-cloud-spanner/lib/google/cloud/spanner/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ def execute_query sql, params: nil, types: nil, single_use: nil,
results = session.execute_query \
sql, params: params, types: types, transaction: single_use_tx,
query_options: query_options, request_options: request_options,
call_options: call_options, directed_read_options: (directed_read_options || @directed_read_options),
call_options: call_options, directed_read_options: directed_read_options || @directed_read_options,
route_to_leader: route_to_leader
end
results
Expand Down Expand Up @@ -970,7 +970,7 @@ def read table, columns, keys: nil, index: nil, limit: nil,
transaction: single_use_tx,
request_options: request_options,
call_options: call_options,
directed_read_options: (directed_read_options || @directed_read_options),
directed_read_options: directed_read_options || @directed_read_options,
route_to_leader: route_to_leader
end
results
Expand Down Expand Up @@ -2003,8 +2003,8 @@ def snapshot strong: nil, timestamp: nil, read_timestamp: nil,
@pool.with_session do |session|
snp_grpc = @project.service.create_snapshot \
session.path, strong: strong,
timestamp: (timestamp || read_timestamp),
staleness: (staleness || exact_staleness),
timestamp: timestamp || read_timestamp,
staleness: staleness || exact_staleness,
call_options: call_options
Thread.current[IS_TRANSACTION_RUNNING_KEY] = true
snp = Snapshot.from_grpc snp_grpc, session, @directed_read_options
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ def initialize
def database
return nil unless done?
return nil unless @grpc.grpc_op.result == :response
return nil unless @grpc.results.instance_of? \
Admin::Database::V1::Database
return nil unless @grpc.results.instance_of? Admin::Database::V1::Database
Database.from_grpc @grpc.results, service
end

Expand Down
2 changes: 1 addition & 1 deletion google-cloud-spanner/lib/google/cloud/spanner/fields.rb
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def keys
# @return [Boolean] Returns `true` if there are duplicate names.
#
def duplicate_names?
keys.group_by { |e| e }.select { |_k, v| v.size > 1 }.any?
keys.group_by { |e| e }.any? { |_k, v| v.size > 1 }
end

##
Expand Down
4 changes: 2 additions & 2 deletions google-cloud-spanner/lib/google/cloud/spanner/results.rb
Original file line number Diff line number Diff line change
Expand Up @@ -283,15 +283,15 @@ def row_count
# Whether the row count is the lower bound row count for PDML
# statements.
def row_count_lower_bound?
return nil if @stats.nil?
return nil if @stats.nil? # rubocop:disable Style/ReturnNilInPredicateMethodDefinition
@stats.row_count == :row_count_lower_bound
end

##
# @private
# Whether the row count is the exact row count for DML statements.
def row_count_exact?
return nil if @stats.nil?
return nil if @stats.nil? # rubocop:disable Style/ReturnNilInPredicateMethodDefinition
@stats.row_count == :row_count_exact
end

Expand Down
4 changes: 2 additions & 2 deletions google-cloud-spanner/lib/google/cloud/spanner/snapshot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ def execute_query sql, params: nil, types: nil, query_options: nil,
transaction: tx_selector,
query_options: query_options,
call_options: call_options,
directed_read_options: (directed_read_options || @directed_read_options)
directed_read_options: directed_read_options || @directed_read_options
end
alias execute execute_query
alias query execute_query
Expand Down Expand Up @@ -387,7 +387,7 @@ def read table, columns, keys: nil, index: nil, limit: nil,
session.read table, columns, keys: keys, index: index, limit: limit,
transaction: tx_selector,
call_options: call_options,
directed_read_options: (directed_read_options || @directed_read_options)
directed_read_options: directed_read_options || @directed_read_options
end

##
Expand Down