Skip to content
Open
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
2 changes: 1 addition & 1 deletion google-cloud-spanner/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ gem "google-cloud-core", "~> 1.8.0"
gem "google-cloud-errors", "~> 1.5.0"
gem "google-cloud-spanner-admin-database-v1", "~> 1.3"
gem "google-cloud-spanner-admin-instance-v1", "~> 1.5"
gem "google-cloud-spanner-v1", "~> 1.5"
gem "google-cloud-spanner-v1", "~> 1.8"
gem "google-style", "~> 1.31.0"
gem "grpc", "~> 1.67"
gem "grpc-tools", "~> 1.74", ">= 1.74.1"
Expand Down
30 changes: 25 additions & 5 deletions google-cloud-spanner/lib/google/cloud/spanner/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1053,6 +1053,8 @@ def read table, columns, keys: nil, index: nil, limit: nil,
# @param [Boolean] exclude_txn_from_change_streams If set to true,
# mutations will not be recorded in change streams with DDL option
# `allow_txn_exclusion=true`.
# @param [Google::Cloud::Spanner::V1::TransactionOptions::IsolationLevel] isolation_level The
# isolation level for the transaction.
# @param [Hash] commit_options A hash of commit options.
# e.g., return_commit_stats. Commit options are optional.
# The following options can be provided:
Expand Down Expand Up @@ -1143,14 +1145,15 @@ def read table, columns, keys: nil, index: nil, limit: nil,
# request_options: request_options
#
def upsert table, rows,
exclude_txn_from_change_streams: false,
exclude_txn_from_change_streams: false, isolation_level: nil,
commit_options: nil, request_options: nil, call_options: nil
request_options = Convert.to_request_options \
request_options, tag_type: :transaction_tag

@pool.with_session do |session|
session.upsert table, rows,
exclude_txn_from_change_streams: exclude_txn_from_change_streams,
isolation_level: isolation_level,
commit_options: commit_options,
request_options: request_options,
call_options: call_options
Expand Down Expand Up @@ -1200,6 +1203,8 @@ def upsert table, rows,
# @param [Boolean] exclude_txn_from_change_streams If set to true,
# mutations will not be recorded in change streams with DDL option
# `allow_txn_exclusion=true`.
# @param [Google::Cloud::Spanner::V1::TransactionOptions::IsolationLevel] isolation_level The
# isolation level for the transaction.
# @param [Hash] commit_options A hash of commit options.
# e.g., return_commit_stats. Commit options are optional.
# The following options can be provided:
Expand Down Expand Up @@ -1290,14 +1295,15 @@ def upsert table, rows,
# request_options: request_options
#
def insert table, rows,
exclude_txn_from_change_streams: false,
exclude_txn_from_change_streams: false, isolation_level: nil,
commit_options: nil, request_options: nil, call_options: nil
request_options = Convert.to_request_options \
request_options, tag_type: :transaction_tag

@pool.with_session do |session|
session.insert table, rows,
exclude_txn_from_change_streams: exclude_txn_from_change_streams,
isolation_level: isolation_level,
commit_options: commit_options,
request_options: request_options,
call_options: call_options
Expand Down Expand Up @@ -1346,6 +1352,8 @@ def insert table, rows,
# @param [Boolean] exclude_txn_from_change_streams If set to true,
# mutations will not be recorded in change streams with DDL option
# `allow_txn_exclusion=true`.
# @param [Google::Cloud::Spanner::V1::TransactionOptions::IsolationLevel] isolation_level The
# isolation level for the transaction.
# @param [Hash] commit_options A hash of commit options.
# e.g., return_commit_stats. Commit options are optional.
# The following options can be provided:
Expand Down Expand Up @@ -1435,14 +1443,15 @@ def insert table, rows,
# request_options: request_options
#
def update table, rows,
exclude_txn_from_change_streams: false,
exclude_txn_from_change_streams: false, isolation_level: nil,
commit_options: nil, request_options: nil, call_options: nil
request_options = Convert.to_request_options \
request_options, tag_type: :transaction_tag

@pool.with_session do |session|
session.update table, rows,
exclude_txn_from_change_streams: exclude_txn_from_change_streams,
isolation_level: isolation_level,
commit_options: commit_options,
request_options: request_options,
call_options: call_options
Expand Down Expand Up @@ -1493,6 +1502,8 @@ def update table, rows,
# @param [Boolean] exclude_txn_from_change_streams If set to true,
# mutations will not be recorded in change streams with DDL option
# `allow_txn_exclusion=true`.
# @param [Google::Cloud::Spanner::V1::TransactionOptions::IsolationLevel] isolation_level The
# isolation level for the transaction.
# @param [Hash] commit_options A hash of commit options.
# e.g., return_commit_stats. Commit options are optional.
# The following options can be provided:
Expand Down Expand Up @@ -1582,11 +1593,12 @@ def update table, rows,
# request_options: request_options
#
def replace table, rows,
exclude_txn_from_change_streams: false,
exclude_txn_from_change_streams: false, isolation_level: nil,
commit_options: nil, request_options: nil, call_options: nil
@pool.with_session do |session|
session.replace table, rows,
exclude_txn_from_change_streams: exclude_txn_from_change_streams,
isolation_level: isolation_level,
commit_options: commit_options,
request_options: request_options,
call_options: call_options
Expand Down Expand Up @@ -1616,6 +1628,8 @@ def replace table, rows,
# @param [Boolean] exclude_txn_from_change_streams If set to true,
# mutations will not be recorded in change streams with DDL option
# `allow_txn_exclusion=true`.
# @param [Google::Cloud::Spanner::V1::TransactionOptions::IsolationLevel] isolation_level The
# isolation level for the transaction.
# @param [Hash] commit_options A hash of commit options.
# e.g., return_commit_stats. Commit options are optional.
# The following options can be provided:
Expand Down Expand Up @@ -1699,13 +1713,15 @@ def replace table, rows,
#
def delete table, keys = [],
exclude_txn_from_change_streams: false,
commit_options: nil, request_options: nil, call_options: nil
isolation_level: nil, commit_options: nil, request_options: nil,
call_options: nil
request_options = Convert.to_request_options \
request_options, tag_type: :transaction_tag

@pool.with_session do |session|
session.delete table, keys,
exclude_txn_from_change_streams: exclude_txn_from_change_streams,
isolation_level: isolation_level,
commit_options: commit_options,
request_options: request_options,
call_options: call_options
Expand All @@ -1730,6 +1746,8 @@ def delete table, keys = [],
# @param [Boolean] exclude_txn_from_change_streams If set to true,
# mutations will not be recorded in change streams with DDL option
# `allow_txn_exclusion=true`.
# @param [Google::Cloud::Spanner::V1::TransactionOptions::IsolationLevel] isolation_level The
# isolation level for the transaction.
# @param [Hash] commit_options A hash of commit options.
# e.g., return_commit_stats. Commit options are optional.
# The following options can be provided:
Expand Down Expand Up @@ -1826,6 +1844,7 @@ def delete table, keys = [],
# end
#
def commit exclude_txn_from_change_streams: false,
isolation_level: nil,
commit_options: nil, request_options: nil, call_options: nil,
&block
raise ArgumentError, "Must provide a block" unless block_given?
Expand All @@ -1836,6 +1855,7 @@ def commit exclude_txn_from_change_streams: false,
@pool.with_session do |session|
session.commit(
exclude_txn_from_change_streams: exclude_txn_from_change_streams,
isolation_level: isolation_level,
commit_options: commit_options, request_options: request_options,
call_options: call_options, &block
)
Expand Down
19 changes: 13 additions & 6 deletions google-cloud-spanner/lib/google/cloud/spanner/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -534,13 +534,15 @@ def partition_query session_name, sql, transaction, params: nil,
# @return [::Google::Cloud::Spanner::V1::CommitResponse]
def commit session_name, mutations = [],
transaction_id: nil, exclude_txn_from_change_streams: false,
commit_options: nil, request_options: nil, call_options: nil
isolation_level: nil, commit_options: nil, request_options: nil,
call_options: nil
route_to_leader = LARHeaders.commit
tx_opts = nil
if transaction_id.nil?
tx_opts = V1::TransactionOptions.new(
read_write: V1::TransactionOptions::ReadWrite.new,
exclude_txn_from_change_streams: exclude_txn_from_change_streams
exclude_txn_from_change_streams: exclude_txn_from_change_streams,
isolation_level: isolation_level
)
end
opts = default_options session_name: session_name,
Expand Down Expand Up @@ -589,12 +591,14 @@ def rollback session_name, transaction_id, call_options: nil

def begin_transaction session_name,
exclude_txn_from_change_streams: false,
isolation_level: nil,
request_options: nil,
call_options: nil,
route_to_leader: nil
tx_opts = V1::TransactionOptions.new(
read_write: V1::TransactionOptions::ReadWrite.new,
exclude_txn_from_change_streams: exclude_txn_from_change_streams
exclude_txn_from_change_streams: exclude_txn_from_change_streams,
isolation_level: isolation_level
)
opts = default_options session_name: session_name,
call_options: call_options,
Expand Down Expand Up @@ -626,7 +630,7 @@ def batch_write session_name,
end

def create_snapshot session_name, strong: nil, timestamp: nil,
staleness: nil, call_options: nil
isolation_level: nil, staleness: nil, call_options: nil
tx_opts = V1::TransactionOptions.new(
read_only: V1::TransactionOptions::ReadOnly.new(
{
Expand All @@ -635,7 +639,8 @@ def create_snapshot session_name, strong: nil, timestamp: nil,
exact_staleness: Convert.number_to_duration(staleness),
return_read_timestamp: true
}.compact
)
),
isolation_level: isolation_level
)
opts = default_options session_name: session_name,
call_options: call_options
Expand All @@ -645,10 +650,12 @@ def create_snapshot session_name, strong: nil, timestamp: nil,

def create_pdml session_name,
exclude_txn_from_change_streams: false,
isolation_level: nil,
call_options: nil
tx_opts = V1::TransactionOptions.new(
partitioned_dml: V1::TransactionOptions::PartitionedDml.new,
exclude_txn_from_change_streams: exclude_txn_from_change_streams
exclude_txn_from_change_streams: exclude_txn_from_change_streams,
isolation_level: isolation_level
)
route_to_leader = LARHeaders.begin_transaction true
opts = default_options session_name: session_name,
Expand Down
Loading