mirror of
https://github.com/dimitri/pgloader.git
synced 2025-08-06 22:37:02 +02:00
Switch to the newer cl-csv API.
Thanks to the work at https://github.com/AccelerationNet/cl-csv/pull/12 we can now use the main branch of cl-csv again.
This commit is contained in:
parent
539ad57347
commit
07c614c170
2
Makefile
2
Makefile
@ -21,7 +21,7 @@ docs:
|
||||
git clone https://github.com/qitab/qmynd.git $@
|
||||
|
||||
~/quicklisp/local-projects/cl-csv:
|
||||
git clone -b empty-strings-and-nil https://github.com/dimitri/cl-csv.git $@
|
||||
git clone https://github.com/AccelerationNet/cl-csv.git $@
|
||||
|
||||
postmodern: ~/quicklisp/local-projects/Postmodern ;
|
||||
qmynd: ~/quicklisp/local-projects/qmynd ;
|
||||
|
@ -26,7 +26,7 @@
|
||||
:initform cl-csv:*quote-escape*)
|
||||
(trim-blanks :accessor csv-trim-blanks ; CSV blank and NULLs
|
||||
:initarg :trim-blanks ;
|
||||
:initform cl-csv:*trim-blanks*))
|
||||
:initform t))
|
||||
(:documentation "pgloader CSV Data Source"))
|
||||
|
||||
(defmethod initialize-instance :after ((csv copy-csv) &key)
|
||||
@ -98,7 +98,9 @@
|
||||
:separator (csv-separator csv)
|
||||
:quote (csv-quote csv)
|
||||
:escape (csv-escape csv)
|
||||
:trim-blanks (csv-trim-blanks csv))
|
||||
:unquoted-empty-string-is-nil t
|
||||
:quoted-empty-string-is-nil nil
|
||||
:trim-outer-whitespace (csv-trim-blanks csv))
|
||||
((or cl-csv:csv-parse-error type-error) (condition)
|
||||
(progn
|
||||
(log-message :error "~a" condition)
|
||||
|
@ -17,4 +17,4 @@ LOAD CSV
|
||||
"unquoted blanks", ,"should be null"
|
||||
"unquoted string",no quote,"should be 'no quote'"
|
||||
"quoted separator","a,b,c","should be 'a,b,c'"
|
||||
"keep extra blanks", test string , "should be ' test string '"
|
||||
"keep extra blanks", test string , "should be an error"
|
20
test/csv-trim-extra-blanks.load
Normal file
20
test/csv-trim-extra-blanks.load
Normal file
@ -0,0 +1,20 @@
|
||||
LOAD CSV
|
||||
FROM INLINE
|
||||
INTO postgresql:///pgloader?nulls (f1, f2, f3)
|
||||
WITH truncate,
|
||||
trim unquoted blanks,
|
||||
fields optionally enclosed by '"',
|
||||
fields escaped by double-quote,
|
||||
fields terminated by ','
|
||||
|
||||
BEFORE LOAD DO
|
||||
$$ drop table if exists nulls; $$,
|
||||
$$ create table if not exists nulls (id serial, f1 text, f2 text, f3 text); $$;
|
||||
|
||||
"quoted empty string","","should be empty string"
|
||||
"no value between separators",,"should be null"
|
||||
"quoted blanks"," ","should be blanks"
|
||||
"unquoted blanks", ,"should be null"
|
||||
"unquoted string",no quote,"should be 'no quote'"
|
||||
"quoted separator","a,b,c","should be 'a,b,c'"
|
||||
"trim extra blanks", test string , "should be 'test string'"
|
Loading…
Reference in New Issue
Block a user