mysql2sqlite icon indicating copy to clipboard operation
mysql2sqlite copied to clipboard

ENUM pattern also fits e.g. 'voyagenumber'

Open MarcelRoelofs opened this issue 6 years ago • 4 comments

Not an expert in awk, but I guess a lot of the patterns should be made to do only a word-only comparison, otherwise examples as in the issue title will result in faulty SQL statements.

Otherwise great and very useful script!!

MarcelRoelofs avatar Mar 11 '19 22:03 MarcelRoelofs

What do you mean by "word-only" comparison? Could you please demonstrate in on a piece of mysql dump?

Currently it's a known fact, that any gsub() destroys data (there are many different gsub() calls in the script), but if we changed it (e.g. to more sophisticated pattern like do{ sub(/^a/, ...); sub(/^b/, ...); sub(/^c/, ...); ...; } while(at_least_one_sub()_matched)), we would require a really good testing data as the change would introduce other subtle mistakes.

dumblob avatar Mar 12 '19 18:03 dumblob

Sure, the following line:

CONSTRAINT `data_epositionvoyagenumber_7510_ibfk_1` FOREIGN KEY (`revid`) REFERENCES `rev` (`id`)

got converted to

CONSTRAINT `data_epositionvoyagtext REFERENCES `rev` (`id`)

I provisionally 'fixed' that by changing in the mysql2sqlite script the line

gsub( /(ENUM|enum)[^)]+\)/, "text " )

to

gsub( / (ENUM|enum)[^)]+\)/, " text " )

which worked for the particular SQL file I wanted to convert, but I would expect that there are better ways to accomplish the same, and the same problem may occur with the other substitutions as well.

MarcelRoelofs avatar Mar 13 '19 18:03 MarcelRoelofs

Ok, now I understand what you meant by word comparison. Well, it might sound rude from me, but I won't have time for rewriting the script to safer parsing (e.g. using do{}while() as noted above). I'll though welcome someone doing that (including proper testing to avoid making the current fragile substitutions even more prone).

In that light I believe we can close this issue as it won't get fixed until a bigger rewrite and testing :(

dumblob avatar Mar 13 '19 19:03 dumblob

I will try to address this in #71 because I will have to change the way BIT are parsed. So it would be the right time to improve other types parsing.

vdechef avatar Mar 23 '20 14:03 vdechef