Sha256: 309cf6f08d41cd0efd09223c71d263fd5ee767fd7ca0c96c08b70eb870edacf9
Contents?: true
Size: 781 Bytes
Versions: 9
Compression:
Stored size: 781 Bytes
Contents
module Cassanity module ArgumentGenerators class ColumnFamilyInsert # Internal def call(args = {}) name = args.fetch(:column_family_name) data = args.fetch(:data) using = args[:using] || {} keys = data.keys binders = ['?'] * keys.size if (keyspace_name = args[:keyspace_name]) name = "#{keyspace_name}.#{name}" end cql = "INSERT INTO #{name} (#{keys.join(', ')}) VALUES (#{binders.join(', ')})" unless using.empty? statements = [] using.each do |key, value| statements << "#{key.upcase} #{value}" end cql << " USING #{statements.join(' AND ')}" end [cql, *data.values] end end end end
Version data entries
9 entries across 9 versions & 1 rubygems