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 | 1398e3d4f3728b9d19acde9b0f8bd123964bea82 (patch) | |
tree | 10a42001c0d2bdb5bbb5ea42ed5fa259261e17b7 | |
parent | afbae0fd76e9dfde06a1834dcc22f8c93de3c4d4 (diff) | |
download | prosody-1398e3d4f3728b9d19acde9b0f8bd123964bea82.tar.gz prosody-1398e3d4f3728b9d19acde9b0f8bd123964bea82.zip |
util.sql: Do lazy fetching of affected/rowcount
-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; |