cql-rb 2.0.0.pre1 → 2.0.0.pre2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/cql/client/batch.rb +1 -0
- data/lib/cql/protocol/cql_protocol_handler.rb +2 -1
- data/lib/cql/uuid.rb +24 -17
- data/lib/cql/version.rb +1 -1
- data/spec/cql/client/batch_spec.rb +11 -0
- data/spec/cql/client/query_result_spec.rb +4 -1
- data/spec/cql/protocol/cql_protocol_handler_spec.rb +7 -0
- data/spec/cql/uuid_spec.rb +5 -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: dcb7e0235108a8f81d404fd31054f2d1ac4701d4
|
4
|
+
data.tar.gz: 928b20dfd3e07da9062c3443b57de7b68e82f1df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31788daec8a14dd8c2a3a0588e510ff54cef4b8ad289dfb806a978b49035345b760e5602cd5142930acfd2a56e6f289304efb714b5984f117b07e9196833d580
|
7
|
+
data.tar.gz: 4518fdb25311bd20433aae27094015d4502c53e9f793670a85fca6ed20da351e8065f08197a5621ecec3d82fe3050e6b368c02db5ffa614ddae82baf623b8c19
|
data/README.md
CHANGED
@@ -358,9 +358,9 @@ There's a known issue with collections that get too big. The protocol uses a sho
|
|
358
358
|
|
359
359
|
## Authentication doesn't work
|
360
360
|
|
361
|
-
Please open an issue. It should be working, but it's hard to set up and write automated tests for, so there may be edge cases that aren't covered. If you're using Cassandra 2.0 or DataStax Enterprise
|
361
|
+
Please open an issue. It should be working, but it's hard to set up and write automated tests for, so there may be edge cases that aren't covered. If you're using Cassandra 2.0 or DataStax Enterprise 3.1 or higher and/or are using something other than the built in `PasswordAuthenticator` your setup is theoretically supported, but it's not field tested.
|
362
362
|
|
363
|
-
If you are using DataStax Enterprise earlier than
|
363
|
+
If you are using DataStax Enterprise earlier than 3.1 authentication is unfortunately not supported. Please open an issue and we might be able to get it working, I just need someone who's willing to test it out. DataStax backported the authentication from Cassandra 2.0 into DSE 3.0, even though it only uses Cassandra 1.2. The authentication logic might not be able to handle this and will try to authenticate with DSE using an earlier version of the protocol. In short, DSE before 3.1 uses a non-standard protocol, but it should be possible to get it working. DSE 3.1 and 4.0 have been confirmed to work.
|
364
364
|
|
365
365
|
## I'm connecting to port 9160 and it doesn't work
|
366
366
|
|
data/lib/cql/client/batch.rb
CHANGED
@@ -84,7 +84,8 @@ module Cql
|
|
84
84
|
# @yieldparam error [nil, Error] the error that caused the connection to
|
85
85
|
# close, if any
|
86
86
|
def on_closed(&listener)
|
87
|
-
@closed_promise.future.
|
87
|
+
@closed_promise.future.on_value(&listener)
|
88
|
+
@closed_promise.future.on_failure(&listener)
|
88
89
|
end
|
89
90
|
|
90
91
|
# Register to receive server sent events, like schema changes, nodes going
|
data/lib/cql/uuid.rb
CHANGED
@@ -28,18 +28,17 @@ module Cql
|
|
28
28
|
#
|
29
29
|
def to_s
|
30
30
|
@s ||= begin
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
parts.join('-').force_encoding(::Encoding::ASCII)
|
31
|
+
s = RAW_FORMAT % @n
|
32
|
+
s.insert(20, HYPHEN)
|
33
|
+
s.insert(16, HYPHEN)
|
34
|
+
s.insert(12, HYPHEN)
|
35
|
+
s.insert( 8, HYPHEN)
|
36
|
+
s
|
38
37
|
end
|
39
38
|
end
|
40
39
|
|
41
40
|
def hash
|
42
|
-
@
|
41
|
+
@n.hash
|
43
42
|
end
|
44
43
|
|
45
44
|
# Returns the numerical representation of this UUID
|
@@ -59,17 +58,25 @@ module Cql
|
|
59
58
|
|
60
59
|
private
|
61
60
|
|
62
|
-
|
61
|
+
RAW_FORMAT = '%032x'.force_encoding(Encoding::ASCII).freeze
|
62
|
+
HYPHEN = '-'.force_encoding(Encoding::ASCII).freeze
|
63
|
+
EMPTY_STRING = ''.freeze
|
63
64
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
65
|
+
if RUBY_ENGINE == 'jruby'
|
66
|
+
HEX_RE = /^[A-Fa-f0-9]+$/
|
67
|
+
# See https://github.com/jruby/jruby/issues/1608
|
68
|
+
def from_s(str)
|
69
|
+
str = str.gsub(HYPHEN, EMPTY_STRING)
|
70
|
+
raise ArgumentError, "Expected 32 hexadecimal digits but got #{str.length}" unless str.length == 32
|
71
|
+
raise ArgumentError, "invalid value for Integer(): \"#{str}\"" unless str =~ HEX_RE
|
72
|
+
Integer(str, 16)
|
73
|
+
end
|
74
|
+
else
|
75
|
+
def from_s(str)
|
76
|
+
str = str.gsub(HYPHEN, EMPTY_STRING)
|
77
|
+
raise ArgumentError, "Expected 32 hexadecimal digits but got #{str.length}" unless str.length == 32
|
78
|
+
Integer(str, 16)
|
71
79
|
end
|
72
|
-
n
|
73
80
|
end
|
74
81
|
end
|
75
82
|
end
|
data/lib/cql/version.rb
CHANGED
@@ -86,6 +86,17 @@ module Cql
|
|
86
86
|
encoded_frame.to_s.should include(Protocol::ExecuteRequest.encode_values(Protocol::CqlByteBuffer.new, metadata, [3, 'foo']))
|
87
87
|
end
|
88
88
|
|
89
|
+
it 'resets the batch so that it can be used again' do
|
90
|
+
batch.add('UPDATE x SET y = 1 WHERE z = 2')
|
91
|
+
batch.execute.value
|
92
|
+
batch.add('UPDATE x SET y = 2 WHERE z = 3')
|
93
|
+
batch.execute.value
|
94
|
+
first_request, second_request = requests.map { |r| r[0].write(1, Protocol::CqlByteBuffer.new).to_s }
|
95
|
+
first_request.should include('UPDATE x SET y = 1 WHERE z = 2')
|
96
|
+
second_request.should include('UPDATE x SET y = 2 WHERE z = 3')
|
97
|
+
second_request.should_not include('UPDATE x SET y = 1 WHERE z = 2')
|
98
|
+
end
|
99
|
+
|
89
100
|
it 'uses the provided type hints' do
|
90
101
|
batch.add('UPDATE x SET y = 2 WHERE z = ?', 3, type_hints: [:int])
|
91
102
|
batch.execute.value
|
@@ -159,7 +159,10 @@ module Cql
|
|
159
159
|
|
160
160
|
describe '#each' do
|
161
161
|
it 'delegates to the wrapped result' do
|
162
|
-
query_result.stub(:each)
|
162
|
+
query_result.stub(:each) do |&block|
|
163
|
+
block.call(:row1)
|
164
|
+
block.call(:row2)
|
165
|
+
end
|
163
166
|
rows = paged_query_result.each_with_object([]) { |row, rows| rows << row }
|
164
167
|
rows.should == [:row1, :row2]
|
165
168
|
end
|
@@ -322,6 +322,13 @@ module Cql
|
|
322
322
|
called.should be_true, 'expected the close listener to have been called'
|
323
323
|
end
|
324
324
|
|
325
|
+
it 'passes the error that made the connection close to the listener' do
|
326
|
+
error = nil
|
327
|
+
protocol_handler.on_closed { |e| error = e }
|
328
|
+
connection.closed_listener.call(StandardError.new('Blurgh'))
|
329
|
+
error.message.should == 'Blurgh'
|
330
|
+
end
|
331
|
+
|
325
332
|
it 'ignores errors raised by the listener' do
|
326
333
|
called = false
|
327
334
|
protocol_handler.on_closed { |e| raise 'Blurgh' }
|
data/spec/cql/uuid_spec.rb
CHANGED
@@ -56,6 +56,11 @@ module Cql
|
|
56
56
|
it 'returns a UUID standard format' do
|
57
57
|
Uuid.new('a4a70900-24e1-11df-8924-001ff3591711').to_s.should == 'a4a70900-24e1-11df-8924-001ff3591711'
|
58
58
|
end
|
59
|
+
|
60
|
+
it 'returns an ASCII string' do
|
61
|
+
s = Uuid.new('a4a70900-24e1-11df-8924-001ff3591711').to_s
|
62
|
+
s.encoding.should == Encoding::ASCII
|
63
|
+
end
|
59
64
|
end
|
60
65
|
|
61
66
|
describe '#hash' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cql-rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0.
|
4
|
+
version: 2.0.0.pre2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Theo Hultberg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ione
|