ejabberdsql2prosody: Display a warning if a row has more columns than expected

Sun, 26 Jul 2009 18:05:05 +0500

author
Waqas Hussain <waqas20@gmail.com>
date
Sun, 26 Jul 2009 18:05:05 +0500
changeset 1600
cd9790f42269
parent 1599
308986a3e66a
child 1601
a3ffc27b6207

ejabberdsql2prosody: Display a warning if a row has more columns than expected

tools/ejabberdsql2prosody.lua file | annotate | diff | comparison | revisions
--- a/tools/ejabberdsql2prosody.lua	Sun Jul 26 17:51:36 2009 +0500
+++ b/tools/ejabberdsql2prosody.lua	Sun Jul 26 18:05:05 2009 +0500
@@ -181,8 +181,11 @@
 		for i=1,#data do
 			local row = data[i];
 			for j=1,#row do
-				row[m[j]] = row[j];
-				row[j] = nil;
+				local n = m[j];
+				if n then
+					row[n] = row[j];
+					row[j] = nil;
+				else print("[warning] expected "..#n.." columns for table `"..name.."`, found "..#row); break; end
 			end
 		end
 	end

mercurial