Changeset

5744:253dfea0e3f6

util.sql: Do lazy fetching of affected/rowcount
author Kim Alvefur <zash@zash.se>
date Fri, 12 Jul 2013 17:44:30 +0200 (2013-07-12)
parents 5743:8363dda76155
children 5746:3137751751b4
files util/sql.lua
diffstat 1 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/util/sql.lua	Fri Jul 12 17:41:54 2013 +0200
+++ b/util/sql.lua	Fri Jul 12 17:44:30 2013 +0200
@@ -177,8 +177,8 @@
 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 @@
 		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;