mirror of
https://github.com/dimitri/pgloader.git
synced 2025-08-06 22:37:02 +02:00
To be able to use "t" (or "nil") as a column name, pgloader needs to be able to generate lisp code where those symbols are available. It's simple enough in that a Common Lisp package that doesn't :use :cl fullfills the condition, so intern user symbols in a specially crafted package that doesn't :use :cl. Now, we still need to be able to run transformation code that is using the :cl package symbols and the pgloader.transforms functions too. In this commit we introduce a heuristic to pick symbols either as functions from pgloader.transforms or anything else in pgloader.user-symbols. And so that user code may use NIL too, we provide an override mechanism to the intern-symbol heuristic and use it only when parsing user code, not when producing Common Lisp code from the parsed load command.
29 lines
595 B
Fish
29 lines
595 B
Fish
--
|
|
-- See https://github.com/dimitri/pgloader/issues/297
|
|
--
|
|
-- The "t" field would be "temperature", for instance.
|
|
--
|
|
|
|
LOAD CSV
|
|
FROM inline (a, b, nil, t)
|
|
INTO postgresql:///pgloader?temp(a,b,nil,t)
|
|
|
|
WITH fields terminated by ';'
|
|
|
|
BEFORE LOAD DO
|
|
$$ drop table if exists temp; $$,
|
|
$$ CREATE TABLE temp
|
|
(
|
|
a integer,
|
|
b timestamp without time zone,
|
|
nil real,
|
|
t real
|
|
);
|
|
$$;
|
|
|
|
|
|
100;2015-01-01 00:00:00;-6;10
|
|
101;2015-01-02 00:00:00;-2.1;12.5
|
|
102;2015-01-03 00:00:00;3.4;5.5
|
|
103;2015-01-04 00:00:00;4.7;-2.3
|
|
104;2015-01-05 00:00:00;0.4;0 |