isage / lua-resty-moongoo

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

server_version causing error in newer Mongo versions. #8

Closed develephant closed 7 years ago

develephant commented 7 years ago

Hi,

Both version 2.6.10 and 3.4 throw:

bad argument #1 to 'gsub' (string expected, got nil)

Works fine when commenting out the offending lines. Seems related to #6

I tried poking around but was unable to create a fix.

-dev

isage commented 7 years ago

Does it help to call mg:connect() before issuing insert?

develephant commented 7 years ago

Hi,

Thank you for the reply, and also the module.

I'll give it a try the next time I have the project up and report back.

-dev

develephant commented 7 years ago

Hi,

I modified the collection.lua with:

...

self._db._moongoo:connect()

local server_version = tonumber(string.sub(string.gsub(self._db._moongoo.version, "(%D)", ""), 1, 3))

...

And that seems to work perfectly. 👍

-dev