summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlo Zancanaro <carlo@clearboxsystems.com.au>2013-05-24 10:02:16 +1000
committerCarlo Zancanaro <carlo@clearboxsystems.com.au>2013-05-24 10:02:16 +1000
commite2bd4b4939d34fc9400c9843b691428d3888ecc4 (patch)
tree884dff7985b66cbd2ae84153e45d40e8139f5c92
parent5ccaca496f4babb4fef2d34e272b8772e077fa25 (diff)
Fix a bug in `resolve-fields`
The recursive calls to `resolve-fields` were not being made due to programmer error. This has been fixed, so now the field resolution stuff should work properly again. This is really highlighting the need for better testing. Get on that!
-rw-r--r--src/clojure_sql/dsl.clj4
-rw-r--r--test/clojure_sql/core_test.clj13
2 files changed, 11 insertions, 6 deletions
diff --git a/src/clojure_sql/dsl.clj b/src/clojure_sql/dsl.clj
index 996b55c..8c9c31d 100644
--- a/src/clojure_sql/dsl.clj
+++ b/src/clojure_sql/dsl.clj
@@ -45,8 +45,8 @@
(ambiguous-error field)))))
(defn ^:private resolve-fields [table aliases expression]
- (cond (list? expression) (map (partial table aliases) expression)
- (vector? expression) (mapv (partial table aliases) expression)
+ (cond (list? expression) (map (partial resolve-fields table aliases) expression)
+ (vector? expression) (mapv (partial resolve-fields table aliases) expression)
(keyword? expression) (resolve-field table aliases expression)
:else expression))
diff --git a/test/clojure_sql/core_test.clj b/test/clojure_sql/core_test.clj
index b5d65e7..236e421 100644
--- a/test/clojure_sql/core_test.clj
+++ b/test/clojure_sql/core_test.clj
@@ -18,8 +18,13 @@
(into {} (-> (table :user) (project '{(+ :username :password) :u})))
-(-> (table {(-> (table :users)
- (project '[:username (+ 1 2 3)])
- (rename '{(+ 1 2 3) :x})
- (select `(exists ~(table :users)))) :u})
+(-> (table :users)
+ (project '[:username (+ 1 2 3)])
+ (rename '{(+ 1 2 3) :x})
+ (select `(exists ~(-> (table :users)
+ (select '(= 10 :username)))))
println)
+
+(-> (table :users)
+ (project {:username :un})
+ (select '(= :username 10)))