Skip to content

When query fails, some functions stop working #141

@Zvbhrf

Description

@Zvbhrf

Hello!

I've been using this library for a long time, but after rewriting my abstraction on it, I noticed some.. ?bugs? with some functions.

If your query, which is in transaction, fails with an error, then query:error() returns empty string, query:isRunning() stays true and query:hasMoreResults() throws an error.

I think it shouldn't be like that? Because when query fails, it should be marked as "not running" with correct error().

local db = database:GetDB() -- my own function, it returns mysqloo database object

local t = db:createTransaction()
local p = db:query("select * fom abc") -- query with syntax error
t:addQuery(p)

function t:onError(...)

	for _, q in ipairs(self:getQueries()) do
		print(q:error(), q:isRunning()) -- error() is empty, isRunning is true
		
		while q:hasMoreResults() do -- error goes here: Query not completed yet
			local queryData = databaseQuery:getData()
			print(queryData)
			
			databaseQuery:getNextResults()
		end
	end
end

t:start()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions