From 07eb66759a43e92ba539c6bd450c474b8d49dcd2 Mon Sep 17 00:00:00 2001 From: Sean Corfield Date: Sat, 30 Jan 2021 17:27:00 -0800 Subject: [PATCH] Restore cljs compatibility --- README.md | 2 +- src/honey/sql.cljc | 3 ++- test/honey/sql/helpers_test.cljc | 7 +++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 855fb04..eae23aa 100644 --- a/README.md +++ b/README.md @@ -344,7 +344,7 @@ to identify inline parameter values, and how to add in raw SQL fragments! ``` ```clojure call-qualify-map -=> {:where [:and [:= :a [:param :baz]] [:= :b [:inline 42]]] +=> '{:where [:and [:= :a [:param :baz]] [:= :b [:inline 42]]] :from (:foo) :select [[[:foo :bar]] [[:raw "@var := foo.bar"]]]} ``` diff --git a/src/honey/sql.cljc b/src/honey/sql.cljc index 39e25d8..3ad5f5b 100644 --- a/src/honey/sql.cljc +++ b/src/honey/sql.cljc @@ -460,10 +460,11 @@ "in" "not-in" "like" "not-like" "regexp" "ilike" "not-ilike" "similar-to" "not-similar-to" "is" "is-not" "not=" "!=" "regex"} - (into (map str "+-*/%|&^=<>")) + (into (map str "+-*%|&^=<>")) (into (keys infix-aliases)) (into (vals infix-aliases)) (->> (into #{} (map keyword))) + (conj :/) ; because (keyword "/") does not work in cljs (atom))) (def ^:private op-ignore-nil (atom #{:and :or})) diff --git a/test/honey/sql/helpers_test.cljc b/test/honey/sql/helpers_test.cljc index 540ac86..034b716 100644 --- a/test/honey/sql/helpers_test.cljc +++ b/test/honey/sql/helpers_test.cljc @@ -5,7 +5,10 @@ (:require #?(:clj [clojure.test :refer [deftest is testing]] :cljs [cljs.test :refer-macros [deftest is testing]]) [honey.sql :as sql] - [honey.sql.helpers :refer :all])) + [honey.sql.helpers + :refer [columns cross-join from full-join group-by having insert-into + join left-join limit offset order-by right-join + select select-distinct values where with]])) (deftest test-select (let [m1 (-> (with [:cte (-> (select :*) @@ -263,7 +266,7 @@ :from [:collection] :where [:= :personal_owner_id nil]} (clojure.core/for [id ids] - [:not-like :location [:raw (clojure.core/format "'/%d/%%'" id)]]))))) + [:not-like :location [:raw (str "'/" id "/%'")]]))))) (deftest issue-282 (is (= [(str "SELECT id AS id FROM collection"