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 +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +2 -2
- data/lib/cequel/type.rb +15 -8
- data/lib/cequel/version.rb +1 -1
- data/spec/examples/type_spec.rb +22 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a64f78d32fbb2e223d8537d5f0cf8c7ff61ed81c
|
4
|
+
data.tar.gz: 50b4f001571a9aa00025e5e0b46a845dc8b70ae1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 297d35f852f20151515ebba24607a7c13873f1a4930e365f75b1a9adf4352b7b14bc8a57b7e4f2348d64b2107631fff4b2f20bf5a8e385286df5143e3fff3faa
|
7
|
+
data.tar.gz: a12d232abd033573eaa674dd280dfee4d16a6775604ce510d23c7336190aa9572cf3cc4f23213e8bd5e41bd11a045ac7d5d44bbf579832ca78b6b0d6dddc1ad2
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
cequel (1.2.
|
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.
|
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)
|
data/lib/cequel/type.rb
CHANGED
@@ -85,19 +85,26 @@ module Cequel
|
|
85
85
|
end
|
86
86
|
case value
|
87
87
|
when ::String
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
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
|
-
|
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.
|
data/lib/cequel/version.rb
CHANGED
data/spec/examples/type_spec.rb
CHANGED
@@ -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.
|
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-
|
21
|
+
date: 2014-05-29 00:00:00.000000000 Z
|
22
22
|
dependencies:
|
23
23
|
- !ruby/object:Gem::Dependency
|
24
24
|
name: activemodel
|