rethinkdb 1.13.0.1 → 1.14.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5fe6c545db48fca4ef50d6963dcce1b12a54df31
4
- data.tar.gz: c6e34a121b3704940df425d3f88588de7b48e6cb
3
+ metadata.gz: b14d4516dee0a85107a2f9e59e508df5d6282245
4
+ data.tar.gz: cdb4c4f58579fe6bc7996782d5101cb3aa0bc40e
5
5
  SHA512:
6
- metadata.gz: 4ee1c1b7cbcddec88fb0fc2795f6e93dbae157ea7dcd23f13f363f8d961bdf1db2f3bcb4161719857a84dbaa01a14da674bc9540a2e5d88acad439c3d007b676
7
- data.tar.gz: 5f9a985e76c85c3289d1079e1f9c4ce268305cdf349dcf0cab98fc1163e0210eee39b27e2cf4b6105b92aaa6a77c8f6cbcaf664d9ef813e849e4c5fdebc9f249
6
+ metadata.gz: d4fdf55ab09026bd76c33f3803863f896f8c92c5a0b1f5f8dd69744fb672dde9f80913eefd46774d60c6af6d7863f407f48cfc44b080d64ee573b10c57865ffa
7
+ data.tar.gz: 522abfe5ea3458ce2ddbbb5cd8e400a6709d7e8c97a986877e976bf450026112f7a3369ab885eb5f1abb7e1c116736d53283e96a758c78d37955a64fb2f74280
data/lib/func.rb CHANGED
@@ -35,8 +35,10 @@ module RethinkDB
35
35
  :group => -1,
36
36
  :iso8601 => -1,
37
37
  :index_create => -1,
38
+ :index_rename => -1,
38
39
  :random => -1,
39
- :http => 1
40
+ :http => 1,
41
+ :distinct => -1
40
42
  }
41
43
  @@method_aliases = {
42
44
  :lt => :<,
@@ -58,6 +60,11 @@ module RethinkDB
58
60
  }
59
61
 
60
62
  termtypes = Term::TermType.constants.map{ |c| c.to_sym }
63
+
64
+ # r.binary has different behavior when operating on client-side strings vs
65
+ # terms on the server
66
+ termtypes.delete(:BINARY)
67
+
61
68
  termtypes.each {|termtype|
62
69
 
63
70
  method_body = proc { |*a, &b|
@@ -137,7 +144,7 @@ module RethinkDB
137
144
  def do(*args, &b)
138
145
  a = ((@body != RQL) ? [self] : []) + args.dup
139
146
  if a == [] && !b
140
- raise RqlDriverError, "Expected 1 or more argument(s) but found 0."
147
+ raise RqlDriverError, "Expected 1 or more arguments but found 0."
141
148
  end
142
149
  funcall_args = (b ? [new_func(&b)] : [a.pop]) + a
143
150
  # PP.pp funcall_args
data/lib/net.rb CHANGED
@@ -28,6 +28,12 @@ module RethinkDB
28
28
  raise ArgumentError, "`group_format` must be 'raw' or 'native' (got `#{gf}`)."
29
29
  end
30
30
  end
31
+ if (bf = opts[:binary_format])
32
+ opts[:binary_format] = (bf = bf.to_s)
33
+ if bf != 'raw' && bf != 'native'
34
+ raise ArgumentError, "`binary_format` must be 'raw' or 'native' (got `#{bf}`)."
35
+ end
36
+ end
31
37
  if !c
32
38
  raise ArgumentError, "No connection specified!\n" \
33
39
  "Use `query.run(conn)` or `conn.repl(); query.run`."
@@ -124,11 +130,18 @@ module RethinkDB
124
130
  @@last = self
125
131
  @default_opts = default_db ? {:db => RQL.new.db(default_db)} : {}
126
132
  @conn_id = 0
133
+
134
+ @token_cnt = 0
135
+ @token_cnt_mutex = Mutex.new
136
+
127
137
  reconnect(:noreply_wait => false)
128
138
  end
129
139
  attr_reader :default_db, :conn_id
130
140
 
131
- @@token_cnt = 0
141
+ def new_token
142
+ @token_cnt_mutex.synchronize{@token_cnt += 1}
143
+ end
144
+
132
145
  def set_opts(token, opts)
133
146
  @mutex.synchronize{@opts[token] = opts}
134
147
  end
@@ -149,7 +162,7 @@ module RethinkDB
149
162
  all_opts[:noreply] = !!all_opts[:noreply]
150
163
  end
151
164
 
152
- token = (@@token_cnt += 1)
165
+ token = new_token
153
166
  q = [Query::QueryType::START,
154
167
  msg,
155
168
  Hash[all_opts.map {|k,v|
@@ -279,7 +292,7 @@ module RethinkDB
279
292
  def noreply_wait
280
293
  raise RqlRuntimeError, "Error: Connection Closed." if !@socket || !@listener
281
294
  q = [Query::QueryType::NOREPLY_WAIT]
282
- res = run_internal(q, {noreply: false}, @@token_cnt += 1)
295
+ res = run_internal(q, {noreply: false}, new_token)
283
296
  if res['t'] != Response::ResponseType::WAIT_COMPLETE
284
297
  raise RqlRuntimeError, "Unexpected response to noreply_wait: " + PP.pp(res, "")
285
298
  end
data/lib/ql2.pb.rb CHANGED
@@ -148,6 +148,7 @@ module RethinkDB
148
148
  INDEX_LIST = 77
149
149
  INDEX_STATUS = 139
150
150
  INDEX_WAIT = 140
151
+ INDEX_RENAME = 156
151
152
  FUNCALL = 64
152
153
  BRANCH = 65
153
154
  ANY = 66
@@ -212,6 +213,7 @@ module RethinkDB
212
213
  RANDOM = 151
213
214
  CHANGES = 152
214
215
  ARGS = 154
216
+ BINARY = 155
215
217
  end
216
218
 
217
219
  module AssocPair
data/lib/rpp.rb CHANGED
@@ -11,6 +11,31 @@ module RethinkDB
11
11
  (bt && bt[0] == el) ? bt[1..-1] : nil
12
12
  end
13
13
 
14
+ def self.pp_pseudotype(q, pt, bt)
15
+ if not pt.has_key?('$reql_type$')
16
+ return false
17
+ end
18
+
19
+ case pt['$reql_type$']
20
+ when 'TIME' then
21
+ if not (pt.has_key?('epoch_time') and pt.has_key?('timezone'))
22
+ return false
23
+ end
24
+ t = Time.at(pt['epoch_time'])
25
+ tz = pt['timezone']
26
+ t = (tz && tz != "" && tz != "Z") ? t.getlocal(tz) : t.utc
27
+ q.text("r.expr(#{t.inspect})")
28
+ when 'BINARY' then
29
+ if not (pt.has_key?('data'))
30
+ return false
31
+ end
32
+ q.text("<data>")
33
+ else return false
34
+ end
35
+
36
+ return true
37
+ end
38
+
14
39
  def self.pp_int_optargs(q, optargs, bt, pre_dot = false)
15
40
  q.text("r(") if pre_dot
16
41
  q.group(1, "{", "}") {
@@ -73,7 +98,7 @@ module RethinkDB
73
98
  end
74
99
 
75
100
  def self.can_prefix (name, args)
76
- return !["db", "table", "funcall", "args", "branch"].include?(name)
101
+ return !["db", "table", "funcall", "args", "branch", "http", "binary"].include?(name)
77
102
  end
78
103
  def self.pp_int(q, term, bt, pre_dot=false)
79
104
  q.text("\x7", 0) if bt == []
@@ -82,7 +107,9 @@ module RethinkDB
82
107
  # PP.pp [:pp_int, term.to_json, bt]
83
108
  if term.class != Array
84
109
  if term.class == Hash
85
- pp_int_optargs(q, term, bt, pre_dot)
110
+ if not pp_pseudotype(q, term, bt)
111
+ pp_int_optargs(q, term, bt, pre_dot)
112
+ end
86
113
  else
87
114
  pp_int_datum(q, term, pre_dot)
88
115
  end
data/lib/shim.rb CHANGED
@@ -1,8 +1,14 @@
1
1
  module RethinkDB
2
2
  require 'json'
3
3
  require 'time'
4
+ require 'base64'
5
+
6
+ # Use a dummy object for binary data so we don't lose track of the data type
7
+ class Binary < String
8
+ end
9
+
4
10
  module Shim
5
- def self.recursive_munge(x, parse_time, parse_group)
11
+ def self.recursive_munge(x, parse_time, parse_group, parse_binary)
6
12
  case x
7
13
  when Hash
8
14
  if parse_time && x['$reql_type$'] == 'TIME'
@@ -11,15 +17,17 @@ module RethinkDB
11
17
  return (tz && tz != "" && tz != "Z") ? t.getlocal(tz) : t.utc
12
18
  elsif parse_group && x['$reql_type$'] == 'GROUPED_DATA'
13
19
  return Hash[x['data']]
20
+ elsif parse_binary && x['$reql_type$'] == 'BINARY'
21
+ return Binary.new(Base64.decode64(x['data'])).force_encoding('BINARY')
14
22
  else
15
23
  x.each {|k, v|
16
- v2 = recursive_munge(v, parse_time, parse_group)
24
+ v2 = recursive_munge(v, parse_time, parse_group, parse_binary)
17
25
  x[k] = v2 if v.object_id != v2.object_id
18
26
  }
19
27
  end
20
28
  when Array
21
29
  x.each_with_index {|v, i|
22
- v2 = recursive_munge(v, parse_time, parse_group)
30
+ v2 = recursive_munge(v, parse_time, parse_group, parse_binary)
23
31
  x[i] = v2 if v.object_id != v2.object_id
24
32
  }
25
33
  end
@@ -29,7 +37,8 @@ module RethinkDB
29
37
  def self.load_json(target, opts=nil)
30
38
  recursive_munge(JSON.parse(target, max_nesting: false),
31
39
  opts && opts[:time_format] != 'raw',
32
- opts && opts[:group_format] != 'raw')
40
+ opts && opts[:group_format] != 'raw',
41
+ opts && opts[:binary_format] != 'raw')
33
42
  end
34
43
 
35
44
  def self.dump_json(x)
@@ -61,6 +70,16 @@ module RethinkDB
61
70
  end
62
71
  def to_pb; @body; end
63
72
 
73
+ def binary(*a)
74
+ args = ((@body != RQL) ? [self] : []) + a
75
+ RQL.new([Term::TermType::BINARY, args.map {|x|
76
+ case x
77
+ when RQL then x.to_pb
78
+ else { '$reql_type$' => 'BINARY', 'data' => Base64.strict_encode64(x) }
79
+ end
80
+ }, []])
81
+ end
82
+
64
83
  def self.safe_to_s(x)
65
84
  case x
66
85
  when String then x
@@ -82,6 +101,7 @@ module RethinkDB
82
101
  when Hash then RQL.new(Hash[x.map{|k,v| [safe_to_s(k),
83
102
  fast_expr(v, max_depth-1)]}])
84
103
  when Proc then RQL.new.new_func(&x)
104
+ when Binary then RQL.new.binary(x)
85
105
  when String then RQL.new(x)
86
106
  when Symbol then RQL.new(x)
87
107
  when Numeric then RQL.new(x)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rethinkdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.13.0.1
4
+ version: 1.14.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - RethinkDB Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-30 00:00:00.000000000 Z
11
+ date: 2014-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -30,13 +30,13 @@ executables: []
30
30
  extensions: []
31
31
  extra_rdoc_files: []
32
32
  files:
33
- - lib/net.rb
33
+ - lib/ql2.pb.rb
34
34
  - lib/exc.rb
35
35
  - lib/func.rb
36
- - lib/shim.rb
36
+ - lib/net.rb
37
37
  - lib/rethinkdb.rb
38
38
  - lib/rpp.rb
39
- - lib/ql2.pb.rb
39
+ - lib/shim.rb
40
40
  homepage: http://rethinkdb.com
41
41
  licenses:
42
42
  - Apache-2