summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/clojure_sql/dsl.clj23
1 files changed, 6 insertions, 17 deletions
diff --git a/src/clojure_sql/dsl.clj b/src/clojure_sql/dsl.clj
index 5cf7f59..a75b8f7 100644
--- a/src/clojure_sql/dsl.clj
+++ b/src/clojure_sql/dsl.clj
@@ -46,9 +46,9 @@
[table field]
(ambiguous-error field)))))
-(defn ^:private resolve-fields [table aliases expression]
- (cond ;;(vector? expression) (mapv (partial resolve-fields table aliases) expression)
- (sequential? expression) (map (partial resolve-fields table aliases) expression)
+(defn ^:private process-expression [table aliases expression]
+ (cond (vector? expression) (list 'quote expression)
+ (sequential? expression) (map (partial process-expression table aliases) expression)
(keyword? expression) (resolve-field table aliases expression)
:else expression))
@@ -56,7 +56,7 @@
(let [table (if (= (count (:tables query)) 1)
(-> query :tables first key))
alias-lookup (or (:fields query) {})
- get-real-name #(resolve-fields table alias-lookup %)]
+ get-real-name #(resolve-field table alias-lookup %)]
(assoc query
:fields (->> (for [[old-name new-name] (if (map? fields)
fields
@@ -126,7 +126,7 @@
{:left left
:right right
:common-fields common-fields}))
- :else (resolve-fields nil merged-fields on))
+ :else (process-expression nil merged-fields on))
type (or type
(if join-condition :inner)
:cross)]
@@ -144,7 +144,7 @@
(let [table-name (if (= (count (:tables query)) 1)
(-> query :tables first key))
old-where (:where query)
- resolved-expression (resolve-fields table-name (:fields query) expression)
+ resolved-expression (process-expression table-name (:fields query) expression)
new-where (combine-wheres old-where resolved-expression)]
(assoc query :where new-where)))
@@ -162,17 +162,6 @@
(let [id 10]
- (->> (-> (table :x)
- (project [:x])
- (select `(and (in :x [1 2 3 :y])
- (= :x ~id)))
- (join (-> (table :y)
- (project [:y]))
- :on `(= :x :y))
- (join (-> (table :z)
- (project [:x])))
- (sort-by [:x]))
- (into {}))
(-> (table :x)
(project [:x])
(select `(and (in :x [1 2 3 :y])