Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add some 'where' tests for name with hyphen.

  • Loading branch information...
commit e04ee1624d14e4320df77e90b1241f19bf875332 1 parent 39cf023
@Ruiyun authored
View
3  src/clojureql/internal.clj
@@ -67,7 +67,8 @@
(not (empty? tname)))
(str (nskeyword tname) \.) "")
(escape-name (nskeyword colname)))
- (.replaceAll "\\.\\." "\\.")))))
+ (.replaceAll "\\.\\." "\\.")
+ (.replaceAll "\"\"" "\"")))))
(defn aggregate? [c]
(let [c (if (vector? c) (first c) c)]
View
2  src/clojureql/predicates.clj
@@ -116,7 +116,7 @@
{:keys [stmt env cols]} pred
aggregates (set (map nskeyword (find-aggregates this)))
colnames (set (remove #(.contains % ".")
- (map nskeyword cols)))
+ (map #(escape-name (nskeyword %)) cols)))
qualify? (set/difference colnames aggregates)]
(predicate
(map #(if (qualify? %) (str (to-tablealias (:tname this))
View
8 test/clojureql/test/core.clj
@@ -140,7 +140,13 @@
"SELECT users.id FROM users WHERE ((users.id != 5) AND ((users.id > 10) OR (users.id < 20)))"
(-> (table :users)
(select (where (= :lower/name "bob"))))
- "SELECT users.* FROM users WHERE (lower(name) = bob)"))
+ "SELECT users.* FROM users WHERE (lower(name) = bob)"
+ (-> (table :users)
+ (select (where (= :second-id 5))))
+ "SELECT users.* FROM users WHERE (users.\"second-id\" = 5)"
+ (-> (table :vip-users)
+ (select (where (and (!= :id 5) (> :vip-years 2) (= :second-id 4)))))
+ "SELECT \"vip-users\".* FROM \"vip-users\" WHERE ((\"vip-users\".id != 5) AND (\"vip-users\".\"vip-years\" > 2) AND (\"vip-users\".\"second-id\" = 4))"))
(testing "Nested where predicates"
(are [x y] (= (-> x (compile nil) interpolate-sql) y)
Please sign in to comment.
Something went wrong with that request. Please try again.