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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ee42c11d2d4d39946b1df62d6d0cd9ef240edf57
4
- data.tar.gz: c2d82f55a791696d8ea9e1d0529f0c1fbec31c02
3
+ metadata.gz: dcb7e0235108a8f81d404fd31054f2d1ac4701d4
4
+ data.tar.gz: 928b20dfd3e07da9062c3443b57de7b68e82f1df
5
5
  SHA512:
6
- metadata.gz: ced007c5c12672918218c0c3e24d792f77a84d81779c972aeb10b976355f9f5d860615835c1b7878f267380a19e8960a1f2cab347c15e978a65d3a287049a4be
7
- data.tar.gz: 896789b373ba5310738f046c823dac12f261f544116000a39594d9f4dd6a30cef37a213e7fbef3a3267565f8469c3124762c4b86475dae79677fb066d9b7d537
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 4.0 or higher and are using something other than the built in `PasswordAuthenticator` your setup is theoretically supported, but it's not field tested.
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 4.0 authentication is unfortunately 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, 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 4.0 uses a non-standard protocol, but it should be possible to get it working.
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
 
@@ -100,6 +100,7 @@ module Cql
100
100
  raise
101
101
  end
102
102
  end
103
+ @parts = []
103
104
  @request_runner.execute(connection, request, options[:timeout])
104
105
  end
105
106
 
@@ -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.on_complete(&listener)
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
- parts = []
32
- parts << (@n >> (24 * 4)).to_s(16).rjust(8, '0')
33
- parts << ((@n >> (20 * 4)) & 0xffff).to_s(16).rjust(4, '0')
34
- parts << ((@n >> (16 * 4)) & 0xffff).to_s(16).rjust(4, '0')
35
- parts << ((@n >> (12 * 4)) & 0xffff).to_s(16).rjust(4, '0')
36
- parts << (@n & 0xffffffffffff).to_s(16).rjust(12, '0')
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
- @h ||= 0x7fffffffffffffff - ((@n & 0xffffffffffffffff) ^ ((@n >> 64) & 0xffffffffffffffff))
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
- HEX_STRING_PATTERN = /^[0-9a-fA-F]+$/
61
+ RAW_FORMAT = '%032x'.force_encoding(Encoding::ASCII).freeze
62
+ HYPHEN = '-'.force_encoding(Encoding::ASCII).freeze
63
+ EMPTY_STRING = ''.freeze
63
64
 
64
- def from_s(str)
65
- str = str.gsub('-', '')
66
- raise ArgumentError, "Expected 32 chars but got #{str.length}" unless str.length == 32
67
- raise ArgumentError, "Expected only characters 0-9, a-f, A-F" unless str =~ HEX_STRING_PATTERN
68
- n = 0
69
- (str.length/2).times do |i|
70
- n = (n << 8) | str[i * 2, 2].to_i(16)
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
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Cql
4
- VERSION = '2.0.0.pre1'.freeze
4
+ VERSION = '2.0.0.pre2'.freeze
5
5
  end
@@ -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).and_yield(:row1).and_yield(:row2)
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' }
@@ -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.pre1
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-03-15 00:00:00.000000000 Z
11
+ date: 2014-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ione