Software /
code /
prosody
Comparison
tools/ejabberdsql2prosody.lua @ 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 |
parent | 1600:cd9790f42269 |
child | 1602:1056369a29df |
comparison
equal
deleted
inserted
replaced
1600:cd9790f42269 | 1601:a3ffc27b6207 |
---|---|
176 local NULL = {}; | 176 local NULL = {}; |
177 local t = parseFile(arg); | 177 local t = parseFile(arg); |
178 for name, data in pairs(t) do | 178 for name, data in pairs(t) do |
179 local m = map[name]; | 179 local m = map[name]; |
180 if m then | 180 if m then |
181 if #data > 0 and #data[1] ~= #m then | |
182 print("[warning] expected "..#m.." columns for table `"..name.."`, found "..#data[1]); | |
183 end | |
181 for i=1,#data do | 184 for i=1,#data do |
182 local row = data[i]; | 185 local row = data[i]; |
183 for j=1,#row do | 186 for j=1,#m do |
184 local n = m[j]; | 187 row[m[j]] = row[j]; |
185 if n then | 188 row[j] = nil; |
186 row[n] = row[j]; | |
187 row[j] = nil; | |
188 else print("[warning] expected "..#n.." columns for table `"..name.."`, found "..#row); break; end | |
189 end | 189 end |
190 end | 190 end |
191 end | 191 end |
192 end | 192 end |
193 --print(serialize(t)); | 193 --print(serialize(t)); |