From c2c3e896dcd69ef59132395126bd2e8fe13434a2 Mon Sep 17 00:00:00 2001 From: Carlo Zancanaro Date: Fri, 12 Jul 2013 10:20:20 +1000 Subject: Add a rename helper to turn queries into "subobjects" in the result. Essentially just prefixes a subobject name in front of all fields in a query, with a dot separating the new prefix and the original name. --- src/clojure_sql/dsl.clj | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/clojure_sql/dsl.clj b/src/clojure_sql/dsl.clj index 35f296f..13319f3 100644 --- a/src/clojure_sql/dsl.clj +++ b/src/clojure_sql/dsl.clj @@ -158,6 +158,13 @@ [prefix] (prefix-names-matching (constantly true) prefix)) +(defn as-subobject + "Prefix all field names with \"{key}.\" to use them as sub-objects + in the final result. Can also be useful to disambiguate fields for + joins in a regular and predictable manner." + [key] + (prefix-names (str (name key) \.))) + (defn ^:private combine-conjunctions [& wheres] -- cgit v1.2.3