Accept more syntaxes for fields and columns, fixes #79.

With this patch it's now possible to "quote" column names and to use
_ (underscore) as the leading character in a field or column name. Of
course it is still unnecessary to quote the column names, but handling
the PostgreSQL quoting rules can't be bad here.
This commit is contained in:
Dimitri Fontaine 2014-06-16 16:27:46 +02:00
parent b1c1b8bd45
commit ecd4f31d12

View File

@ -1558,12 +1558,20 @@ load database
(:lambda (options)
(alexandria:alist-plist options)))
(defrule csv-field-name (and (alpha-char-p character)
(* (or (alpha-char-p character)
(digit-char-p character)
#\_)))
(defrule csv-bare-field-name (and (or #\_ (alpha-char-p character))
(* (or (alpha-char-p character)
(digit-char-p character)
#\_)))
(:text t))
(defrule csv-quoted-field-name (and #\" csv-bare-field-name #\")
(:lambda (csv-field-name)
(destructuring-bind (open name close) csv-field-name
(declare (ignore open close))
name)))
(defrule csv-field-name (or csv-quoted-field-name csv-bare-field-name))
(defrule csv-source-field (and csv-field-name csv-field-options)
(:destructure (name opts)
`(,name ,@opts)))