diff --git a/src/utils/transforms.lisp b/src/utils/transforms.lisp index dff12d1..7dfa473 100644 --- a/src/utils/transforms.lisp +++ b/src/utils/transforms.lisp @@ -145,7 +145,13 @@ "When using MySQL, strange things will happen, like encoding booleans into bit(1). Of course PostgreSQL wants 'f' and 't'." (when (and bit-vector (= 1 (length bit-vector))) - (if (= 0 (aref bit-vector 0)) "f" "t"))) + (let ((bit (aref bit-vector 0))) + ;; we might have either a char or a number here, see issue #684. + ;; current guess when writing the code is that it depends on MySQL + ;; version, but this has not been checked. + (etypecase bit + (fixnum (if (= 0 bit) "f" "t")) + (character (if (= 0 (char-code bit)) "f" "t")))))) (defun int-to-ip (int) "Transform an IP as integer into its dotted notation, optimised code from diff --git a/test/mysql/my.sql b/test/mysql/my.sql index ab12fc3..44234f1 100644 --- a/test/mysql/my.sql +++ b/test/mysql/my.sql @@ -89,6 +89,17 @@ CREATE TABLE pgloader_test_unsigned ); INSERT INTO pgloader_test_unsigned(id) VALUES (65535); +/* + * https://github.com/dimitri/pgloader/issues/684 + */ +create table bits + ( + id integer not null AUTO_INCREMENT primary key, + bool bit(1) + ); + +insert into bits(bool) values(0b00), (0b01); + CREATE TABLE `fcm_batches` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `raw_payload` mediumtext COLLATE utf8_unicode_ci,