From ab7c235329a52a84ad60cf731432bf7972061efc Mon Sep 17 00:00:00 2001 From: Sean Corfield Date: Sat, 26 Mar 2022 13:45:43 -0700 Subject: [PATCH] fix #399 by correcting docs and tests --- CHANGELOG.md | 1 + doc/postgresql.md | 4 ++-- src/honey/sql/helpers.cljc | 6 +++--- test/honey/sql/postgres_test.cljc | 4 ++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c1fa60..bade664 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Changes * 2.2.next in progress + * Address [#399](https://github.com/seancorfield/honeysql/issues/399) by correcting multi-column `RETURNING` clauses in docs and tests. * Address [#398](https://github.com/seancorfield/honeysql/issues/398) by adding `honey.sql.pg-json` namespace that registers PostgreSQL JSON operators and provides symbolic names for "unwritable" operators (that contain `@`). * Fix [#387](https://github.com/seancorfield/honeysql/issues/387) again. * Update CI to reflect Clojure 1.11 release (master -> 1.11; new master is 1.12). diff --git a/doc/postgresql.md b/doc/postgresql.md index 9f60600..e7e1e1f 100644 --- a/doc/postgresql.md +++ b/doc/postgresql.md @@ -250,9 +250,9 @@ user=> (sql/format {:delete-from :distributors user=> (-> (update :distributors) (set {:dname "Foo Bar Designs"}) (where [:= :did 2]) - (returning [:did :dname]) + (returning :did :dname) sql/format) -["UPDATE distributors SET dname = ? WHERE did = ? RETURNING did dname" +["UPDATE distributors SET dname = ? WHERE did = ? RETURNING did, dname" "Foo Bar Designs" 2] ``` diff --git a/src/honey/sql/helpers.cljc b/src/honey/sql/helpers.cljc index 3c6346c..f6a21e4 100644 --- a/src/honey/sql/helpers.cljc +++ b/src/honey/sql/helpers.cljc @@ -1,4 +1,4 @@ -;; copyright (c) 2020-2021 sean corfield, all rights reserved +;; copyright (c) 2020-2022 sean corfield, all rights reserved (ns honey.sql.helpers "Helper functions for the built-in clauses in honey.sql. @@ -870,9 +870,9 @@ "Accepts any number of column names to return from an insert operation: - (returning :*) + (returning :*) and (returning :a :b) - Produces: RETURNING *" + Produce: RETURNING * and RETURNING a, b respectively." [& cols] (generic :returning cols)) diff --git a/test/honey/sql/postgres_test.cljc b/test/honey/sql/postgres_test.cljc index 9649a66..00218b1 100644 --- a/test/honey/sql/postgres_test.cljc +++ b/test/honey/sql/postgres_test.cljc @@ -152,11 +152,11 @@ (sql/format {:delete-from :distributors :where [:> :did :10] :returning [:*]}))) - (is (= ["UPDATE distributors SET dname = ? WHERE did = 2 RETURNING did dname" "Foo Bar Designs"] + (is (= ["UPDATE distributors SET dname = ? WHERE did = 2 RETURNING did, dname" "Foo Bar Designs"] (-> (update :distributors) (set {:dname "Foo Bar Designs"}) (where [:= :did :2]) - (returning [:did :dname]) + (returning :did :dname) sql/format))))) (deftest create-view-test