sessionm-cassandra_object 4.0.18 → 4.0.20
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cassandra_object/adapters/cassandra_driver.rb +17 -26
- data/sessionm-cassandra_object.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 32924130490af3ac836dfc59d0c17814e0879928
|
4
|
+
data.tar.gz: 58f04eefe80bd07d77082945521c48acf43944c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c382c6fd5f4c0f4f31c7954c76f1c015c19c4630e56346478d2a41a2667ea6e578164292e3da233166e15657ec610d09400175727d43a595997c60d545388732
|
7
|
+
data.tar.gz: 63d6cb50a2bf1951a02ffb3e80213c0faf35ed289998e473dcc7f6316aa216220f5181c0bc4dc53ada42b5c1a785f4b19c85339b347bed7d216c059d30758acc
|
@@ -41,11 +41,9 @@ module CassandraObject
|
|
41
41
|
:port => 9042,
|
42
42
|
:connect_timeout => config[:thrift].try(:[], :connect_timeout) || 10,
|
43
43
|
:timeout => config[:thrift].try(:[], :timeout) || 10,
|
44
|
-
:logger => (defined?(Rails) && Rails.logger) || Logger.new(STDOUT)
|
45
|
-
:heartbeat_interval => nil,
|
46
|
-
:idle_timeout => nil
|
44
|
+
:logger => config[:logger] || (defined?(Rails) && Rails.logger) || Logger.new(STDOUT)
|
47
45
|
).merge(
|
48
|
-
:consistency => (config[:consistency] || {})[:write_default].try(:to_sym) || :one
|
46
|
+
:consistency => (config[:consistency] || {})[:write_default].try(:to_sym) || :one
|
49
47
|
)
|
50
48
|
end
|
51
49
|
|
@@ -85,11 +83,10 @@ module CassandraObject
|
|
85
83
|
async = opts.try(:[], :async)
|
86
84
|
|
87
85
|
insert_into_options = ttl ? " USING TTL #{ttl}" : ''
|
88
|
-
key = "textAsBlob('#{key}')"
|
89
86
|
|
90
87
|
query = "BEGIN BATCH\n"
|
91
88
|
query << values.map do |name, value|
|
92
|
-
" INSERT INTO \"#{column_family}\" (#{KEY_FIELD}, #{NAME_FIELD}, #{VALUE_FIELD}) VALUES (#{key}, #{escape(name, name_type(column_family))}, #{escape(value, value_type(column_family))})#{insert_into_options}"
|
89
|
+
" INSERT INTO \"#{column_family}\" (#{KEY_FIELD}, #{NAME_FIELD}, #{VALUE_FIELD}) VALUES (#{escape(key, key_type(column_family))}, #{escape(name, name_type(column_family))}, #{escape(value, value_type(column_family))})#{insert_into_options}"
|
93
90
|
end.join("\n")
|
94
91
|
query << "\nAPPLY BATCH;"
|
95
92
|
|
@@ -102,13 +99,11 @@ module CassandraObject
|
|
102
99
|
|
103
100
|
columns = columns_options.flatten.compact
|
104
101
|
|
105
|
-
key = "textAsBlob('#{key}')"
|
106
|
-
|
107
102
|
query =
|
108
103
|
if columns.size == 1
|
109
|
-
"SELECT #{VALUE_FIELD} FROM \"#{column_family}\" WHERE #{KEY_FIELD} = #{key} AND #{NAME_FIELD} =
|
104
|
+
"SELECT #{VALUE_FIELD} FROM \"#{column_family}\" WHERE #{KEY_FIELD} = #{escape(key, key_type(column_family))} AND #{NAME_FIELD} = #{escape(columns.first, name_type(column_family))}"
|
110
105
|
else
|
111
|
-
"SELECT #{NAME_FIELD}, #{VALUE_FIELD} FROM \"#{column_family}\" WHERE #{KEY_FIELD} = #{key}"
|
106
|
+
"SELECT #{NAME_FIELD}, #{VALUE_FIELD} FROM \"#{column_family}\" WHERE #{KEY_FIELD} = #{escape(key, key_type(column_family))}"
|
112
107
|
end
|
113
108
|
|
114
109
|
result = async ? self.execute_async(query, execute_options(opts)) : self.execute(query, execute_options(opts))
|
@@ -125,11 +120,9 @@ module CassandraObject
|
|
125
120
|
def get_columns(column_family, key, columns, opts)
|
126
121
|
async = opts.try(:[], :async)
|
127
122
|
|
128
|
-
|
129
|
-
|
130
|
-
name_fields = columns.map { |c| "'#{c}'" }.join(', ')
|
123
|
+
name_fields = columns.map { |c| escape(c, name_type(column_family)) }.join(', ')
|
131
124
|
|
132
|
-
query = "SELECT #{NAME_FIELD}, #{VALUE_FIELD} FROM \"#{column_family}\" WHERE #{NAME_FIELD} IN(#{name_fields}) AND #{KEY_FIELD} = #{key}"
|
125
|
+
query = "SELECT #{NAME_FIELD}, #{VALUE_FIELD} FROM \"#{column_family}\" WHERE #{NAME_FIELD} IN(#{name_fields}) AND #{KEY_FIELD} = #{escape(key, key_type(column_family))}"
|
133
126
|
|
134
127
|
result = async ? self.execute_async(query, execute_options(opts)) : self.execute(query, execute_options(opts))
|
135
128
|
return result if async
|
@@ -143,11 +136,9 @@ module CassandraObject
|
|
143
136
|
def get_columns_as_hash(column_family, key, columns, opts)
|
144
137
|
async = opts.try(:[], :async)
|
145
138
|
|
146
|
-
key = "textAsBlob('#{key}')"
|
147
|
-
|
148
139
|
name_fields = columns.map { |c| "'#{c}'" }.join(', ')
|
149
140
|
|
150
|
-
query = "SELECT #{NAME_FIELD}, #{VALUE_FIELD} FROM \"#{column_family}\" WHERE #{NAME_FIELD} IN(#{name_fields}) AND #{KEY_FIELD} = #{key}"
|
141
|
+
query = "SELECT #{NAME_FIELD}, #{VALUE_FIELD} FROM \"#{column_family}\" WHERE #{NAME_FIELD} IN(#{name_fields}) AND #{KEY_FIELD} = #{escape(key, key_type(column_family))}"
|
151
142
|
|
152
143
|
result = async ? self.execute_async(query, execute_options(opts)) : self.execute(query, execute_options(opts))
|
153
144
|
return result if async
|
@@ -163,10 +154,9 @@ module CassandraObject
|
|
163
154
|
def add(column_family, key, by, fields, opts=nil)
|
164
155
|
async = opts.try(:[], :async)
|
165
156
|
fields = [fields] unless fields.is_a?(Array)
|
166
|
-
key = "textAsBlob('#{key}')"
|
167
157
|
|
168
158
|
fields.each do |field|
|
169
|
-
query = "UPDATE \"#{column_family}\" SET #{VALUE_FIELD} = #{VALUE_FIELD} + #{by} WHERE #{KEY_FIELD} = #{key} AND #{NAME_FIELD} =
|
159
|
+
query = "UPDATE \"#{column_family}\" SET #{VALUE_FIELD} = #{VALUE_FIELD} + #{by} WHERE #{KEY_FIELD} = #{escape(key, key_type(column_family))} AND #{NAME_FIELD} = #{escape(field, name_type(column_family))};"
|
170
160
|
async ? self.execute_async(query, execute_options(opts)) : self.execute(query, execute_options(opts))
|
171
161
|
end
|
172
162
|
end
|
@@ -174,13 +164,12 @@ module CassandraObject
|
|
174
164
|
def remove(column_family, key, *args)
|
175
165
|
opts = args.pop if args.last.is_a?(Hash)
|
176
166
|
async = opts.try(:[], :async)
|
177
|
-
key = "textAsBlob('#{key}')"
|
178
167
|
|
179
168
|
query =
|
180
169
|
if args.first.nil? || args.first.is_a?(Hash)
|
181
|
-
"DELETE FROM \"#{column_family}\" WHERE #{KEY_FIELD} = #{key};"
|
170
|
+
"DELETE FROM \"#{column_family}\" WHERE #{KEY_FIELD} = #{escape(key, key_type(column_family))};"
|
182
171
|
else
|
183
|
-
"DELETE \"#{column_family}\" WHERE #{KEY_FIELD} = #{key} AND #{NAME_FIELD} =
|
172
|
+
"DELETE \"#{column_family}\" WHERE #{KEY_FIELD} = #{escape(key, key_type(column_family))} AND #{NAME_FIELD} = #{escape(args.first, name_type(column_family))};"
|
184
173
|
end
|
185
174
|
|
186
175
|
async ? self.execute_async(query, execute_options(opts)) : self.execute(query, execute_options(opts))
|
@@ -195,7 +184,7 @@ module CassandraObject
|
|
195
184
|
|
196
185
|
def multi_get(column_family, keys, *args)
|
197
186
|
opts = args.pop if args.last.is_a?(Hash)
|
198
|
-
keys = keys.map { |key|
|
187
|
+
keys = keys.map { |key| escape(key, key_type(column_family)) }.join(',')
|
199
188
|
results = {}
|
200
189
|
query = "SELECT * FROM \"#{column_family}\" WHERE #{KEY_FIELD} IN(#{keys})"
|
201
190
|
self.execute(query, execute_options(opts)).each do |row|
|
@@ -208,9 +197,7 @@ module CassandraObject
|
|
208
197
|
def get_slice(column_family, key, column, start, finish, count, reversed, consistency, opts={})
|
209
198
|
opts[:consistency] = consistency
|
210
199
|
|
211
|
-
|
212
|
-
|
213
|
-
query = "SELECT * FROM \"#{column_family}\" WHERE #{KEY_FIELD} = #{key}"
|
200
|
+
query = "SELECT * FROM \"#{column_family}\" WHERE #{KEY_FIELD} = #{escape(key, key_type(column_family))}"
|
214
201
|
query << " AND #{NAME_FIELD} = #{escape(column, name_type(column_family))}" if column
|
215
202
|
query << " AND #{NAME_FIELD} >= #{escape(start, name_type(column_family))}" unless start.empty?
|
216
203
|
query << " AND #{NAME_FIELD} <= #{escape(finish, name_type(column_family))}" unless finish.empty?
|
@@ -291,6 +278,10 @@ CQL
|
|
291
278
|
self.column_families[column_family.name.to_s] = column_family
|
292
279
|
end
|
293
280
|
|
281
|
+
def key_type(column_family)
|
282
|
+
self.cluster.keyspace(keyspace).table(column_family).column(KEY_FIELD).type.kind
|
283
|
+
end
|
284
|
+
|
294
285
|
def name_type(column_family)
|
295
286
|
self.cluster.keyspace(keyspace).table(column_family).column(NAME_FIELD).type.kind
|
296
287
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sessionm-cassandra_object
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
4
|
+
version: 4.0.20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Doug Youch
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2017-03-10 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Cassandra ActiveModel
|
15
15
|
email: doug@sessionm.com
|
@@ -151,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
151
151
|
version: '0'
|
152
152
|
requirements: []
|
153
153
|
rubyforge_project:
|
154
|
-
rubygems_version: 2.4.
|
154
|
+
rubygems_version: 2.4.8
|
155
155
|
signing_key:
|
156
156
|
specification_version: 4
|
157
157
|
summary: Cassandra ActiveModel
|