mirror of
https://github.com/dimitri/pgloader.git
synced 2026-05-04 18:36:12 +02:00
Fix MySQL bit(1) casting function.
When this function was written, pgloader would get an array of numbers over the wire, nowadays it looks like it's receiving an array of characters instead (in other words, a string). Improve the `bits-to-boolean` function to accept either input, and raise an error in another case. My theory is that something changed either in MySQL (with version 10) or in the Qmynd driver somehow... but tonight we just go easy and fix the bug locally rather than try and understand where it might be coming from. Fixes #684.
This commit is contained in:
parent
c05183fcba
commit
b7d87a9eb1
@ -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
|
||||
|
||||
11
test/mysql/my.sql
vendored
11
test/mysql/my.sql
vendored
@ -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,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user