rethinkdb 1.11.0.2 → 1.12.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/func.rb +76 -98
- data/lib/net.rb +18 -12
- data/lib/ql2.pb.rb +10 -2
- data/lib/rethinkdb.rb +6 -7
- data/lib/rpp.rb +2 -16
- data/lib/shim.rb +49 -37
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eba1925eeec3a40cbebb6209d1f659b7880ac82f
|
4
|
+
data.tar.gz: a84db592ff134e93e9505fb1bc1e84a147643aab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a31d54964b3086feac437eb843bedbc83cc3c4cdf7999128775b121576488ad6f06c5f03c45397b92d243c6e0000b866fad7d7f5797995f370420eb9d2391f2
|
7
|
+
data.tar.gz: a67cf797dd62f616e0992b913b028b8c8ef919388f90ae54301b1a4ba5730b6a66f9d135cd660368df82137b29af437278ddc6c557806b25fbe10f223d635ac3
|
data/lib/func.rb
CHANGED
@@ -15,89 +15,95 @@ module RethinkDB
|
|
15
15
|
# only be removed from the argument list and treated as an optarg
|
16
16
|
# if it's a Hash. A positive value is necessary for functions
|
17
17
|
# that can take a hash for the last non-optarg argument.
|
18
|
-
# NOTE: we search for the optarg after we apply the rewrite rules below.
|
19
|
-
# For example we need to use orderby not order_by
|
20
18
|
@@optarg_offsets = {
|
21
19
|
:replace => {:with_block => 0, :without => 1},
|
22
20
|
:update => {:with_block => 0, :without => 1},
|
23
21
|
:insert => 1,
|
24
22
|
:delete => -1,
|
25
|
-
:reduce => -1,
|
26
|
-
:
|
27
|
-
:
|
28
|
-
:
|
29
|
-
:
|
30
|
-
:
|
23
|
+
:reduce => -1,
|
24
|
+
:between => 2,
|
25
|
+
:table => -1,
|
26
|
+
:table_create => -1,
|
27
|
+
:get_all => -1,
|
28
|
+
:eq_join => -1,
|
29
|
+
:javascript => -1,
|
30
|
+
:filter => {:with_block => 0, :without => 1},
|
31
|
+
:slice => -1,
|
32
|
+
:during => -1,
|
33
|
+
:orderby => -1,
|
34
|
+
:group => -1,
|
35
|
+
:iso8601 => -1,
|
36
|
+
:index_create => -1
|
31
37
|
}
|
32
|
-
@@
|
33
|
-
|
34
|
-
|
35
|
-
:
|
36
|
-
:
|
37
|
-
:
|
38
|
-
:
|
39
|
-
:
|
40
|
-
:
|
41
|
-
:
|
42
|
-
:
|
38
|
+
@@method_aliases = {
|
39
|
+
:lt => :<,
|
40
|
+
:le => :<=,
|
41
|
+
:gt => :>,
|
42
|
+
:ge => :>=,
|
43
|
+
:add => :+,
|
44
|
+
:sub => :-,
|
45
|
+
:mul => :*,
|
46
|
+
:div => :/,
|
47
|
+
:mod => :%,
|
48
|
+
:any => [:"|", :or],
|
49
|
+
:all => [:"&", :and],
|
50
|
+
:orderby => :order_by,
|
51
|
+
:concatmap => :concat_map,
|
52
|
+
:foreach => :for_each,
|
53
|
+
:javascript => :js,
|
54
|
+
:typeof => :type_of
|
43
55
|
}
|
44
|
-
@@allow_json = {:
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
termtype = Term::TermType.const_get(m.to_s.upcase)
|
65
|
-
rescue NameError => e
|
66
|
-
unbound_if(true, old_m)
|
67
|
-
end
|
68
|
-
unbound_if(!termtype, m)
|
56
|
+
@@allow_json = {:INSERT => true}
|
57
|
+
|
58
|
+
termtypes = Term::TermType.constants.map{ |c| c.to_sym }
|
59
|
+
termtypes.each {|termtype|
|
60
|
+
|
61
|
+
method = define_method(termtype.downcase){|*a, &b|
|
62
|
+
bitop = [:"|", :"&"].include?(__method__)
|
63
|
+
|
64
|
+
if [:<, :<=, :>, :>=, :+, :-, :*, :/, :%].include?(__method__)
|
65
|
+
a.each {|arg|
|
66
|
+
if arg.class == RQL && arg.bitop
|
67
|
+
err = "Calling #{__method__} on result of infix bitwise operator:\n" +
|
68
|
+
"#{arg.inspect}.\n" +
|
69
|
+
"This is almost always a precedence error.\n" +
|
70
|
+
"Note that `a < b | b < c` <==> `a < (b | b) < c`.\n" +
|
71
|
+
"If you really want this behavior, use `.or` or `.and` instead."
|
72
|
+
raise RqlDriverError, err
|
73
|
+
end
|
74
|
+
}
|
75
|
+
end
|
69
76
|
|
70
|
-
|
71
|
-
|
72
|
-
|
77
|
+
if (opt_offset = @@optarg_offsets[termtype.downcase])
|
78
|
+
if opt_offset.class == Hash
|
79
|
+
opt_offset = opt_offset[b ? :with_block : :without]
|
80
|
+
end
|
81
|
+
# TODO: This should drop the Hash comparison or at least
|
82
|
+
# @@optarg_offsets should stop specifying -1, where possible.
|
83
|
+
# Any time one of these operations is changed to support a
|
84
|
+
# hash argument, we'll have to remember to fix
|
85
|
+
# @@optarg_offsets, otherwise.
|
86
|
+
optargs = a.delete_at(opt_offset) if a[opt_offset].class == Hash
|
73
87
|
end
|
74
|
-
# TODO: This should drop the Hash comparison or at least
|
75
|
-
# @@optarg_offsets should stop specifying -1, where possible.
|
76
|
-
# Any time one of these operations is changed to support a
|
77
|
-
# hash argument, we'll have to remember to fix
|
78
|
-
# @@optarg_offsets, otherwise.
|
79
|
-
optargs = a.delete_at(opt_offset) if a[opt_offset].class == Hash
|
80
|
-
end
|
81
88
|
|
82
|
-
|
89
|
+
args = (@body ? [self] : []) + a + (b ? [new_func(&b)] : [])
|
83
90
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
91
|
+
t = Term.new
|
92
|
+
t.type = Term::TermType.const_get(termtype)
|
93
|
+
t.args = args.map{|x| RQL.new.expr(x, :allow_json => @@allow_json[termtype]).to_pb}
|
94
|
+
t.optargs = (optargs || {}).map {|k,v|
|
95
|
+
ap = Term::AssocPair.new
|
96
|
+
ap.key = k.to_s
|
97
|
+
ap.val = RQL.new.expr(v, :allow_json => @@allow_json[termtype]).to_pb
|
98
|
+
ap
|
99
|
+
}
|
100
|
+
return RQL.new(t, bitop)
|
92
101
|
}
|
93
|
-
return RQL.new(t, bitop)
|
94
|
-
end
|
95
102
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
def groupby(*a, &b); group_by(*a, &b); end
|
103
|
+
[*@@method_aliases[termtype.downcase]].each{|method_alias|
|
104
|
+
define_method method_alias, method
|
105
|
+
}
|
106
|
+
}
|
101
107
|
|
102
108
|
def connect(*args, &b)
|
103
109
|
unbound_if @body
|
@@ -105,33 +111,6 @@ module RethinkDB
|
|
105
111
|
b ? begin b.call(c) ensure c.close end : c
|
106
112
|
end
|
107
113
|
|
108
|
-
def avg(attr)
|
109
|
-
unbound_if @body
|
110
|
-
{:AVG => attr}
|
111
|
-
end
|
112
|
-
def sum(attr)
|
113
|
-
unbound_if @body
|
114
|
-
{:SUM => attr}
|
115
|
-
end
|
116
|
-
def count(*a, &b)
|
117
|
-
!@body && a == [] ? {:COUNT => true} : super(*a, &b)
|
118
|
-
end
|
119
|
-
|
120
|
-
def reduce(*a, &b)
|
121
|
-
args = a.dup
|
122
|
-
base_offset_front = (@body ? 0 : 1)
|
123
|
-
base_offset_back = args.size - (b ? 1 : 2)
|
124
|
-
if base_offset_front == base_offset_back
|
125
|
-
args << {:base => args.delete_at(base_offset_front)}
|
126
|
-
end
|
127
|
-
super(*args, &b)
|
128
|
-
end
|
129
|
-
|
130
|
-
def grouped_map_reduce(*a, &b)
|
131
|
-
a << {:base => a.delete_at(-2)} if a.size >= 2 && a[-2].class != Proc
|
132
|
-
super(*a, &b)
|
133
|
-
end
|
134
|
-
|
135
114
|
def -@; RQL.new.sub(0, self); end
|
136
115
|
|
137
116
|
def [](ind)
|
@@ -155,7 +134,6 @@ module RethinkDB
|
|
155
134
|
their protobufs like: `query1.to_pb == query2.to_pb`."
|
156
135
|
end
|
157
136
|
|
158
|
-
|
159
137
|
def do(*args, &b)
|
160
138
|
a = (@body ? [self] : []) + args.dup
|
161
139
|
if a == [] && !b
|
data/lib/net.rb
CHANGED
@@ -34,6 +34,12 @@ module RethinkDB
|
|
34
34
|
raise ArgumentError, "`time_format` must be 'raw' or 'native' (got `#{tf}`)."
|
35
35
|
end
|
36
36
|
end
|
37
|
+
if (gf = opts[:group_format])
|
38
|
+
opts[:group_format] = (gf = gf.to_s)
|
39
|
+
if gf != 'raw' && gf != 'native'
|
40
|
+
raise ArgumentError, "`group_format` must be 'raw' or 'native' (got `#{gf}`)."
|
41
|
+
end
|
42
|
+
end
|
37
43
|
if !c
|
38
44
|
raise ArgumentError, "No connection specified!\n" \
|
39
45
|
"Use `query.run(conn)` or `conn.repl(); query.run`."
|
@@ -199,10 +205,10 @@ module RethinkDB
|
|
199
205
|
begin
|
200
206
|
res = nil
|
201
207
|
raise RqlRuntimeError, "Connection closed by server!" if not @listener
|
202
|
-
@mutex.synchronize
|
208
|
+
@mutex.synchronize {
|
203
209
|
(@waiters[token] = ConditionVariable.new).wait(@mutex) if not @data[token]
|
204
210
|
res = @data.delete token if @data[token]
|
205
|
-
|
211
|
+
}
|
206
212
|
raise RqlRuntimeError, "Connection closed by server!" if !@listener or !res
|
207
213
|
return res
|
208
214
|
rescue @abort_module::Abort => e
|
@@ -309,16 +315,16 @@ module RethinkDB
|
|
309
315
|
end
|
310
316
|
|
311
317
|
@listener.terminate if @listener
|
312
|
-
@listener = Thread.new
|
313
|
-
loop
|
318
|
+
@listener = Thread.new {
|
319
|
+
loop {
|
314
320
|
begin
|
315
321
|
response_length = @socket.read_exn(4).unpack('L<')[0]
|
316
322
|
response = @socket.read_exn(response_length)
|
317
323
|
rescue RqlRuntimeError => e
|
318
|
-
@mutex.synchronize
|
324
|
+
@mutex.synchronize {
|
319
325
|
@listener = nil
|
320
326
|
@waiters.each {|kv| kv[1].signal}
|
321
|
-
|
327
|
+
}
|
322
328
|
Thread.current.terminate
|
323
329
|
abort("unreachable")
|
324
330
|
end
|
@@ -329,7 +335,7 @@ module RethinkDB
|
|
329
335
|
raise RqlRuntimeError, "Bad Protobuf #{response}, server is buggy."
|
330
336
|
end
|
331
337
|
if protob.token == -1
|
332
|
-
@mutex.synchronize
|
338
|
+
@mutex.synchronize {
|
333
339
|
@waiters.keys.each {|k|
|
334
340
|
@data[k] = protob
|
335
341
|
if @waiters[k]
|
@@ -337,18 +343,18 @@ module RethinkDB
|
|
337
343
|
cond.signal
|
338
344
|
end
|
339
345
|
}
|
340
|
-
|
346
|
+
}
|
341
347
|
else
|
342
|
-
@mutex.synchronize
|
348
|
+
@mutex.synchronize {
|
343
349
|
@data[protob.token] = protob
|
344
350
|
if @waiters[protob.token]
|
345
351
|
cond = @waiters.delete protob.token
|
346
352
|
cond.signal
|
347
353
|
end
|
348
|
-
|
354
|
+
}
|
349
355
|
end
|
350
|
-
|
351
|
-
|
356
|
+
}
|
357
|
+
}
|
352
358
|
end
|
353
359
|
end
|
354
360
|
end
|
data/lib/ql2.pb.rb
CHANGED
@@ -200,6 +200,7 @@ class Term < ::ProtocolBuffers::Message
|
|
200
200
|
CONTAINS = 93
|
201
201
|
GET_FIELD = 31
|
202
202
|
KEYS = 94
|
203
|
+
OBJECT = 143
|
203
204
|
HAS_FIELDS = 32
|
204
205
|
WITH_FIELDS = 96
|
205
206
|
PLUCK = 33
|
@@ -216,8 +217,6 @@ class Term < ::ProtocolBuffers::Message
|
|
216
217
|
IS_EMPTY = 86
|
217
218
|
UNION = 44
|
218
219
|
NTH = 45
|
219
|
-
GROUPED_MAP_REDUCE = 46
|
220
|
-
GROUPBY = 47
|
221
220
|
INNER_JOIN = 48
|
222
221
|
OUTER_JOIN = 49
|
223
222
|
EQ_JOIN = 50
|
@@ -254,6 +253,8 @@ class Term < ::ProtocolBuffers::Message
|
|
254
253
|
DESC = 74
|
255
254
|
INFO = 79
|
256
255
|
MATCH = 97
|
256
|
+
UPCASE = 141
|
257
|
+
DOWNCASE = 142
|
257
258
|
SAMPLE = 81
|
258
259
|
DEFAULT = 92
|
259
260
|
JSON = 98
|
@@ -296,6 +297,13 @@ class Term < ::ProtocolBuffers::Message
|
|
296
297
|
NOVEMBER = 124
|
297
298
|
DECEMBER = 125
|
298
299
|
LITERAL = 137
|
300
|
+
GROUP = 144
|
301
|
+
SUM = 145
|
302
|
+
AVG = 146
|
303
|
+
MIN = 147
|
304
|
+
MAX = 148
|
305
|
+
SPLIT = 149
|
306
|
+
UNGROUP = 150
|
299
307
|
end
|
300
308
|
|
301
309
|
set_fully_qualified_name "Term"
|
data/lib/rethinkdb.rb
CHANGED
@@ -18,7 +18,6 @@ class Term::AssocPair
|
|
18
18
|
end
|
19
19
|
|
20
20
|
class Term
|
21
|
-
attr_accessor :context
|
22
21
|
attr_accessor :is_error
|
23
22
|
|
24
23
|
def deep_dup
|
@@ -60,12 +59,13 @@ module RethinkDB
|
|
60
59
|
|
61
60
|
module Utils
|
62
61
|
def get_mname(i = 0)
|
63
|
-
caller[
|
64
|
-
$1
|
62
|
+
caller(i, 1)[0] =~ /`(.*?)'/; $1
|
65
63
|
end
|
66
64
|
def unbound_if (x, name = nil)
|
67
|
-
|
68
|
-
|
65
|
+
if x
|
66
|
+
name = get_mname(2) if not name
|
67
|
+
raise NoMethodError, "undefined method `#{name}'"
|
68
|
+
end
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
@@ -74,10 +74,9 @@ module RethinkDB
|
|
74
74
|
|
75
75
|
attr_accessor :body, :bitop
|
76
76
|
|
77
|
-
def initialize(body = nil, bitop = nil
|
77
|
+
def initialize(body = nil, bitop = nil)
|
78
78
|
@body = body
|
79
79
|
@bitop = bitop
|
80
|
-
@body.context = (context || RPP.sanitize_context(caller)) if @body
|
81
80
|
end
|
82
81
|
|
83
82
|
def pp
|
data/lib/rpp.rb
CHANGED
@@ -6,15 +6,7 @@ module RethinkDB
|
|
6
6
|
@@termtype_to_str = Hash[
|
7
7
|
Term::TermType.constants.map{|x| [Term::TermType.const_get(x), x.to_s]}
|
8
8
|
]
|
9
|
-
|
10
|
-
def self.sanitize_context context
|
11
|
-
if __FILE__ =~ /^(.*\/)[^\/]+.rb$/
|
12
|
-
prefix = $1;
|
13
|
-
context.reject{|x| x =~ /^#{prefix}/}
|
14
|
-
else
|
15
|
-
context
|
16
|
-
end
|
17
|
-
end
|
9
|
+
@@regex = if __FILE__ =~ /^(.*\/)[^\/]+.rb$/ then /^#{$1}/ else nil end
|
18
10
|
|
19
11
|
def self.pp_int_optargs(q, optargs, pre_dot = false)
|
20
12
|
q.text("r(") if pre_dot
|
@@ -77,7 +69,6 @@ module RethinkDB
|
|
77
69
|
end
|
78
70
|
def self.pp_int(q, term, pre_dot=false)
|
79
71
|
q.text("\x7", 0) if term.is_error
|
80
|
-
@@context = term.context if term.is_error
|
81
72
|
|
82
73
|
if term.type == Term::TermType::DATUM
|
83
74
|
res = pp_int_datum(q, term.datum, pre_dot)
|
@@ -165,7 +156,6 @@ module RethinkDB
|
|
165
156
|
|
166
157
|
def self.pp term
|
167
158
|
begin
|
168
|
-
@@context = nil
|
169
159
|
q = PrettyPrint.new
|
170
160
|
pp_int(q, term, true)
|
171
161
|
q.flush
|
@@ -180,11 +170,7 @@ module RethinkDB
|
|
180
170
|
else
|
181
171
|
line
|
182
172
|
end
|
183
|
-
}.flatten.join("\n")
|
184
|
-
(@@context ?
|
185
|
-
"\nErroneous_Portion_Constructed:\n" +
|
186
|
-
"#{@@context.map{|x| "\tfrom "+x}.join("\n")}" +
|
187
|
-
"\nCalled:" : "")
|
173
|
+
}.flatten.join("\n")
|
188
174
|
rescue Exception => e
|
189
175
|
raise e
|
190
176
|
"AN ERROR OCCURED DURING PRETTY-PRINTING:\n#{e.inspect}\n" +
|
data/lib/shim.rb
CHANGED
@@ -2,9 +2,7 @@ require 'json'
|
|
2
2
|
require 'time'
|
3
3
|
|
4
4
|
module RethinkDB
|
5
|
-
|
6
5
|
module Shim
|
7
|
-
|
8
6
|
def self.is_reql_time(obj)
|
9
7
|
obj.is_a? Hash and obj["$reql_type$"] == "TIME"
|
10
8
|
end
|
@@ -15,26 +13,50 @@ module RethinkDB
|
|
15
13
|
(tz && tz != "" && tz != "Z") ? t.getlocal(tz) : t.utc
|
16
14
|
end
|
17
15
|
|
18
|
-
def self.
|
16
|
+
def self.is_grouped_data(obj)
|
17
|
+
obj.is_a? Hash and obj["$reql_type$"] == "GROUPED_DATA"
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.convert_grouped_data(obj, opts)
|
21
|
+
convert_reql_types!(obj['data'], opts)
|
22
|
+
Hash[obj["data"]]
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.maybe_convert_type(obj, opts)
|
26
|
+
if opts[:time_format] != 'raw' && is_reql_time(obj)
|
27
|
+
convert_time(obj)
|
28
|
+
elsif opts[:group_format] != 'raw' && is_grouped_data(obj)
|
29
|
+
convert_grouped_data(obj, opts)
|
30
|
+
else
|
31
|
+
nil
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.convert_reql_types!(result, opts)
|
19
36
|
case result
|
20
37
|
when Hash
|
21
|
-
result.each {
|
22
|
-
if
|
23
|
-
result[k] =
|
38
|
+
result.each {|k,v|
|
39
|
+
if (new_res = maybe_convert_type(v, opts))
|
40
|
+
result[k] = new_res
|
24
41
|
else
|
25
|
-
|
42
|
+
convert_reql_types!(v, opts)
|
26
43
|
end
|
27
44
|
}
|
28
45
|
when Array
|
29
|
-
result.each_index {
|
30
|
-
if
|
31
|
-
result[i] =
|
46
|
+
result.each_index {|i|
|
47
|
+
if (new_res = maybe_convert_type(result[i], opts))
|
48
|
+
result[i] = new_res;
|
32
49
|
else
|
33
|
-
|
50
|
+
convert_reql_types!(result[i], opts)
|
34
51
|
end
|
35
52
|
}
|
36
53
|
end
|
37
|
-
|
54
|
+
nil
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.postprocess!(result, opts)
|
58
|
+
maybe_convert_type(result, opts) \
|
59
|
+
|| (convert_reql_types!(result, opts); result)
|
38
60
|
end
|
39
61
|
|
40
62
|
def self.datum_to_native(d, opts)
|
@@ -48,18 +70,9 @@ module RethinkDB
|
|
48
70
|
when dt::R_ARRAY then d.r_array.map{|d2| datum_to_native(d2, opts)}
|
49
71
|
when dt::R_OBJECT then
|
50
72
|
obj = Hash[d.r_object.map{|x| [x.key, datum_to_native(x.val, opts)]}]
|
51
|
-
|
52
|
-
is_reql_time(obj) ? convert_time(obj) : obj
|
53
|
-
else
|
54
|
-
obj
|
55
|
-
end
|
73
|
+
postprocess!(obj, opts)
|
56
74
|
when dt::R_JSON then
|
57
|
-
|
58
|
-
if opts[:time_format] != 'raw'
|
59
|
-
is_reql_time(result) ? convert_time(result) : convert_times!(result)
|
60
|
-
else
|
61
|
-
result
|
62
|
-
end
|
75
|
+
postprocess!(JSON.parse("[" + d.r_str + "]")[0], opts)
|
63
76
|
else raise RqlRuntimeError, "#{dt} Unimplemented."
|
64
77
|
end
|
65
78
|
end
|
@@ -121,7 +134,7 @@ module RethinkDB
|
|
121
134
|
@@datum_types = [Fixnum, Float, Bignum, String, Symbol,
|
122
135
|
TrueClass, FalseClass, NilClass]
|
123
136
|
|
124
|
-
def any_to_pb(x
|
137
|
+
def any_to_pb(x)
|
125
138
|
return x.to_pb if x.class == RQL
|
126
139
|
t = Term.new
|
127
140
|
t.type = Term::TermType::JSON
|
@@ -136,23 +149,23 @@ module RethinkDB
|
|
136
149
|
return (offset < 0 ? "-" : "+") + sprintf("%02d:%02d", raw_hours, raw_minutes);
|
137
150
|
end
|
138
151
|
|
139
|
-
def fast_expr(x,
|
152
|
+
def fast_expr(x, allow_json)
|
140
153
|
return x if x.class == RQL
|
141
154
|
if @@datum_types.include?(x.class)
|
142
155
|
return x if allow_json
|
143
|
-
return RQL.new(Shim.native_to_datum_term(x), nil
|
156
|
+
return RQL.new(Shim.native_to_datum_term(x), nil)
|
144
157
|
end
|
145
158
|
|
146
159
|
case x
|
147
160
|
when Array
|
148
|
-
args = x.map{|y| fast_expr(y,
|
161
|
+
args = x.map{|y| fast_expr(y, allow_json)}
|
149
162
|
return x if allow_json && args.all?{|y| y.class != RQL}
|
150
163
|
t = Term.new
|
151
164
|
t.type = Term::TermType::MAKE_ARRAY
|
152
|
-
t.args = args.map{|y| any_to_pb(y
|
153
|
-
return RQL.new(t, nil
|
165
|
+
t.args = args.map{|y| any_to_pb(y)}
|
166
|
+
return RQL.new(t, nil)
|
154
167
|
when Hash
|
155
|
-
kvs = x.map{|k,v| [k, fast_expr(v,
|
168
|
+
kvs = x.map{|k,v| [k, fast_expr(v, allow_json)]}
|
156
169
|
return x if allow_json && kvs.all? {|k,v|
|
157
170
|
(k.class == String || k.class == Symbol) && v.class != RQL
|
158
171
|
}
|
@@ -166,13 +179,13 @@ module RethinkDB
|
|
166
179
|
raise RqlDriverError, "Object keys must be strings or symbols." +
|
167
180
|
" (Got object `#{k.inspect}` of class `#{k.class}`.)"
|
168
181
|
end
|
169
|
-
ap.val = any_to_pb(v
|
182
|
+
ap.val = any_to_pb(v)
|
170
183
|
ap
|
171
184
|
}
|
172
|
-
return RQL.new(t, nil
|
185
|
+
return RQL.new(t, nil)
|
173
186
|
when Proc
|
174
|
-
t = RQL.new(nil, nil
|
175
|
-
return RQL.new(t, nil
|
187
|
+
t = RQL.new(nil, nil).new_func(&x).to_pb
|
188
|
+
return RQL.new(t, nil)
|
176
189
|
else raise RqlDriverError, "r.expr can't handle #{x.inspect} of type #{x.class}"
|
177
190
|
end
|
178
191
|
end
|
@@ -202,10 +215,9 @@ module RethinkDB
|
|
202
215
|
def expr(x, opts={})
|
203
216
|
allow_json = opts[:allow_json]
|
204
217
|
unbound_if @body
|
205
|
-
|
206
|
-
res = fast_expr(reql_typify(x), context, allow_json)
|
218
|
+
res = fast_expr(reql_typify(x), allow_json)
|
207
219
|
return res if res.class == RQL
|
208
|
-
return RQL.new(any_to_pb(res
|
220
|
+
return RQL.new(any_to_pb(res), nil)
|
209
221
|
end
|
210
222
|
|
211
223
|
def coerce(other)
|
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.
|
4
|
+
version: 1.12.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-
|
11
|
+
date: 2014-03-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -60,11 +60,11 @@ extra_rdoc_files: []
|
|
60
60
|
files:
|
61
61
|
- lib/exc.rb
|
62
62
|
- lib/ql2.pb.rb
|
63
|
-
- lib/net.rb
|
64
63
|
- lib/rethinkdb.rb
|
65
|
-
- lib/shim.rb
|
66
|
-
- lib/func.rb
|
67
64
|
- lib/rpp.rb
|
65
|
+
- lib/func.rb
|
66
|
+
- lib/net.rb
|
67
|
+
- lib/shim.rb
|
68
68
|
homepage: http://rethinkdb.com
|
69
69
|
licenses:
|
70
70
|
- Apache-2
|