isage / lua-resty-moongoo

MongoDB library for OpenResty
Do What The F*ck You Want To Public License
118 stars 33 forks source link

attempt to call field 'uint' (a nil value) #20

Closed donghuichun closed 5 years ago

donghuichun commented 6 years ago

/resty/moongoo/utils.lua:19: attempt to call field 'uint' (a nil value) stack traceback: coroutine 0: /Users/dong/develop/lua/ldas/resty/moongoo/utils.lua: in function 'uint_to_hex' /Users/dong/develop/lua/ldas/resty/moongoo/utils.lua:40: in function 'generate_oid' /Users/dong/develop/lua/ldas/resty/moongoo/collection.lua:67: in function 'ensure_oids' /Users/dong/develop/lua/ldas/resty/moongoo/collection.lua:96: in function 'insert'

local function uint_to_hex(num, len, be) local len = len or 4 local be = be or 0 **local num = cbson.uint(num)** local raw = cbson.uint_to_raw(num, len, be) local out = '' for i = 1, #raw do out = out .. string.format("%02x", raw:byte(i,i)) end return out end

how to solve?

isage commented 6 years ago

Looks like you using wrong version of lua-cbson.

1) format your message properly, with code tags 2) be sure to use latest non-modified versions of lua-cbson and lua-resty-moongoo 3) provide minimal test code