Changeset

1601:a3ffc27b6207

ejabberdsql2prosody: Fix typo, and improve the warning message
author Waqas Hussain <waqas20@gmail.com>
date Sun, 26 Jul 2009 18:12:32 +0500
parents 1600:cd9790f42269
children 1602:1056369a29df
files tools/ejabberdsql2prosody.lua
diffstat 1 files changed, 6 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- 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