OPENBUS-3021 Correção no tipo da flag legacy em logins e observadores após adoção do SQLite3

 Mudança para inteiro foi introduzida no commit 1478ca36 da issue OPENBUS-2970 mas não alterou a biblioteca de acesso e os outros usos na implementação do Core. Resolvi voltar a usar booleanos e compatibilizar o fato do SQLite3 persistir como inteiros no momento de gravar e ler do banco.
parent a051e661
local _G = require "_G"
local print = _G.print
local pairs = _G.pairs
local pcall = _G.pcall
local select = _G.select
......@@ -125,11 +126,10 @@ function Login:newObserver(callback, legacy)
id = id,
login = login,
ior = ior,
legacy = legacy,
legacy = legacy or false,
}
local db = base.database
legacy = (legacy and 1) or 0
assert(db:pexec("addLoginObserver", id, ior, legacy, login))
assert(db:pexec("addLoginObserver", id, ior, (legacy and 1) or 0, login))
data.callback = callback
data.base = base
return Observer(data)
......@@ -172,26 +172,27 @@ function Database:__init()
self.publisher = Publisher(self.publisher)
local db = self.database
for entry in db.pstmts.getLogin:nrows() do
entry.base = self
entry.base = self
entry.allowLegacyDelegate = (entry.allowLegacyDelegate == 1)
Login(entry)
end
for entry in db.pstmts.getLoginObserver:nrows() do
entry.base = self
entry.legacy = (entry.legacy == 1)
Observer(entry)
end
end
function Database:newLogin(entity, encodedkey, allowLegacyDelegate)
local id = newid("time")
allowLegacyDelegate = (allowLegacyDelegate and 1) or 0
local data = {
id = id,
entity = entity,
encodedkey = encodedkey,
allowLegacyDelegate = allowLegacyDelegate
allowLegacyDelegate = allowLegacyDelegate or false
}
assert(self.database:pexec("addLogin", id, entity, encodedkey,
allowLegacyDelegate))
(allowLegacyDelegate and 1) or 0))
data.base = self
return Login(data)
end
......
......@@ -74,9 +74,9 @@ do
-- check login
local entity = login.entity
if entity == "delegator" then
assert(login.allowLegacyDelegate == 1, "wrong stored login")
assert(login.allowLegacyDelegate == true, "wrong stored login")
else
assert(login.allowLegacyDelegate == 0, "wrong stored login")
assert(login.allowLegacyDelegate == false, "wrong stored login")
end
-- check observers owned by this login
local observers = assert(Data[login.entity], "unknown stored login")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment