0

I am currently writing a driver for Luvit, a Lua library which is incompatible with the current Lua-ReQL driver. How would I go about this problem?
The data in question, as JSON is,

{"Settings":{"bet":"b!","admin_roles":[],"co_owner_roles":[],"voting_chan":"default---channel","mod_log":"true","log_channel":"default---channel","voting":"false","verify":"true","audit_log":"true","audit_log_chan":"audit-log-test","mod_log_chan":"modlog","banned_phrases":[],"mod_roles":[],"verify_chan":"default---channel","mod_log_channel":"default---channel","verify_role":"Member"},"Roles":[],"Cases":[],"Votes":[],"Timers":[],"id":"284381751084843008","Ignore":[]}

The serialized data is

[1,[53, [[15, [[14, ["test"]], "table"]], {"Ignore":[],"id":"284381751084843008","Cases":[],"Roles":[],"Timers":[],"Settings":{"bet":"b!","admin_roles":[],"co_owner_roles":[],"voting_chan":"default---channel","mod_log":"true","log_channel":"default---channel","voting":"false","verify":"true","audit_log":"true","audit_log_chan":"audit-log-test","mod_log_chan":"modlog","banned_phrases":[],"mod_roles":[],"verify_chan":"default---channel","mod_log_channel":"default---channel","verify_role":"Member"},"Votes":[]}]],{}]  

The data from the server is:

Expected between 1 and 3 elements in a raw term, but found 0.
DannehSC
  • 21
  • 1

1 Answers1

0

The problem is one of the arrays being empty. What is the actual query you're building this from? Is it r.db('test').table('table').update(<your document>)?

I'm looking at the source file term_walker.cc. It looks like the object passed to UPDATE (the entire object {"Ignore"...}) will get wrapped into [MAKE_OBJ, {"Ignore"...}] (as the AST gets processed, with the line of code rewrite(src, Term::MAKE_OBJ);) and then the object {"Ignore"...} will get processed the same way optargs parameters do -- their value fields get walk called on them.

It looks like bare objects get treated the same as if they were already wrapped with [3, <object>] (because MAKE_OBJ = 3). When a user writes the expression {"abc": r.add(1, 2)}, that's supposed to be a MAKE_OBJ expression and the sub-expression needs to get converted by the client library into the appropriate ReQL-ese. My guess is your client library isn't traversing objects and doing this conversion. You need to do that, so that the bare arrays would get turned into whatever they get turned into (a MAKE_ARRAY term?). If you want your client to pass an object that doesn't get traversed and processed at all, you should use DATUM, I'd guess.

Take everything I said here as guidelines with only 90% certainty.

Sam Hughes
  • 89
  • 2