Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions clojure/src/pgloader/load_file/ast.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
[clojure.string :as str]
[clojure.tools.logging :as log]
[pgloader.pg-service :as pg-service]
[pgloader.mysql-options :as mysql-opts])
[pgloader.mysql-options :as mysql-opts]
[pgloader.transforms :refer [compile-using-expr]])
(:import [java.net URI]))

(declare s-expr-content)

(set! *warn-on-reflection* true)

(defrecord LoadCommand
Expand Down Expand Up @@ -295,8 +298,18 @@
(clojure.string/join " " (map second (filter #(= :word-part (first %)) (rest target-inner)))))))
using-fn (some (fn [n]
(when (and (vector? n) (= :using-fn (first n)))
(keyword (second (some #(when (and (vector? %) (= :fn-name (first %))) %)
(rest n))))))
(let [expr-node (some #(when (and (vector? %)
(or (= :fn-name (first %))
(= :s-expr (first %))
(= :reader-fn (first %))))
%)
(rest n))]
(case (first expr-node)
:fn-name (keyword (second expr-node))
:s-expr (compile-using-expr
(str "(" (s-expr-content expr-node) ")"))
:reader-fn (compile-using-expr
(str "#(" (s-expr-content (second expr-node)) ")"))))))
flat-cast-opts)
when-node (first (filter #(= :when-or-unsigned (first %)) inner-children))
when-cond (when when-node
Expand Down
2 changes: 1 addition & 1 deletion clojure/src/pgloader/load_file/grammar.clj
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@
keep-not-null = <'keep'> <ws> <'not'> <ws> <'null'>
drop-typemod = <'drop'> <ws> <'typemod'>
keep-typemod = <'keep'> <ws> <'typemod'>
using-fn = <'using'> <ws> fn-name
using-fn = <'using'> <ws> (s-expr | reader-fn | fn-name)
fn-name = #'[a-zA-Z][a-zA-Z0-9_-]*'
when-or-unsigned = <'when'> <ws> (when-expr | <'unsigned'> | <'default'> <ws> when-default-val) (<ws> when-not-null)?
when-not-null = <'and'> <ws> <'not'> <ws> <'null'>
Expand Down