From e783362c6a54e73730d93eebe7092447a567f989 Mon Sep 17 00:00:00 2001 From: Cam Saul Date: Wed, 8 Feb 2023 18:56:23 +0000 Subject: [PATCH] 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).