We found the solution!
If you don't care how to do it and just want the solution, here you go:
https://github.com/iViscosity/AnotherULXSBanModuleTurns out the return type for the implementation of pmysql is very convoluted (the query returns a table of tables of tables:
result = {
1:
{
data = {
1:
{
field_name = field_value
}
}
}
}
so to access field_name you need to call:
result[1].data[1].field_name
Once I figured that out, it was relatively simple to track down how everything was being called. The first error, shown in the pastebin in OP's post, was solved by replacing
#SBAN_SQL_Query(query, qTab) > 0
on line 308 with:
SBAN_SQL_Query(query, qTab) ~= nil
while also replacing the return type of SBAN_SQL_Query(sql, qTab) from:
return function(sql)
local results = database_sban:query_sync(sql)
return results[1].data
end
on lines 154-157 with:
return function(sql)
local results = database_sban:query_sync(sql)
return results[1]
end
because the return type of query_sync will ALWAYS be a table, but it MAY be an empty table.
I also removed the function
local function SBAN_SQL_Query_Callback(results, qTab)
qTab.cb(results, qTab)
end
because I could simply call SBAN_SQL_Query like:
SBAN_SQL_Query(sql, qTab.cb, qTab)