class Google::Cloud::Spanner::ColumnValue
Represents a change to be made to a row's column value by the Spanner
API.
@example
require "google/cloud/spanner" spanner = Google::Cloud::Spanner.new db = spanner.client "my-instance", "my-database" # create column value object commit_timestamp = db.commit_timestamp db.commit do |c| c.insert "users", [ { id: 5, name: "Murphy", updated_at: commit_timestamp } ] end
Public Class Methods
commit_timestamp()
click to toggle source
Creates a column value object representing setting a field's value to the timestamp of the commit. (See {Client#commit_timestamp} and {Transaction#commit_timestamp})
This placeholder value can only be used for timestamp columns that have set the option “(allow_commit_timestamp=true)” in the schema.
@return [ColumnValue] The commit timestamp column value object.
@example
require "google/cloud/spanner" spanner = Google::Cloud::Spanner.new db = spanner.client "my-instance", "my-database" # create column value object commit_timestamp = \ Google::Cloud::Spanner::ColumnValue.commit_timestamp db.commit do |c| c.insert "users", [ { id: 5, name: "Murphy", updated_at: commit_timestamp } ] end
# File lib/google/cloud/spanner/column_value.rb, line 102 def self.commit_timestamp new :commit_timestamp end
new(type)
click to toggle source
@private Creates a column value object representing changes made to fields in document data.
# File lib/google/cloud/spanner/column_value.rb, line 45 def initialize type @type = type end
Public Instance Methods
to_column_value()
click to toggle source
@private The actual value that is sent to Spanner
for the field.
# File lib/google/cloud/spanner/column_value.rb, line 108 def to_column_value # We only have one ColumnValue, so hard-code this for now. "spanner.commit_timestamp()" end
type()
click to toggle source
@private The type of change to make to a row's column value.
@return [Symbol] The type of the column value.
@example
require "google/cloud/spanner" spanner = Google::Cloud::Spanner.new db = spanner.client "my-instance", "my-database" # create column value object commit_timestamp = db.commit_timestamp db.commit do |c| c.insert "users", [ { id: 5, name: "Murphy", updated_at: commit_timestamp } ] end
# File lib/google/cloud/spanner/column_value.rb, line 71 def type @type end