ejabberdsql2prosody: Fix typo, and improve the warning message

Sun, 26 Jul 2009 18:12:32 +0500

author
Waqas Hussain <waqas20@gmail.com>
date
Sun, 26 Jul 2009 18:12:32 +0500
changeset 1601
a3ffc27b6207
parent 1600
cd9790f42269
child 1602
1056369a29df

ejabberdsql2prosody: Fix typo, and improve the warning message

tools/ejabberdsql2prosody.lua file | annotate | diff | comparison | revisions
--- a/tools/ejabberdsql2prosody.lua	Sun Jul 26 18:05:05 2009 +0500
+++ b/tools/ejabberdsql2prosody.lua	Sun Jul 26 18:12:32 2009 +0500
@@ -178,14 +178,14 @@
 for name, data in pairs(t) do
 	local m = map[name];
 	if m then
+		if #data > 0 and #data[1] ~= #m then
+			print("[warning] expected "..#m.." columns for table `"..name.."`, found "..#data[1]);
+		end
 		for i=1,#data do
 			local row = data[i];
-			for j=1,#row do
-				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
+			for j=1,#m do
+				row[m[j]] = row[j];
+				row[j] = nil;
 			end
 		end
 	end

mercurial