ejabberdsql2prosody: Fix typo, and improve the warning message
authorWaqas Hussain <waqas20@gmail.com>
Sun, 26 Jul 2009 13:12:32 +0000 (18:12 +0500)
committerWaqas Hussain <waqas20@gmail.com>
Sun, 26 Jul 2009 13:12:32 +0000 (18:12 +0500)
tools/ejabberdsql2prosody.lua

index 6ff8cf193edea41995150e16cc9d8235a27fd94d..ddbe3ee2638418733c27a57fc6880fbbbad66110 100644 (file)
@@ -178,14 +178,14 @@ local t = parseFile(arg);
 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