Builder of CQL 3 (Cassandra Query Language) statements in OOP style.
require "query_builder"
include QueryBuilder::CQL::Operators # for operators like cql_gt, cql_lte below.
table = QueryBuilder::CQL.keyspace(:auth).table(:users)
statement = table
.select(:id, :role)
.select(name: :user)
.where(id: cql_gt(1))
.where(id: cql_lte(4))
.using(consistency: :quorum)
.limit(3)
# => #<QueryBuilder::CQL::Statements::Select ...>
statement.to_s
# => "SELECT id, role, user AS name FROM auth.users WHERE id > 1 AND id <= 4 USING consistency = 'quorum' LIMIT 3;"
See the list of all supported contexts, statements and operators.
The gem doesn't depend on any specific Cassandra driver. It could be used to extend official Datastax driver with features of CQL building.
It doesn't validate CQL statements, leaving this to either driver or Cassandra database.
Add this line to your application's Gemfile:
# Gemfile
gem "query_builder"
Then execute:
bundle
Or add it manually:
gem install query_builder
Tested under rubies compatible to MRI 1.9.3+.
Uses RSpec 3.0+ for testing and hexx-suit for dev/test tools collection.
git checkout -b my-new-feature
)git commit -am '[UPDATE] Add some feature'
)git push origin my-new-feature
)See the MIT LICENSE.