mirror of
https://github.com/dimitri/pgloader.git
synced 2026-05-04 18:36:12 +02:00
Allow any character in a quoted CSV field name.
We used to force overly strict rules for a quoted field name in a CSV load file, now accept any character but a quote to be part of the field name. Fixes #416.
This commit is contained in:
parent
70572a2ea7
commit
c2c98b8b42
@ -189,15 +189,6 @@
|
||||
|
||||
(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)
|
||||
@ -207,9 +198,10 @@
|
||||
(:lambda (name)
|
||||
(string-downcase (text name))))
|
||||
|
||||
(defrule csv-quoted-field-name (and #\" csv-raw-field-name #\")
|
||||
(defrule csv-quoted-field-name (or (and #\' (* (not #\')) #\')
|
||||
(and #\" (* (not #\")) #\"))
|
||||
(:lambda (csv-field-name)
|
||||
(bind (((_ name _) csv-field-name)) name)))
|
||||
(bind (((_ name _) csv-field-name)) (text name))))
|
||||
|
||||
(defrule csv-field-name (or csv-quoted-field-name csv-bare-field-name))
|
||||
|
||||
|
||||
@ -4,7 +4,11 @@
|
||||
|
||||
LOAD CSV
|
||||
FROM inline with encoding 'LATIN1'
|
||||
HAVING FIELDS ("Some-Field", c2, c3)
|
||||
INTO postgresql:///pgloader?tab_csv
|
||||
(
|
||||
c1 text using "Some-Field", c2, c3
|
||||
)
|
||||
WITH truncate,
|
||||
skip header = 0,
|
||||
fields terminated by ',',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user