class Cequel::Metal::Statement
Builder for CQL statements. Contains a CQL string with bind substitutions and a collection of bind variables
@api private
Attributes
bind_vars[R]
@return [Array] bind variables for CQL string
Public Class Methods
new(cql_or_prepared='', bind_vars=[])
click to toggle source
@return [Array] cassandra type hints for bind variables
# File lib/cequel/metal/statement.rb, line 14 def initialize(cql_or_prepared='', bind_vars=[]) cql, prepared = *case cql_or_prepared when Cassandra::Statements::Prepared [cql_or_prepared.cql, cql_or_prepared] else [cql_or_prepared.to_s, nil] end @cql, @prepared, @bind_vars = cql, prepared, bind_vars end
Public Instance Methods
append(cql, *bind_vars)
click to toggle source
Add a CQL fragment with optional bind variables to the end of the statement
@param cql [String] CQL fragment @param bind_vars
[Object] zero or more bind variables @return [void]
# File lib/cequel/metal/statement.rb, line 58 def append(cql, *bind_vars) unless cql.nil? @cql << cql @bind_vars.concat(bind_vars) end self end
args()
click to toggle source
@return [Array] this statement as an array of arguments to
Keyspace#execute (CQL string followed by bind variables)
# File lib/cequel/metal/statement.rb, line 70 def args [cql, *bind_vars] end
prepare(keyspace)
click to toggle source
@return [Cassandra::Statements::Prepared] prepared version of this statement
# File lib/cequel/metal/statement.rb, line 34 def prepare(keyspace) @prepared ||= keyspace.client.prepare(cql) end
prepend(cql, *bind_vars)
click to toggle source
Add a CQL fragment with optional bind variables to the beginning of the statement
@param (see append
) @return [void]
# File lib/cequel/metal/statement.rb, line 45 def prepend(cql, *bind_vars) @cql.prepend(cql) @bind_vars.unshift(*bind_vars) end
to_s()
click to toggle source
@return [String] CQL statement
# File lib/cequel/metal/statement.rb, line 28 def to_s @cql end
Also aliased as: cql