mysql2sqlite icon indicating copy to clipboard operation
mysql2sqlite copied to clipboard

Hex numbers inside strings are trimmed

Open Hakkin opened this issue 6 years ago • 4 comments

If you have a string that has a long hex number in it, the script will trim it to be 16 characters.

Example: INSERT INTO `test` VALUES(1,2,'0x00000000000000003');

will result in the warning 1: WARN Hex number trimmed (length longer than 16 chars). and the output SQL will be INSERT INTO `test` VALUES(1,2,'0x0000000000000000');

Hakkin avatar Mar 27 '19 15:03 Hakkin

That's a deliberate check in the conversion script - see the source code:

  # sqlite3 is limited to 16 significant digits of precision

Maybe there are some Sqlite3 versions out there which support more digits, but I don't know about them. Feel free to remove the check or increase the number, convert your DB and try to load it into Sqlite3 and if OK, then check all the numbers whether they were correctly imported.

dumblob avatar Mar 29 '19 20:03 dumblob

The problem isn't trimming the number, that is correct, but it's trimming the number inside strings.

0x00000000000000003 is the number 3, '0x00000000000000003' is a string containing 0x00000000000000003

Hakkin avatar Mar 30 '19 02:03 Hakkin

I think it should also probably be smarter about how it trims numbers, sqlite handles the hex literal 0x00000000000000003 completely fine, since it's actually only 1 digit long, the script should probably trim any leading 0s before calculating the length.

Hakkin avatar Mar 30 '19 02:03 Hakkin

This issue is linked to #69

vdechef avatar Mar 22 '20 20:03 vdechef