Software /
code /
prosody
Comparison
tools/migration/migrator/prosody_sql.lua @ 4247:6a372135b4c4
tools/migration/migrator/prosody_sql.lua: Fix compatibility with PostgreSQL (thanks Timo)
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Mon, 11 Apr 2011 17:01:06 +0100 |
parent | 4234:ce92aafc9c03 |
child | 4294:d2406f0ce8a5 |
comparison
equal
deleted
inserted
replaced
4244:19c9bf88ec89 | 4247:6a372135b4c4 |
---|---|
147 create_table(dbh, output); | 147 create_table(dbh, output); |
148 local stmt = assert(dbh:prepare("SELECT * FROM prosody")); | 148 local stmt = assert(dbh:prepare("SELECT * FROM prosody")); |
149 assert(stmt:execute()); | 149 assert(stmt:execute()); |
150 local stmt = assert(dbh:prepare("DELETE FROM prosody")); | 150 local stmt = assert(dbh:prepare("DELETE FROM prosody")); |
151 assert(stmt:execute()); | 151 assert(stmt:execute()); |
152 local insert = assert(dbh:prepare("INSERT INTO `prosody` (`host`,`user`,`store`,`key`,`type`,`value`) VALUES (?,?,?,?,?,?)")); | 152 local insert_sql = "INSERT INTO `prosody` (`host`,`user`,`store`,`key`,`type`,`value`) VALUES (?,?,?,?,?,?)"; |
153 if output.driver == "PostgreSQL" then | |
154 insert_sql = insert_sql:gsub("`", "\""); | |
155 end | |
156 local insert = assert(dbh:prepare(insert_sql)); | |
153 | 157 |
154 return function(item) | 158 return function(item) |
155 if not item then assert(dbh:commit()) return dbh:close(); end -- end of input | 159 if not item then assert(dbh:commit()) return dbh:close(); end -- end of input |
156 local host = item.host or ""; | 160 local host = item.host or ""; |
157 local user = item.user or ""; | 161 local user = item.user or ""; |