FredyH / MySQLOO

MySQLOO
GNU Lesser General Public License v2.1
138 stars 55 forks source link

Query callbacks not working. #80

Closed na-stewart closed 3 years ago

na-stewart commented 3 years ago

I've been trying to get query callbacks working and none of them have for success or failure. This happens while selecting, updating, or inserting. This is a addon breaking problem that I'd love to get to the bottom of ASAP. Thank you! :)

function test()
    local q = sunsetsync.mysql:query("SELECT 1, 2, 3") -- In mysqloo 9 a query can be started before the database is connected
    function q:onSuccess(data)
        local row = data[1]
        for k,v in pairs(row) do
            print(v) -- should print 1, 2, 3
        end
    end
end

I want to make clear, all querys have been working. However, I have been unable to receive data from them.

FredyH commented 3 years ago

You have to start the query using q:start()

na-stewart commented 3 years ago

You have to start the query using q:start()

Even with start it doesn't work. I forgot to put it in the issue code by mistake.

Here is a revised test method below.

function sunsetsync.test()
    print('test query being executed.')
    local query = sunsetsync.mysql:query("SELECT 1, 2, 3") -- In mysqloo 9 a query can be started before the database is connected
    function query:onSuccess(data)
        print('query executed successfully')
    end
    query:start()
end

On Success is still not executed.

na-stewart commented 3 years ago

Would using MySQL 8.0.20 cause this issue? and if so what version should I use instead.

FredyH commented 3 years ago

That should not cause an issue, but try using the latest beta version. Are you sure that you successfully connected to the database?

na-stewart commented 3 years ago

That should not cause an issue, but try using the latest beta version. Are you sure that you successfully connected to the database?

I am positive as the query's go through successfully (such as inserting and creating tables), but the callbacks are never called.

na-stewart commented 3 years ago

I'll give using the beta version a try.

na-stewart commented 3 years ago

Using the beta 64 bit linux version of MySQLOO does not get imported and throws an error in my addon. I'm gonna try decreasing the MySQL version from 8 to 5.

na-stewart commented 3 years ago

After testing on MySQL version 5, query callbacks are still not functional.

FredyH commented 3 years ago

The callbacks are only called if there's a player on the server (as they rely on the think hook). So that is also something to keep in mind.

na-stewart commented 3 years ago

The callbacks are only called if there's a player on the server (as they rely on the think hook). So that is also something to keep in mind.

Yeah, that did it. Thanks.