From 0c3f3d0403cccae2738f2e9aadbdf1d89b436f3f Mon Sep 17 00:00:00 2001 From: "Howard M. Lewis Ship" Date: Wed, 22 Oct 2014 10:01:46 -0700 Subject: [PATCH] Fix example of insert-into w/ nested query The previous example generated SQL that could not actually execute. --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 5721d38..267c573 100644 --- a/README.md +++ b/README.md @@ -117,16 +117,17 @@ The column values do not have to be literals, they can be nested queries: ```clj (let [user-id 12345 - role-names ["user" "editor"]] + role-name "user"] (-> (insert-into :user_profile_to_role) (values [{:user_profile_id user-id :role_id (-> (select :id) (from :role) - (where [:in :name role-names]))}]) + (where [:= :name role-name]))}]) sql/format)) + => ["INSERT INTO user_profile_to_role (user_profile_id, role_id) - VALUES (12345, (SELECT id FROM role WHERE (name in (?, ?))))" - "user" "editor"] + VALUES (12345, (SELECT id FROM role WHERE name = ?))" + "user"] ``` Updates are possible too (note the double S in `sset` to avoid clashing