Skip to content

Commit

Permalink
fixes #566
Browse files Browse the repository at this point in the history
Signed-off-by: Sean Corfield <sean@corfield.org>
  • Loading branch information
seancorfield committed Feb 21, 2025
1 parent 695351e commit c299059
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changes

* 2.6.next in progress
* Address [#566](/~https://github.com/seancorfield/honeysql/issues/566) by adding `IS [NOT] DISTINCT FROM` operators.
* Add examples of `:alias` with `:group-by` (syntax is slightly different to existing examples for `:order-by`).

* 2.6.1270 -- 2025-01-17
Expand Down
3 changes: 2 additions & 1 deletion src/honey/sql.cljc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;; copyright (c) 2020-2024 sean corfield, all rights reserved
;; copyright (c) 2020-2025 sean corfield, all rights reserved

(ns honey.sql
"Primary API for HoneySQL 2.x.
Expand Down Expand Up @@ -1788,6 +1788,7 @@
"like" "not-like" "regexp" "~" "&&"
"ilike" "not-ilike" "similar-to" "not-similar-to"
"is" "is-not" "not=" "!=" "regex"
"is-distinct-from" "is-not-distinct-from"
"with-ordinality"}
(into (map str "+-*%|&^=<>"))
(into (keys infix-aliases))
Expand Down
10 changes: 9 additions & 1 deletion test/honey/ops_test.cljc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;; copyright (c) 2023-2024 sean corfield, all rights reserved
;; copyright (c) 2023-2025 sean corfield, all rights reserved

(ns honey.ops-test
(:refer-clojure :exclude [format])
Expand All @@ -9,3 +9,11 @@
(is (= ["SELECT a - b - c AS x"]
(-> {:select [[[:- :a :b :c] :x]]}
(sut/format)))))

(deftest issue-566
(is (= ["SELECT * FROM table WHERE a IS DISTINCT FROM b"]
(-> {:select :* :from :table :where [:is-distinct-from :a :b]}
(sut/format))))
(is (= ["SELECT * FROM table WHERE a IS NOT DISTINCT FROM b"]
(-> {:select :* :from :table :where [:is-not-distinct-from :a :b]}
(sut/format)))))

0 comments on commit c299059

Please sign in to comment.