Transform dates with just day of month set to "00" to NIL.

This commit is contained in:
Dimitri Fontaine 2013-11-13 21:45:11 +01:00
parent 2a65a1d39f
commit a41ce12023

View File

@ -27,10 +27,14 @@
(find-package "PGLOADER.TRANSFORMS")))
(defun zero-dates-to-null (date-string)
"MySQL accepts '0000-00-00' as a date, we want :null instead."
"MySQL accepts '0000-00-00' as a date, we want NIL (SQL NULL) instead."
(cond
((null date-string) nil)
((string= date-string "") nil)
;; day is 00
((string= date-string "0000-00-00" :start1 8 :start2 8 ) nil)
;; month is 00
((string= date-string "0000-00-00" :start1 5 :end1 7 :start2 5 :end2 7) nil)
((string= date-string "0000-00-00") nil)
((string= date-string "0000-00-00 00:00:00") nil)
(t date-string)))