Skip to content

Commit b667b8b

Browse files
committed
Fix formatting
1 parent cd8c7c3 commit b667b8b

File tree

3 files changed

+25
-30
lines changed

3 files changed

+25
-30
lines changed

src/honeysql_postgres/format.cljc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
(ns ^{:doc "Extension of the honeysql format functions specifically for postgreSQL"}
2-
honeysql-postgres.format
2+
honeysql-postgres.format
33
(:require [honeysql.format :as sqlf :refer [fn-handler format-clause format-modifiers]] ;; multi-methods
44
[honeysql-postgres.util :as util]
55
[clojure.string :as string]))
@@ -100,8 +100,8 @@
100100

101101
(defmethod format-clause :on-conflict-constraint [[_ k] _]
102102
(str "ON CONFLICT ON CONSTRAINT " (-> k
103-
util/get-first
104-
sqlf/to-sql)))
103+
util/get-first
104+
sqlf/to-sql)))
105105

106106
(defmethod format-clause :on-conflict [[_ ids] _]
107107
(str "ON CONFLICT " (util/comma-join-args ids)))

src/honeysql_postgres/util.cljc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
(ns ^{:doc "Postgres Honeysql utils"}
2-
honeysql-postgres.util
2+
honeysql-postgres.util
33
(:refer-clojure :exclude [format partition-by])
44
(:require [honeysql.format :as sqlf]))
55

@@ -27,8 +27,8 @@
2727
(prep-check '([:= :a :b] [:< :a :c])) => [:and [:= :a :b] [:< :a :c]]"
2828
[args]
2929
(let [preds (if (= 1 (count args))
30-
(first args)
31-
args)
30+
(first args)
31+
args)
3232
[logic-op preds] (if (keyword? (first preds))
3333
[(first preds) (rest preds)]
3434
[:and preds])]

test/honeysql_postgres/postgres_test.cljc

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -55,24 +55,22 @@
5555
do-nothing))
5656
sql/format)))))
5757

58-
5958
(deftest upsert-where-test
6059
(is (= ["INSERT INTO user (phone, name) VALUES (?, ?) ON CONFLICT (phone) WHERE phone IS NOT NULL DO UPDATE SET phone = EXCLUDED.phone, name = EXCLUDED.name WHERE user.active = FALSE" "5555555" "John"]
6160
(sql/format
62-
{:insert-into :user
63-
:values [{:phone "5555555" :name "John"}]
64-
:upsert {:on-conflict [:phone]
65-
:where [:<> :phone nil]
66-
:do-update-set {:fields [:phone :name]
67-
:where [:= :user.active false]}}}))))
68-
61+
{:insert-into :user
62+
:values [{:phone "5555555" :name "John"}]
63+
:upsert {:on-conflict [:phone]
64+
:where [:<> :phone nil]
65+
:do-update-set {:fields [:phone :name]
66+
:where [:= :user.active false]}}}))))
6967

7068
(deftest returning-test
7169
(testing "returning clause in sql generation for postgresql"
7270
(is (= ["DELETE FROM distributors WHERE did > 10 RETURNING *"]
7371
(sql/format {:delete-from :distributors
7472
:where [:> :did :10]
75-
:returning [:*] })))
73+
:returning [:*]})))
7674
(is (= ["UPDATE distributors SET dname = ? WHERE did = 2 RETURNING did dname" "Foo Bar Designs"]
7775
(-> (update :distributors)
7876
(sset {:dname "Foo Bar Designs"})
@@ -209,26 +207,25 @@
209207
(testing "select from table with ILIKE operator"
210208
(is (= ["SELECT * FROM products WHERE name ILIKE ?" "%name%"]
211209
(-> (select :*)
212-
(from :products)
213-
(where [:ilike :name "%name%"])
214-
sql/format)))))
210+
(from :products)
211+
(where [:ilike :name "%name%"])
212+
sql/format)))))
215213

216214
(deftest select-where-not-ilike
217215
(testing "select from table with NOT ILIKE operator"
218216
(is (= ["SELECT * FROM products WHERE name NOT ILIKE ?" "%name%"]
219217
(-> (select :*)
220-
(from :products)
221-
(where [:not-ilike :name "%name%"])
222-
sql/format)))))
218+
(from :products)
219+
(where [:not-ilike :name "%name%"])
220+
sql/format)))))
223221

224222
(deftest values-except-select
225223
(testing "select which values are not not present in a table"
226224
(is (= ["VALUES (?), (?), (?) EXCEPT SELECT id FROM images" 4 5 6]
227225
(sql/format
228-
{:except
229-
[{:values [[4] [5] [6]]}
230-
{:select [:id] :from [:images]}]})))))
231-
226+
{:except
227+
[{:values [[4] [5] [6]]}
228+
{:select [:id] :from [:images]}]})))))
232229

233230
(deftest select-except-select
234231
(testing "select which rows are not present in another table"
@@ -238,7 +235,6 @@
238235
[{:select [:ip]}
239236
{:select [:ip] :from [:ip_location]}]})))))
240237

241-
242238
(deftest values-except-all-select
243239
(testing "select which values are not not present in a table"
244240
(is (= ["VALUES (?), (?), (?) EXCEPT ALL SELECT id FROM images" 4 5 6]
@@ -247,7 +243,6 @@
247243
[{:values [[4] [5] [6]]}
248244
{:select [:id] :from [:images]}]})))))
249245

250-
251246
(deftest select-except-all-select
252247
(testing "select which rows are not present in another table"
253248
(is (= ["SELECT ip EXCEPT ALL SELECT ip FROM ip_location"]
@@ -260,6 +255,6 @@
260255
(testing "select distinct on"
261256
(is (= ["SELECT DISTINCT ON(\"a\", \"b\") \"c\" FROM \"products\" "]
262257
(-> (select :c)
263-
(from :products)
264-
(modifiers :distinct-on :a :b)
265-
(sql/format :quoting :ansi))))))
258+
(from :products)
259+
(modifiers :distinct-on :a :b)
260+
(sql/format :quoting :ansi))))))

0 commit comments

Comments
 (0)