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

Class Method Summary collapse

Instance Method Summary collapse

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

Class Method Details

.prepareBoolean Originally defined in module Preparation::ClassMethods

.prepare=(val) ⇒ Object Originally defined in module Preparation::ClassMethods

.prepare?Boolean Originally defined in module Preparation::ClassMethods

Instance Method Details

#idempotent(val = :get) ⇒ Boolean Originally defined in module Idempotency::ClassMethods

DSL to set a statement as idempotent

#idempotent=(val) ⇒ Object Originally defined in module Idempotency::ClassMethods

#idempotent?Boolean Originally defined in module Idempotency::ClassMethods

Indicates where the statement has no negative side-effect if issued multiple times.

#loggerObject


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

def logger
  Cassie::Statements.logger
end

#non_idempotentBoolean Originally defined in module Idempotency::ClassMethods

DSL to set a satement as non-idempotent

#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

#type_hints(hints = :get) ⇒ Array, Hash Originally defined in module TypeHinting::ClassMethods

DSL to set the type hints execution option Defaults to nil if none are set

#type_hints=(val) ⇒ Object Originally defined in module TypeHinting::ClassMethods