Closed aleclarson closed 7 years ago
Another symptom:
r.do(r.args([ r.expr(1), r.expr(2) ])).run()
...throws this error:
ReqlDriverError: `do` takes at least 1 argument, 0 provided
Hum, yea it's a bit weird to write r.do(1)
but it's definitively different than the official driver.
Released in 2.3.31
Also note that r.do(r.args([1,2]))
returns 1
and not 2
, so I would probably not use r.do
and r.args
together.
Yeah those are just repros. 😄
Why the different behavior for r.do
with r.args
?
This is the annoying part of r.do
.
r.do(1, 2, func)
is sent as "do(func, 1, 2)". So when you write r.do(r.args([1,2,func])
, we send "do(args(1,2,func))", which becomes do(1, 2, func) instead of do(func, 1, 2)
Why not check r.args
for:
typeof arguments[arguments.length - 1] === 'function'
and move the function to the front if true?
Perhaps a special case inside r.do
is necessary?
I don't think that's needed, the purpose of r.args is to make using a variadic method easier.
r.do(r.args([value1, value2]), function(args) { ... })) is probably what you'll write. I don't see a good reason why you would store the function with value1, value2 etc.
I see, good point! 👍
These queries...
...throw this error:
Even though
r.do
can be passed a single query or an array of queries (without a function argument).