Default value for BIT fields
Hello!
I have a mysql-dump with a table:
CREATE TABLE "map" (
"ID" int(10) unsigned NOT NULL AUTO_INCREMENT,
"f" int(11) NOT NULL,
"t" int(11) NOT NULL,
"direct" bit(1) NOT NULL DEFAULT b'1',
PRIMARY KEY ("ID"),
UNIQUE KEY "UQ_dict__t__t" ("f","t")
);
The problem is in the direct field. Current version of mysql2sqlite converts this table to the
CREATE TABLE "map" (
"ID" int(10) NOT NULL ,
"f" int(11) NOT NULL,
"t" int(11) NOT NULL,
"direct" bit(1) NOT NULL DEFAULT b'1',
PRIMARY KEY ("ID")
);
And such script is not valid SQL for sqlite:
$ cat x.sql | sqlite3 db.sqlite
Error: near line 1: near "'1'": syntax error
I have manually replaced "direct" bit(1) NOT NULL DEFAULT b'1', with "direct" bit(1) NOT NULL DEFAULT 1, and script works fine for me.
Could you fix mysql2sqlite, or add some instructions to create a valid mysqldump?
Good catch, thanks!
It's true, that sqlite doesn't support binary string literals like b'1'. I'll have time first in 3 weeks to write and test a routine converting a general string literal with zeros and ones to a valid integer.
If anyone requests a pull earlier, I'll check it earlier.
@dumblob, I am still not an awk expert, and it is sad :disappointed: .. I could just wait for a solution..