mirror of
https://github.com/dimitri/pgloader.git
synced 2026-05-05 10:56:10 +02:00
Check empty strings in DB3 numeric fields.
Another blind attempt at fixing pgloader from a bug report on gitter, see
This commit is contained in:
parent
652e435843
commit
f6cb428c6d
@ -54,15 +54,17 @@
|
||||
|
||||
(defmethod cast ((field db3-field))
|
||||
"Return the PostgreSQL type definition given the DB3 one."
|
||||
(let ((type (db3-field-type field)))
|
||||
(let* ((type (db3-field-type field))
|
||||
(transform
|
||||
(cond ((string= type "C") #'db3-trim-string)
|
||||
((string= type "N") #'db3-numeric-to-pgsql-numeric)
|
||||
((string= type "L") #'logical-to-boolean)
|
||||
((string= type "D") #'db3-date-to-pgsql-date)
|
||||
(t nil))))
|
||||
(make-column :name (apply-identifier-case (db3-field-name field))
|
||||
:type-name (cdr (assoc type
|
||||
*db3-pgsql-type-mapping*
|
||||
:type-name (cdr (assoc type *db3-pgsql-type-mapping*
|
||||
:test #'string=))
|
||||
:transform (cond ((string= type "L") #'logical-to-boolean)
|
||||
((string= type "C") #'db3-trim-string)
|
||||
((string= type "D") #'db3-date-to-pgsql-date)
|
||||
(t nil)))))
|
||||
:transform transform)))
|
||||
|
||||
(declaim (inline logical-to-boolean
|
||||
db3-trim-string
|
||||
@ -76,6 +78,12 @@
|
||||
"DB3 Strings a right padded with spaces, fix that."
|
||||
(string-right-trim '(#\Space) value))
|
||||
|
||||
(defun db3-numeric-to-pgsql-numeric (value)
|
||||
"DB3 numerics should be good to go, but might contain spaces."
|
||||
(let ((trimmed-string (string-right-trim '(#\Space) value)))
|
||||
(unless (string= "" trimmed-string)
|
||||
trimmed-string)))
|
||||
|
||||
(defun db3-date-to-pgsql-date (value)
|
||||
"Convert a DB3 date to a PostgreSQL date."
|
||||
(when (and value (string/= "" value) (= 8 (length value)))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user