Skip to content

Commit

Permalink
fix(lib): incorrect safeArgs for Sync.transaction (callback)
Browse files Browse the repository at this point in the history
Additionally no longer sending Resource argument since oxmysql can handle that already.
  • Loading branch information
thelindat authored Nov 11, 2021
1 parent 12e9ccb commit 647243f
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions lua/lib/MySQL.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
-- Store is used for compatibility only

local Ox = exports.oxmysql
local Resource = GetCurrentResourceName()
local Store = {}

local function safeArgs(query, parameters, cb, transaction)
Expand Down Expand Up @@ -99,7 +98,7 @@ MySQL.Sync.execute = function(query, parameters)
local promise = promise.new()
Ox:update(query, parameters, function(result)
promise:resolve(result)
end, Resource)
end)
return Citizen.Await(promise)
end

Expand All @@ -112,7 +111,7 @@ MySQL.Sync.fetchAll = function(query, parameters)
local promise = promise.new()
Ox:execute(query, parameters, function(result)
promise:resolve(result)
end, Resource)
end)
return Citizen.Await(promise)
end

Expand All @@ -125,7 +124,7 @@ MySQL.Sync.fetchScalar = function(query, parameters)
local promise = promise.new()
Ox:scalar(query, parameters, function(result)
promise:resolve(result)
end, Resource)
end)
return Citizen.Await(promise)
end

Expand All @@ -138,7 +137,7 @@ MySQL.Sync.fetchSingle = function(query, parameters)
local promise = promise.new()
Ox:single(query, parameters, function(result)
promise:resolve(result)
end, Resource)
end)
return Citizen.Await(promise)
end

Expand All @@ -151,7 +150,7 @@ MySQL.Sync.insert = function(query, parameters)
local promise = promise.new()
Ox:insert(query, parameters, function(result)
promise:resolve(result)
end, Resource)
end)
return Citizen.Await(promise)
end

Expand All @@ -160,11 +159,11 @@ end
---@return boolean result
---returns true when the transaction has succeeded
MySQL.Sync.transaction = function(queries, parameters)
queries, parameters = safeArgs(queries, parameters, true)
queries, parameters = safeArgs(queries, parameters, false, true)
local promise = promise.new()
Ox:transaction(queries, parameters, function(result)
promise:resolve(result)
end, Resource)
end)
return Citizen.Await(promise)
end

Expand All @@ -185,4 +184,4 @@ MySQL.ready = function(cb)
until GetResourceState('oxmysql') == 'started'
cb()
end)
end
end

0 comments on commit 647243f

Please sign in to comment.