Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Ruby 1.8 compatibility and fix for index name clashes. #43

Merged
merged 1 commit into from

2 participants

Marc Worrell Max Lapshin
Marc Worrell

Replaced parse_csv with simple replace/split, for compatibility with Ruby 1.8

Added prefix to the index names, to make them unique.

Fixes issue #42

Marc Worrell mworrell Replaced parse_csv with simple replace/split, for compatibility with …
…Ruby 1.8.

Added prefix to the index names, to make them unique.
ead8f04
Max Lapshin maxlapshin merged commit a68b493 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 30, 2012
  1. Marc Worrell

    Replaced parse_csv with simple replace/split, for compatibility with …

    mworrell authored
    …Ruby 1.8.
    
    Added prefix to the index names, to make them unique.
This page is out of date. Refresh to see the latest.
Showing with 4 additions and 4 deletions.
  1. +4 −4 lib/mysql2psql/mysql_reader.rb
8 lib/mysql2psql/mysql_reader.rb
View
@@ -106,10 +106,10 @@ def load_indexes
next unless line =~ / KEY /
index = {}
if match_data = /CONSTRAINT `(\w+)` FOREIGN KEY \((.*?)\) REFERENCES `(\w+)` \((.*?)\)(.*)/.match(line)
- index[:name] = match_data[1]
- index[:column] = match_data[2].parse_csv(:quote_char => '`',:col_sep => ', ')
+ index[:name] = "fk_"+name+"_"+match_data[1]
+ index[:column] = match_data[2].gsub!('`','').split(', ')
index[:ref_table] = match_data[3]
- index[:ref_column] = match_data[4].parse_csv(:quote_char => '`',:col_sep => ', ')
+ index[:ref_column] = match_data[4].gsub!('`','').split(', ')
the_rest = match_data[5]
@@ -127,7 +127,7 @@ def load_indexes
@foreign_keys << index
elsif match_data = /KEY `(\w+)` \((.*)\)/.match(line)
- index[:name] = match_data[1]
+ index[:name] = "idx_"+name+"_"+match_data[1]
index[:columns] = match_data[2].split(",").map {|col| col[/`(\w+)`/, 1]}
index[:unique] = true if line =~ /UNIQUE/
@indexes << index
Something went wrong with that request. Please try again.