From: James Nobis Date: Wed, 16 Dec 2009 20:40:21 +0000 (+0800) Subject: add mysql escape characters for selecting from tables with names containing X-Git-Url: http://git.neszt.hu/?a=commitdiff_plain;h=b94ec3aed932d3d015a82cbf60015ccafcd2eb4f;p=mysql2postgres add mysql escape characters for selecting from tables with names containing items like - add postgresql escape characters for adding constraints with said table names --- diff --git a/mysql2psql b/mysql2psql index 4eb9aad..029790e 100755 --- a/mysql2psql +++ b/mysql2psql @@ -124,7 +124,7 @@ class MysqlReader def count_for_pager query = has_id? ? 'MAX(id)' : 'COUNT(*)' - @reader.mysql.query("SELECT #{query} FROM #{name}") do |res| + @reader.mysql.query("SELECT #{query} FROM `#{name}`") do |res| return res.fetch_row[0].to_i end end @@ -454,7 +454,7 @@ class PostgresDbWriter < PostgresWriter def write_indexes(table) if primary_index = table.indexes.find {|index| index[:primary]} - @conn.exec("ALTER TABLE #{PGconn.quote_ident(table.name)} ADD CONSTRAINT #{table.name}_pkey PRIMARY KEY(#{primary_index[:columns].map {|col| PGconn.quote_ident(col)}.join(", ")})") + @conn.exec("ALTER TABLE #{PGconn.quote_ident(table.name)} ADD CONSTRAINT \"#{table.name}_pkey\" PRIMARY KEY(#{primary_index[:columns].map {|col| PGconn.quote_ident(col)}.join(", ")})") end table.indexes.each do |index|