sessionm-cassandra_object 4.0.11 → 4.0.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1e09d42c44da63c37887407613d4abfab560b4ba
4
- data.tar.gz: d712eee439e1832cee073e0829b235016b1248ff
3
+ metadata.gz: 11fade06487e64fb440faa12d842abf5dd28ec69
4
+ data.tar.gz: d39185eda954f6d24cb700fba070147da68034e0
5
5
  SHA512:
6
- metadata.gz: 2a72f143c68b66fb4b29f88968504e50ad361af01d22c40316047142863ec87136bb0402ad570d59a36851151d7e6e84066e7dd0eaf0cd350fc23abb484f4c1d
7
- data.tar.gz: 617502c23d8ecb0f42b07f423ebfa180ec4d228e5f4a3ae48cd73b39895dc534decf3edc4fa79d5aabdb4b1097e8304cec787d63b1ea88b38ae888c1d6d73d45
6
+ metadata.gz: 87ff41502c07a90dd515e8a05d90f0c663c916e074fcdb4a0fe65af3bf5302fa9f646d4d24b30e4bfac00ea2add30ba537e4e5b8ac29f82bbe1f035e69c2cb2b
7
+ data.tar.gz: d47225dcaf82c9cf890f67f541f3b376adb88dbf8358d74c72d01a0e6522196da10092c4e33a92bb5c50e8d2fdd9e4beb366046be509226abd063af3e0fb6b63
@@ -75,7 +75,7 @@ module CassandraObject
75
75
 
76
76
  query = "BEGIN BATCH\n"
77
77
  query << values.map do |name, value|
78
- " INSERT INTO \"#{column_family}\" (#{KEY_FIELD}, #{NAME_FIELD}, #{VALUE_FIELD}) VALUES (#{key}, #{escape(name, opts.try(:[], :name_type))}, #{escape(value, opts.try(:[], :value_type))})#{insert_into_options}"
78
+ " 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}"
79
79
  end.join("\n")
80
80
  query << "\nAPPLY BATCH;"
81
81
 
@@ -177,10 +177,10 @@ module CassandraObject
177
177
  key = "textAsBlob('#{key}')"
178
178
 
179
179
  query = "SELECT * FROM \"#{column_family}\" WHERE #{KEY_FIELD} = #{key}"
180
- query << " AND #{NAME_FIELD} = #{escape(column, opts[:name_type])}" if column
181
- query << " AND #{NAME_FIELD} >= #{escape(start, opts[:name_type])}" unless start.empty?
182
- query << " AND #{NAME_FIELD} <= #{escape(finish, opts[:name_type])}" unless finish.empty?
183
- query << " ORDER BY #{NAME_FIELD} #{opts[:reverse_comparator] ? 'ASC' : 'DESC'}" if reversed
180
+ query << " AND #{NAME_FIELD} = #{escape(column, name_type(column_family))}" if column
181
+ query << " AND #{NAME_FIELD} >= #{escape(start, name_type(column_family))}" unless start.empty?
182
+ query << " AND #{NAME_FIELD} <= #{escape(finish, name_type(column_family))}" unless finish.empty?
183
+ query << " ORDER BY #{NAME_FIELD} #{reverse_comparator(column_family) ? 'ASC' : 'DESC'}" if reversed
184
184
  query << " LIMIT #{count}"
185
185
 
186
186
  self.execute(query, execute_options(opts)).inject({}) do |results, row|
@@ -243,6 +243,18 @@ CQL
243
243
  self.column_families[column_family.name.to_s] = column_family
244
244
  end
245
245
 
246
+ def name_type(column_family)
247
+ self.cluster.keyspace(keyspace).table(column_family).column(NAME_FIELD).type.kind
248
+ end
249
+
250
+ def value_type(column_family)
251
+ self.cluster.keyspace(keyspace).table(column_family).column(VALUE_FIELD).type.kind
252
+ end
253
+
254
+ def reverse_comparator(column_family)
255
+ self.cluster.keyspace(keyspace).table(column_family).send(:clustering_order).first == :desc
256
+ end
257
+
246
258
  def escape(str, type)
247
259
  case type
248
260
  when :timeuuid
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'sessionm-cassandra_object'
5
- s.version = '4.0.11'
5
+ s.version = '4.0.12'
6
6
  s.description = 'Cassandra ActiveModel'
7
7
  s.summary = 'Cassandra ActiveModel'
8
8
 
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.11
4
+ version: 4.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Doug Youch