From c2990597f14c15ef5d614f21daf934d3a5c1c0f7 Mon Sep 17 00:00:00 2001 From: Sean Corfield Date: Thu, 20 Feb 2025 16:47:27 -0800 Subject: [PATCH] fixes #566 Signed-off-by: Sean Corfield --- CHANGELOG.md | 1 + src/honey/sql.cljc | 3 ++- test/honey/ops_test.cljc | 10 +++++++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f065665..351a4c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/honey/sql.cljc b/src/honey/sql.cljc index 926decf..642fdf7 100644 --- a/src/honey/sql.cljc +++ b/src/honey/sql.cljc @@ -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. @@ -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)) diff --git a/test/honey/ops_test.cljc b/test/honey/ops_test.cljc index 6c84c1f..c3708cc 100644 --- a/test/honey/ops_test.cljc +++ b/test/honey/ops_test.cljc @@ -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]) @@ -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)))))