From e783362c6a54e73730d93eebe7092447a567f989 Mon Sep 17 00:00:00 2001 From: Cam Saul Date: Wed, 8 Feb 2023 18:56:23 +0000 Subject: [PATCH 1/2] Add section about `ORDER BY ... NULLS LAST` to 1.x differences dox --- doc/differences-from-1-x.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/doc/differences-from-1-x.md b/doc/differences-from-1-x.md index 4e9530b..89b5bb1 100644 --- a/doc/differences-from-1-x.md +++ b/doc/differences-from-1-x.md @@ -189,6 +189,27 @@ user=> (sql/format {:select [[[:exists {:select [:a] :from [:foo]}] :x]]}) ["SELECT EXISTS (SELECT a FROM foo) AS x"] ``` +### `ORDER BY` with `NULLS FIRST` or `NULLS LAST` + +In HoneySQL 1.x, if you wanted to generate SQL like + +```sql +ORDER BY ... DESC NULLS LAST +``` + +you needed to pass `:nulls-last` as a separate keyword, after `:asc` or `:desc`: + +```clj +{:order-by [[:my-column :desc :nulls-last]]} +;; => +``` + +In HoneySQL 2.x, the direction and the null ordering rule are now combined into a single keyword: + +```clj +{:order-by [[:my-column :desc-nulls-last]]} +``` + ## Extensibility The protocols and multimethods in 1.x have all gone away. The primary extension point is `honey.sql/register-clause!` which lets you specify the new clause (keyword), the formatter function for it, and the existing clause that it should be ranked before (`format` processes the DSL in clause order). From 982ebd18e125d37cf8e7504e267e9b84dd1b6357 Mon Sep 17 00:00:00 2001 From: Cam Saul <1455846+camsaul@users.noreply.github.com> Date: Wed, 8 Feb 2023 11:09:14 -0800 Subject: [PATCH 2/2] Update differences-from-1-x.md --- doc/differences-from-1-x.md | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/differences-from-1-x.md b/doc/differences-from-1-x.md index 89b5bb1..9819620 100644 --- a/doc/differences-from-1-x.md +++ b/doc/differences-from-1-x.md @@ -201,7 +201,6 @@ you needed to pass `:nulls-last` as a separate keyword, after `:asc` or `:desc`: ```clj {:order-by [[:my-column :desc :nulls-last]]} -;; => ``` In HoneySQL 2.x, the direction and the null ordering rule are now combined into a single keyword: