From 6324eca4fcc7a3cba79395c2ed83dbe434e5a9a2 Mon Sep 17 00:00:00 2001 From: Sean Corfield Date: Sat, 11 Feb 2023 13:34:39 -0800 Subject: [PATCH] fixes #459 by making all operators variadic except for := and the various :<> variants some operators only make sense in binary usage and will produce invalid SQL if used in a non-binary manner --- doc/extending-honeysql.md | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/doc/extending-honeysql.md b/doc/extending-honeysql.md index 98b1c53..bf06655 100644 --- a/doc/extending-honeysql.md +++ b/doc/extending-honeysql.md @@ -82,16 +82,13 @@ You might have: `honey.sql/register-op!` accepts a keyword (or a symbol) that should be treated as a new infix operator. -By default, operators are treated as strictly binary -- -accepting just two arguments -- and an exception will be -thrown if they are provided less than two or more than -two arguments. You can optionally specify that an operator -can take any number of arguments with `:variadic true`: +All operators are treated as variadic and an exception will be +thrown if they are provided no arguments: ```clojure (require '[honey.sql :as sql]) -(sql/register-op! :<=> :variadic true) +(sql/register-op! :<=>) ;; and then use the new operator: (sql/format {:select [:*], :from [:table], :where [:<=> 13 :x 42]}) ;; will produce: @@ -106,7 +103,7 @@ such `nil` expressions. You can specify `:ignore-nil true` to achieve that: ```clojure -(sql/register-op! :<=> :variadic true :ignore-nil true) +(sql/register-op! :<=> :ignore-nil true) ;; and then use the new operator: (sql/format {:select [:*], :from [:table], :where [:<=> nil :x 42]}) ;; will produce: