Class: CassandraCQL::V08::Statement
- Defined in:
- lib/cassandra-cql/0.8/statement.rb
Constant Summary collapse
- SCHEMA_CHANGE_RE =
/\s*(create|drop|alter)\s+(\w+)/i
- COLFAM_RE =
/\s*select.*from\s+'?(\w+)/i
Constants inherited from Statement
Statement::KS_CHANGE_RE, Statement::KS_DROP_RE
Instance Attribute Summary
Attributes inherited from Statement
Instance Method Summary collapse
Methods inherited from Statement
cast_to_cql, escape, #finish, #initialize, #prepare, quote, sanitize
Constructor Details
This class inherits a constructor from CassandraCQL::Statement
Instance Method Details
#execute(bind_vars = [], options = {}) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/cassandra-cql/0.8/statement.rb', line 7 def execute(bind_vars=[], ={}) column_family = nil if @statement =~ COLFAM_RE column_family = @handle.schema.column_families[$1].dup end sanitized_query = self.class.sanitize(@statement, bind_vars) compression_type = CassandraCQL::Thrift::Compression::NONE if [:compression] compression_type = CassandraCQL::Thrift::Compression::GZIP sanitized_query = Utility.compress(sanitized_query) end res = V08::Result.new(@handle.execute_cql_query(sanitized_query, compression_type), column_family) # Change our keyspace if required if @statement =~ KS_CHANGE_RE @handle.keyspace = $1 elsif @statement =~ KS_DROP_RE @handle.keyspace = nil end # We let ints be fetched for now because they'll probably be deprecated later if res.void? nil else res end end |