Be smarter about MS SQL bit to boolean conversion, should fix #162.

This is a blind patch given that I couldn't CREATE TABLE as per the bug
report to try and see by myself what's happening. Better have some tests
going on though.
This commit is contained in:
Dimitri Fontaine 2015-02-03 13:39:09 +01:00
parent 100e942c22
commit 7ccbb45763
2 changed files with 16 additions and 2 deletions

View File

@ -11,7 +11,8 @@
(:source (:type "nvarchar") :target (:type "text" :drop-typemod t))
(:source (:type "xml") :target (:type "text" :drop-typemod t))
(:source (:type "bit") :target (:type "boolean"))
(:source (:type "bit") :target (:type "boolean")
:using pgloader.transforms::sql-server-bit-to-boolean)
(:source (:type "uniqueidentifier") :target (:type "uuid")
:using pgloader.transforms::sql-server-uniqueidentifier-to-uuid)

View File

@ -22,7 +22,8 @@
right-trim
byte-vector-to-bytea
sqlite-timestamp-to-timestamp
sql-server-uniqueidentifier-to-uuid))
sql-server-uniqueidentifier-to-uuid
sql-server-bit-to-boolean))
;;;
@ -252,3 +253,15 @@
(format nil
"~d-~2,'0d-~2,'0d ~2,'0d:~2,'0d:~2,'0dZ"
year month date hour minute second)))))
(defun sql-server-bit-to-boolean (bit-string-or-integer)
"We might receive bits as '((0))'"
(typecase bit-string-or-integer
(integer (if (= 0 bit-string-or-integer) "f" "t"))
(string
(cond ((string= "0" bit-string-or-integer) "f")
((string= "1" bit-string-or-integer) "t")
((string= "((0))" bit-string-or-integer) "f")
((string= "((1))" bit-string-or-integer) "t")
(t nil)))))