From 819c6e7c1920f8dc537a5669bb0a44634e1e3a67 Mon Sep 17 00:00:00 2001 From: Sean Corfield Date: Mon, 10 May 2021 12:37:07 -0700 Subject: [PATCH] Additional work on #325; update CHANGELOG --- CHANGELOG.md | 5 +++-- src/honey/sql.cljc | 11 +++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eb66033..46d7a83 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,10 @@ # Changes * 2.0.next in progress - * Update `test-runner`. + * Address #326 by allowing `ON`/`USING` to be optional and not dropping parameters on the floor. _[still needs tests to be written!]_ + * Fix #325 by making the `%` function call syntax respect `:quoted true` and/or `:dialect` options, and also allowing for qualified column names _[some additional tests needed plus likely documentation updates]_. (PR from @lognush) * Add `:quoted-snake true` option to force conversion from kebab-case to snake_case when `:quoted true` or a `:dialect` is specified to `format`. - * TBD `%` function syntax may respect `:quoted true` or a `:dialect` is specified to `format` (awaiting PR). + * Update `test-runner`. * 2.0.0-rc1 (for testing; 2021-05-06) * Fix #324 so that `insert-into` supports merging into another statement in all cases. diff --git a/src/honey/sql.cljc b/src/honey/sql.cljc index 4e391cd..2dedaec 100644 --- a/src/honey/sql.cljc +++ b/src/honey/sql.cljc @@ -153,7 +153,6 @@ (defn- namespace-_ [x] (some-> (namespace x) (str/replace "-" "_"))) (defn- name-_ [x] (str/replace (name x) "-" "_")) -(defn- -_ [x] (str/replace x "-" "_")) (defn- sqlize-value [x] (cond @@ -215,13 +214,17 @@ (fn [fk _] (param-value (fk)))})) (defn- format-var [x & [opts]] - (let [c (name x)] + ;; rather than name/namespace, we want to allow + ;; for multiple / in the %fun.call case so that + ;; qualified column names can be used: + (let [c (cond-> (str x) (keyword? x) (subs 1))] (cond (= \% (first c)) (let [[f & args] (str/split (subs c 1) #"\.") quoted-args (map #(format-entity (keyword %) opts) args)] - [(str (upper-case (-_ f)) "(" (str/join ", " quoted-args) ")")]) + [(str (upper-case (str/replace f "-" "_")) + "(" (str/join ", " quoted-args) ")")]) (= \? (first c)) - (let [k (keyword (subs (-_ c) 1))] + (let [k (keyword (subs c 1))] (if *inline* [(sqlize-value (param-value k))] ["?" (->param k)]))