Allow quoted field names to contain spaces, fix #285.

Given a fully quoted field name, there should be no restriction about
using spaces in between the quotes, but the parser used to choke on that
case.
This commit is contained in:
Dimitri Fontaine 2015-09-01 14:32:50 +02:00
parent 62f0b7fc56
commit b78bb6dd31
2 changed files with 14 additions and 8 deletions

View File

@ -197,16 +197,22 @@
(defrule csv-field-options (? csv-field-option-list))
(defrule csv-raw-field-name (and (or #\_ (alpha-char-p character))
(* (or (alpha-char-p character)
(digit-char-p character)
#\Space
#\.
#\$
#\_)))
(:text t))
(defrule csv-bare-field-name (and (or #\_ (alpha-char-p character))
(* (or (alpha-char-p character)
(digit-char-p character)
#\.
#\$
#\_)))
(:text t))
(defrule csv-bare-field-name csv-raw-field-name
(:lambda (name)
(string-downcase name)))
(string-downcase (text name))))
(defrule csv-quoted-field-name (and #\" csv-raw-field-name #\")
(:lambda (csv-field-name)

View File

@ -1,6 +1,6 @@
LOAD CSV
FROM inline (rownum, ts [date format 'YYYY-MM-DD HH24-MI-SS.US'])
INTO postgresql:///pgloader?dateformat (rownum, ts)
FROM inline ("row num", ts [date format 'YYYY-MM-DD HH24-MI-SS.US'])
INTO postgresql:///pgloader?dateformat ("row num", ts)
WITH truncate,
fields optionally enclosed by '"',
@ -14,8 +14,8 @@ LOAD CSV
BEFORE LOAD DO
$$ drop table if exists dateformat; $$,
$$ create table dateformat (
rownum smallint,
ts timestamp
"row num" smallint,
ts timestamp
);
$$;