diff --git a/CHANGELOG.md b/CHANGELOG.md index 050541c..44a35d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ * Fix [#465](https://github.com/seancorfield/honeysql/issues/465) to allow multiple columns in `:order-by` special syntax via PR [#468](https://github.com/seancorfield/honeysql/pull/468) [@p-himik](https://github.com/p-himik). * Fix [#464](https://github.com/seancorfield/honeysql/issues/464) by adding an optional type argument to `:array` via PR [#469](https://github.com/seancorfield/honeysql/pull/469) [@p-himik](https://github.com/p-himik). * Address [#463](https://github.com/seancorfield/honeysql/issues/463) by explaining `:quoted nil` via PR [#475](https://github.com/seancorfield/honeysql/pull/475) [@nharsch](https://github.com/nharsch). + * Address [#462](https://github.com/seancorfield/honeysql/issues/462) by adding a note in the documentation for set operations, clarifying precedence issues. * 2.4.980 -- 2023-02-15 * Fix [#461](https://github.com/seancorfield/honeysql/issues/461) -- a regression introduced in 2.4.979 -- by restricting unary operators to just `+`, `-`, and `~` (bitwise negation). diff --git a/README.md b/README.md index 24069ad..c82888d 100644 --- a/README.md +++ b/README.md @@ -538,6 +538,8 @@ There are also helpers for each of those: => ["SELECT * FROM foo UNION SELECT * FROM bar"] ``` +> Note: different databases have different precedence rules for these set operations when used in combination -- you may need to use `:nest` to add `(` .. `)` in order to combine these operations in a single SQL statement, if the natural order produced by HoneySQL does not work "as expected" for your database. + ### Functions Function calls (and expressions with operators) can be specified as diff --git a/doc/clause-reference.md b/doc/clause-reference.md index 2a9d5e3..e548c96 100644 --- a/doc/clause-reference.md +++ b/doc/clause-reference.md @@ -439,6 +439,8 @@ user=> (sql/format '{union [{select (id,status) from (table-a)} ["SELECT id, status FROM table_a UNION SELECT id, event AS status, from, table_b"] ``` +> Note: different databases have different precedence rules for these set operations when used in combination -- you may need to use `:nest` to add `(` .. `)` in order to combine these operations in a single SQL statement, if the natural order produced by HoneySQL does not work "as expected" for your database. + ## select, select-distinct, table `:select` and `:select-distinct` expect a sequence of SQL entities (column names @@ -482,7 +484,7 @@ user=> (sql/format {:select [[:* :except [:a :b] :replace [[[:inline 2] :c]]]] : ``` The `:table` clause is equivalent to `:select :* :from` and accepts just -a simple table name -- `:create-table-as` above for an example. +a simple table name -- see `:create-table-as` above for an example. ## select-distinct-on