Module: Cassie::Statements::Statement

Extended by:
Preparation::ClassMethods
Includes:
Idempotency, Idempotency::ClassMethods, Preparation, TypeHinting, TypeHinting::ClassMethods
Included in:
Core
Defined in:
lib/cassie/statements/statement.rb,
lib/cassie/statements/statement/mapping.rb,
lib/cassie/statements/statement/deleting.rb,
lib/cassie/statements/statement/ordering.rb,
lib/cassie/statements/statement/relation.rb,
lib/cassie/statements/statement/updating.rb,
lib/cassie/statements/statement/inserting.rb,
lib/cassie/statements/statement/relations.rb,
lib/cassie/statements/statement/selection.rb,
lib/cassie/statements/statement/assignment.rb,
lib/cassie/statements/statement/conditions.rb,
lib/cassie/statements/statement/assignments.rb,
lib/cassie/statements/statement/preparation.rb,
lib/cassie/statements/statement/allow_filtering.rb,
lib/cassie/statements/statement/preparation/cache.rb

Overview

Include Statement to provide support for a ‘statement` method returning a `Cassandra::Statements::Simple` statement with positional arguments.

‘type` and `table` attributes are also added, providing an extension interface for building cql and bindings for different statement types.

Defined Under Namespace

Modules: AllowFiltering, Assignments, Conditions, Deleting, Idempotency, Inserting, Limiting, Mapping, Ordering, Pagination, Preparation, Relations, Selection, TypeHinting, Updating Classes: Assignment, Invalid, Relation

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Preparation::ClassMethods

prepare, prepare=, prepare?

Methods included from Idempotency::ClassMethods

#idempotent, #idempotent=, #idempotent?, #non_idempotent

Methods included from Idempotency

#idempotent, #idempotent?

Methods included from TypeHinting::ClassMethods

#type_hints, #type_hints=

Methods included from TypeHinting

#type_hints

Methods included from Preparation

cache, init_cache

Instance Attribute Details

#cqlObject (readonly)

The CQL string portion for the statment

Examples:

statement.cql
#=> "SELECT * FROM table WHERE first=? AND middle=? and last=?"


76
77
78
79
# File 'lib/cassie/statements/statement.rb', line 76

def cql
  return @cql if defined?(@cql)
  ""
end

#paramsObject (readonly)

The positional values portion for the statment

Examples:

statement.params
#=> ['evan', 'thomas', 'prothro']


86
87
88
89
# File 'lib/cassie/statements/statement.rb', line 86

def params
  return @params if defined?(@params)
  nil
end

Instance Method Details

#loggerObject



67
68
69
# File 'lib/cassie/statements/statement.rb', line 67

def logger
  Cassie::Statements.logger
end

#statementCassandra::Statement

A bound statment with type hint and idempotent options, ready for execution ready for execution with a [Cassandra::Session]



45
46
47
# File 'lib/cassie/statements/statement.rb', line 45

def statement
  Cassandra::Statements::Simple.new(*build_cql_and_params, type_hints, idempotent?)
end

#tableObject



39
40
41
# File 'lib/cassie/statements/statement.rb', line 39

def table
  self.class.table
end

#to_cqlString

Note:

This CQL string does not include execution options like type hinting, idempotency, consistency level, etc – just the raw CQL instruction and values.

A CQL string with inline parameters, representing the current statement as it would be executed in a CQL shell

Examples:

statement.to_cql
#=> "SELECT * FROM table WHERE first='evan' AND middle='thomas' and last='prothro"


59
60
61
62
63
64
65
# File 'lib/cassie/statements/statement.rb', line 59

def to_cql
  if statement.respond_to?(:cql) && statement.respond_to?(:params)
    Cassie::Support::StatementParser.new(statement).to_cql
  else
    statement.to_s
  end
end