diff options
author | Carlo Zancanaro <carlo@clearboxsystems.com.au> | 2013-07-12 10:20:20 +1000 |
---|---|---|
committer | Carlo Zancanaro <carlo@clearboxsystems.com.au> | 2013-07-12 10:20:20 +1000 |
commit | c2c3e896dcd69ef59132395126bd2e8fe13434a2 (patch) | |
tree | 8080d029c1ecdb1a53ff931b544020ca15a1761a | |
parent | d91170319be957b9202eaefd5153883d22ba6f38 (diff) |
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.
-rw-r--r-- | src/clojure_sql/dsl.clj | 7 |
1 files changed, 7 insertions, 0 deletions
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] |