Replace first character checks with starts-with?
This commit is contained in:
parent
bfd7eb2141
commit
15f73f9442
1 changed files with 9 additions and 6 deletions
|
|
@ -280,7 +280,7 @@
|
||||||
|
|
||||||
Handles quoting, splitting at / or ., replacing - with _ etc."
|
Handles quoting, splitting at / or ., replacing - with _ etc."
|
||||||
[e & [{:keys [aliased drop-ns]}]]
|
[e & [{:keys [aliased drop-ns]}]]
|
||||||
(let [e (if (and aliased (keyword? e) (= \' (first (name e))))
|
(let [e (if (and aliased (keyword? e) (str/starts-with? (name e) "'"))
|
||||||
;; #497 quoted alias support (should behave like string)
|
;; #497 quoted alias support (should behave like string)
|
||||||
(subs (name e) 1)
|
(subs (name e) 1)
|
||||||
e)
|
e)
|
||||||
|
|
@ -350,7 +350,7 @@
|
||||||
(let [n (cond-> (name k)
|
(let [n (cond-> (name k)
|
||||||
*escape-?*
|
*escape-?*
|
||||||
(str/replace "?" "??"))]
|
(str/replace "?" "??"))]
|
||||||
(if (= \' (first n))
|
(if (str/starts-with? n "'")
|
||||||
(let [ident (subs n 1)
|
(let [ident (subs n 1)
|
||||||
ident-l (str/lower-case ident)]
|
ident-l (str/lower-case ident)]
|
||||||
(binding [*quoted* (when-not (contains? #{"array"} ident-l) *quoted*)]
|
(binding [*quoted* (when-not (contains? #{"array"} ident-l) *quoted*)]
|
||||||
|
|
@ -419,13 +419,16 @@
|
||||||
;; rather than name/namespace, we want to allow
|
;; rather than name/namespace, we want to allow
|
||||||
;; for multiple / in the %fun.call case so that
|
;; for multiple / in the %fun.call case so that
|
||||||
;; qualified column names can be used:
|
;; qualified column names can be used:
|
||||||
(let [c (cond-> (str x) (keyword? x) (subs 1))]
|
(let [c (if (keyword? x)
|
||||||
(cond (= \% (first c))
|
#?(:clj (str (.sym ^clojure.lang.Keyword x)) ;; Omits leading colon
|
||||||
|
:default (subs (str x) 1))
|
||||||
|
(str x))]
|
||||||
|
(cond (str/starts-with? c "%")
|
||||||
(let [[f & args] (str/split (subs c 1) #"\.")]
|
(let [[f & args] (str/split (subs c 1) #"\.")]
|
||||||
[(str (format-fn-name f) "("
|
[(str (format-fn-name f) "("
|
||||||
(join ", " (map #(format-entity (keyword %) opts)) args)
|
(join ", " (map #(format-entity (keyword %) opts)) args)
|
||||||
")")])
|
")")])
|
||||||
(= \? (first c))
|
(str/starts-with? c "?")
|
||||||
(let [k (keyword (subs c 1))]
|
(let [k (keyword (subs c 1))]
|
||||||
(cond *inline*
|
(cond *inline*
|
||||||
[(sqlize-value (param-value k))]
|
[(sqlize-value (param-value k))]
|
||||||
|
|
@ -433,7 +436,7 @@
|
||||||
(->numbered-param k)
|
(->numbered-param k)
|
||||||
:else
|
:else
|
||||||
["?" (->param k)]))
|
["?" (->param k)]))
|
||||||
(= \' (first c))
|
(str/starts-with? c "'")
|
||||||
(do
|
(do
|
||||||
(reset! *formatted-column* true)
|
(reset! *formatted-column* true)
|
||||||
[(subs c 1)])
|
[(subs c 1)])
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue