mirror of
https://github.com/dimitri/pgloader.git
synced 2025-08-09 07:47:00 +02:00
Handle NIL values in transform functions.
When declaring types of arguments (mainly done for hinting the Common Lisp compiler into generating more efficient code), it's important to account for the possibility of the arguments being NIL, of NULL type. That's been made clear in the way the projection function is now generated in src/sources/source.lisp in project-fields function, with all the arguments now being &optional so that we are able to cope with ragged CSV files. The only expected change from this patch is missing warnings in some test cases, such as test/reformat.load, test/fixed.load and test/archive.load.
This commit is contained in:
parent
1af517323c
commit
9fa638e233
@ -84,13 +84,14 @@
|
||||
(:seconds 4 6)
|
||||
(:msecs 6 nil))))
|
||||
"Apply this function when input date in like '08231560'"
|
||||
(declare (type string time-string))
|
||||
(destructuring-bind (&key hour minute seconds msecs
|
||||
&allow-other-keys)
|
||||
(loop
|
||||
for (name start end) in format
|
||||
append (list name (subseq time-string start end)))
|
||||
(format nil "~a:~a:~a.~a" hour minute seconds msecs)))
|
||||
(declare (type (or null string) time-string))
|
||||
(when time-string
|
||||
(destructuring-bind (&key hour minute seconds msecs
|
||||
&allow-other-keys)
|
||||
(loop
|
||||
for (name start end) in format
|
||||
append (list name (subseq time-string start end)))
|
||||
(format nil "~a:~a:~a.~a" hour minute seconds msecs))))
|
||||
|
||||
(defun tinyint-to-boolean (integer-string)
|
||||
"When using MySQL, strange things will happen, like encoding booleans into
|
||||
@ -122,10 +123,11 @@
|
||||
(defun ip-range (start-integer-string end-integer-string)
|
||||
"Transform a couple of integers to an IP4R ip range notation."
|
||||
(declare (optimize speed)
|
||||
(type string start-integer-string end-integer-string))
|
||||
(let ((ip-start (int-to-ip (parse-integer start-integer-string)))
|
||||
(ip-end (int-to-ip (parse-integer end-integer-string))))
|
||||
(concatenate 'simple-base-string ip-start "-" ip-end)))
|
||||
(type (or null string) start-integer-string end-integer-string))
|
||||
(when (and start-integer-string end-integer-string)
|
||||
(let ((ip-start (int-to-ip (parse-integer start-integer-string)))
|
||||
(ip-end (int-to-ip (parse-integer end-integer-string))))
|
||||
(concatenate 'simple-base-string ip-start "-" ip-end))))
|
||||
|
||||
(defun convert-mysql-point (mysql-point-as-string)
|
||||
"Transform the MYSQL-POINT-AS-STRING into a suitable representation for
|
||||
@ -141,7 +143,7 @@
|
||||
(defun float-to-string (float)
|
||||
"Transform a Common Lisp float value into its string representation as
|
||||
accepted by PostgreSQL, that is 100.0 rather than 100.0d0."
|
||||
(declare (type float float))
|
||||
(declare (type (or null float) float))
|
||||
(let ((*read-default-float-format* 'double-float))
|
||||
(princ-to-string float)))
|
||||
|
||||
@ -155,7 +157,7 @@
|
||||
|
||||
(defun right-trim (string)
|
||||
"Remove whitespaces at end of STRING."
|
||||
(declare (type simple-string string))
|
||||
(declare (type (or null simple-string) string))
|
||||
(string-right-trim '(#\Space) string))
|
||||
|
||||
(defun byte-vector-to-bytea (vector)
|
||||
|
Loading…
Reference in New Issue
Block a user