我目前正在为Luvit编写一个驱动程序,这是一个与当前Lua-ReQL驱动程序不兼容的Lua库。我该如何解决这个问题呢? 有问题的数据,如JSON,
{"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":[]}
序列化数据
[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":[]}]],{}]
来自服务器的数据是:
Expected between 1 and 3 elements in a raw term, but found 0.
答案 0 :(得分:0)
问题是其中一个数组为空。你从中构建的实际查询是什么?是r.db('test').table('table').update(<your document>)
吗?
我正在查看源文件term_walker.cc
。看起来传递给UPDATE的对象(整个对象{"Ignore"...}
)将被包装到[MAKE_OBJ, {"Ignore"...}]
中(因为AST被处理,代码行为rewrite(src, Term::MAKE_OBJ);
)
然后对象{"Ignore"...}
的处理方式与optargs参数的处理方式相同 - 它们的值字段在它们上面调用walk
。
看起来裸对象的处理方式与它们已经用[3, <object>]
包裹一样(因为MAKE_OBJ = 3)。当用户编写表达式{"abc": r.add(1, 2)}
时,该表达式应该是MAKE_OBJ表达式,并且子表达式需要由客户端库转换为适当的ReQL-ese。我的猜测是你的客户端库没有遍历对象并进行这种转换。你需要这样做,这样裸阵列就会变成他们变成的东西(一个MAKE_ARRAY术语?)。如果您希望您的客户传递一个根本没有被遍历和处理的对象,您应该使用DATUM
,我猜。
把我在这里说的所有内容都作为指导,只有90%的确定性。