mirror of
https://github.com/bjc/prosody.git
synced 2025-04-04 21:57:45 +03:00
util.sql: Do lazy fetching of affected/rowcount
This commit is contained in:
parent
051779d694
commit
f7acbbc783
1 changed files with 3 additions and 3 deletions
|
@ -177,8 +177,8 @@ function engine:execute(sql, ...)
|
|||
end
|
||||
|
||||
local result_mt = { __index = {
|
||||
affected = function(self) return self.__affected; end;
|
||||
rowcount = function(self) return self.__rowcount; end;
|
||||
affected = function(self) return self.__stmt:affected(); end;
|
||||
rowcount = function(self) return self.__stmt:rowcount(); end;
|
||||
} };
|
||||
|
||||
function engine:execute_query(sql, ...)
|
||||
|
@ -200,7 +200,7 @@ function engine:execute_update(sql, ...)
|
|||
prepared[sql] = stmt;
|
||||
end
|
||||
assert(stmt:execute(...));
|
||||
return setmetatable({ __affected = stmt:affected(), __rowcount = stmt:rowcount() }, result_mt);
|
||||
return setmetatable({ __stmt = stmt }, result_mt);
|
||||
end
|
||||
engine.insert = engine.execute_update;
|
||||
engine.select = engine.execute_query;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue