cequel 1.2.5 → 1.2.6

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: 37fbccb394100663a372dde3d9308a890091e36c
4
- data.tar.gz: 2f594bf403ed6ba55ee54aa2c495c8c60fb6bb3a
3
+ metadata.gz: a64f78d32fbb2e223d8537d5f0cf8c7ff61ed81c
4
+ data.tar.gz: 50b4f001571a9aa00025e5e0b46a845dc8b70ae1
5
5
  SHA512:
6
- metadata.gz: 4f9d5c21fd006ce0e5021e3d6d3e144d5f27c075b56831fc0c766a9040a294e3c30dcf9e107fdb0f9b9f8677c490882a0bd6378a2af3d83a117e98e0fc39b098
7
- data.tar.gz: 6c4122980edd642cefb3056c2f8fe3c236cf3bc89db38e1328c52ed4365b386fef83a799afc9d08e82c0b5d3b5f14e9f013008b22fb27a78e3d1e75ee822b099
6
+ metadata.gz: 297d35f852f20151515ebba24607a7c13873f1a4930e365f75b1a9adf4352b7b14bc8a57b7e4f2348d64b2107631fff4b2f20bf5a8e385286df5143e3fff3faa
7
+ data.tar.gz: a12d232abd033573eaa674dd280dfee4d16a6775604ce510d23c7336190aa9572cf3cc4f23213e8bd5e41bd11a045ac7d5d44bbf579832ca78b6b0d6dddc1ad2
@@ -1,3 +1,7 @@
1
+ ## 1.2.6
2
+
3
+ * Fixes for Type::quote
4
+
1
5
  ## 1.2.5
2
6
 
3
7
  * Fix `puts` behavior when passed a Record instance
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cequel (1.2.5)
4
+ cequel (1.2.6)
5
5
  activemodel (>= 3.1, < 5.0)
6
6
  cql-rb (~> 1.2)
7
7
 
@@ -58,7 +58,7 @@ GEM
58
58
  psych (2.0.5)
59
59
  racc (1.4.11)
60
60
  rainbow (2.0.0)
61
- rake (10.3.1)
61
+ rake (10.3.2)
62
62
  rspec (2.14.1)
63
63
  rspec-core (~> 2.14.0)
64
64
  rspec-expectations (~> 2.14.0)
@@ -85,19 +85,26 @@ module Cequel
85
85
  end
86
86
  case value
87
87
  when ::String
88
- if value.encoding == Encoding::ASCII_8BIT
89
- "0x#{value}"
90
- else
91
- "'#{value.gsub("'", "''")}'"
92
- end
93
- when Date, Time, ActiveSupport::TimeWithZone
94
- quote(value.to_i * 1000 + value.usec / 1000)
88
+ quote_string(value)
89
+ when Time, ActiveSupport::TimeWithZone, DateTime
90
+ value.strftime('%s%L')
91
+ when Date
92
+ quote(Time.gm(value.year, value.month, value.day))
95
93
  when Numeric, true, false, Cql::Uuid
96
94
  value.to_s
97
95
  else
98
- quote(value.to_s)
96
+ quote_string(value.to_s)
97
+ end
98
+ end
99
+
100
+ def self.quote_string(string)
101
+ if string.encoding == Encoding::ASCII_8BIT && string =~ /^[[:xdigit:]]+$/
102
+ "0x#{string}"
103
+ else
104
+ "'#{string.gsub("'", "''")}'"
99
105
  end
100
106
  end
107
+ private_class_method :quote_string
101
108
 
102
109
  #
103
110
  # The base class for all type objects. Types are singletons.
@@ -1,5 +1,5 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module Cequel
3
3
  # The current version of the library
4
- VERSION = '1.2.5'
4
+ VERSION = '1.2.6'
5
5
  end
@@ -204,4 +204,26 @@ describe Cequel::Type do
204
204
  end
205
205
  end
206
206
 
207
+ describe '::quote' do
208
+ [
209
+ ["don't", "'don''t'"],
210
+ ["don't".force_encoding('US-ASCII'), "'don''t'"],
211
+ ["don't".force_encoding('ASCII-8BIT'), "'don''t'"],
212
+ ["3dc49a6".force_encoding('ASCII-8BIT'), "0x3dc49a6"],
213
+ [["one", "two"], "'one','two'"],
214
+ [1, '1'],
215
+ [1.2, '1.2'],
216
+ [true, 'true'],
217
+ [false, 'false'],
218
+ [Time.at(1401323181, 381000), '1401323181381'],
219
+ [Time.at(1401323181, 381000).in_time_zone, '1401323181381'],
220
+ [Date.parse('2014-05-28'), "1401235200000"],
221
+ [Time.at(1401323181, 381000).to_datetime, '1401323181381'],
222
+ [Cequel.uuid("dbf51e0e-e6c7-11e3-be60-237d76548395"),
223
+ "dbf51e0e-e6c7-11e3-be60-237d76548395"]
224
+ ].each do |input, output|
225
+ specify { expect(Cequel::Type.quote(input)).to eq(output) }
226
+ end
227
+ end
228
+
207
229
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cequel
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.5
4
+ version: 1.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mat Brown
@@ -18,7 +18,7 @@ authors:
18
18
  autorequire:
19
19
  bindir: bin
20
20
  cert_chain: []
21
- date: 2014-05-16 00:00:00.000000000 Z
21
+ date: 2014-05-29 00:00:00.000000000 Z
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
24
24
  name: activemodel