소스 검색

Set a naming strategy to preserve column name case

Keith R. Gustafson 11 년 전
부모
커밋
647746c9b5
2개의 변경된 파일8개의 추가작업 그리고 4개의 파일을 삭제
  1. 4 2
      compojure/hello/src/hello/handler.clj
  2. 4 2
      luminus/hello/src/hello/models/db.clj

+ 4 - 2
compojure/hello/src/hello/handler.clj

@@ -73,8 +73,10 @@
 (defn get-world-raw []
   (let [id (inc (rand-int 9999))] ; Num between 1 and 10,000
     (jdbc/with-connection (db-raw)
-      (jdbc/with-query-results rs [(str "select * from world where id = ?") id]
-        (doall rs)))))
+      ; Set a naming strategy to preserve column name case
+      (jdbc/with-naming-strategy {:keyword identity}
+        (jdbc/with-query-results rs [(str "select * from world where id = ?") id]
+          (doall rs))))))
 
 ; Run the specified number of queries, return the results
 (defn run-queries-raw [queries]

+ 4 - 2
luminus/hello/src/hello/models/db.clj

@@ -23,8 +23,10 @@
 (defn get-world-raw []
   (let [id (inc (rand-int 9999))] ; Num between 1 and 10,000
     (jdbc/with-connection (db-raw)
-      (jdbc/with-query-results rs [(str "select * from world where id = ?") id]
-        (doall rs)))))
+      ; Set a naming strategy to preserve column name case
+      (jdbc/with-naming-strategy {:keyword identity}
+        (jdbc/with-query-results rs [(str "select * from world where id = ?") id]
+          (doall rs))))))
 
 ; Run the specified number of queries, return the results
 (defn run-queries [queries]