mirror of
https://github.com/dimitri/pgloader.git
synced 2026-05-05 10:56:10 +02:00
Fix DBF handling of "empty" date strings.
Blind code a fix for an error when parsing empty date strings in a DBF file. The small amount of information is surprising, I can't quite figure out which input string can produce " - - " with the previous coding of db3-date-to-pgsql-date. Anyway, it seems easy enough to add some checks to a very optimistic function and return nil when our checks aren't met. Fixes #589, hopefully.
This commit is contained in:
parent
1e436555a8
commit
fc01c7acc9
@ -78,8 +78,10 @@
|
||||
|
||||
(defun db3-date-to-pgsql-date (value)
|
||||
"Convert a DB3 date to a PostgreSQL date."
|
||||
(let ((year (subseq value 0 4))
|
||||
(month (subseq value 4 6))
|
||||
(day (subseq value 6 8)))
|
||||
(format nil "~a-~a-~a" year month day)))
|
||||
(when (and value (string/= "" value) (= 8 (length value)))
|
||||
(let ((year (parse-integer (subseq value 0 4) :junk-allowed t))
|
||||
(month (parse-integer (subseq value 4 6) :junk-allowed t))
|
||||
(day (parse-integer (subseq value 6 8) :junk-allowed t)))
|
||||
(when (and year month day)
|
||||
(format nil "~4,'0d-~2,'0d-~2,'0d" year month day)))))
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user