diff options
author | Kim Alvefur <zash@zash.se> | 2013-07-12 17:44:30 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2013-07-12 17:44:30 +0200 |
commit | f7acbbc7831ab1cd8f2bcdf66d284fb47d3ff04e (patch) | |
tree | 10a42001c0d2bdb5bbb5ea42ed5fa259261e17b7 /util/sql.lua | |
parent | 051779d694221adc06600418becbdeda0f48d63e (diff) | |
download | prosody-f7acbbc7831ab1cd8f2bcdf66d284fb47d3ff04e.tar.gz prosody-f7acbbc7831ab1cd8f2bcdf66d284fb47d3ff04e.zip |
util.sql: Do lazy fetching of affected/rowcount
Diffstat (limited to 'util/sql.lua')
-rw-r--r-- | util/sql.lua | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/util/sql.lua b/util/sql.lua index 771df7aa..63c399ff 100644 --- a/util/sql.lua +++ b/util/sql.lua @@ -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; |