tools/ejabberdsql2prosody: Handle INSERT statement form where column list is specified (by skipping the column list).
authorWaqas Hussain <waqas20@gmail.com>
Sun, 05 Feb 2012 00:10:13 +0500
changeset 4496 11983a1e92c0
parent 4495 c0f5c78cb817
child 4500 bfa387f268e2
tools/ejabberdsql2prosody: Handle INSERT statement form where column list is specified (by skipping the column list).
tools/ejabberdsql2prosody.lua
--- a/tools/ejabberdsql2prosody.lua	Sun Feb 05 00:06:20 2012 +0500
+++ b/tools/ejabberdsql2prosody.lua	Sun Feb 05 00:10:13 2012 +0500
@@ -129,7 +129,12 @@
 		end
 	end
 	local tname = readTableName();
-	for ch in ("` VALUES "):gmatch(".") do read(ch); end -- expect this
+	read("`"); read(" ") -- expect this
+	if peek() == "(" then -- skip column list
+		repeat until read() == ")";
+		read(" ");
+	end
+	for ch in ("VALUES "):gmatch(".") do read(ch); end -- expect this
 	local tuples = readTuples();
 	read(";"); read("\n");
 	return tname, tuples;