File tree Expand file tree Collapse file tree 2 files changed +22
-4
lines changed Expand file tree Collapse file tree 2 files changed +22
-4
lines changed Original file line number Diff line number Diff line change 3939
4040(defmethod ig /init-key :duct.database.sql/hikaricp
4141 [_ {:keys [logger connection-uri jdbc-url] :as options}]
42- (sql/->Boundary {:datasource
43- (-> (dissoc options :logger )
42+ (let [datasource (-> (dissoc options :logger )
4443 (assoc :jdbc-url (or jdbc-url connection-uri))
45- (hikari-cp/make-datasource )
46- (cond-> logger (wrap-logger logger)))}))
44+ (hikari-cp/make-datasource ))]
45+ (if logger
46+ (-> (sql/->Boundary {:datasource (wrap-logger datasource logger)})
47+ (assoc :unlogged-spec {:datasource datasource}))
48+ (sql/->Boundary {:datasource datasource}))))
4749
4850(defmethod ig /halt-key! :duct.database.sql/hikaricp [_ {:keys [spec]}]
4951 (let [ds (unwrap-logger (:datasource spec))]
Original file line number Diff line number Diff line change 7979 (is (not (.isClosed (unwrap-logger (:datasource spec)))))
8080 (ig/halt-key! ::sql/hikaricp hikaricp)
8181 (is (.isClosed (unwrap-logger (:datasource spec))))))
82+
83+ (deftest unlogged-test
84+ (let [logs (atom [])
85+ logger (->AtomLogger logs)
86+ hikaricp (ig/init-key ::sql/hikaricp {:jdbc-url " jdbc:sqlite:" :logger logger})
87+ spec (:unlogged-spec hikaricp)]
88+ (jdbc/execute! spec [" CREATE TABLE foo (id INT, body TEXT)" ])
89+ (jdbc/db-do-commands spec [" INSERT INTO foo VALUES (1, 'a')"
90+ " INSERT INTO foo VALUES (2, 'b')" ])
91+ (is (= (jdbc/query spec [" SELECT * FROM foo" ])
92+ [{:id 1 , :body " a" } {:id 2 , :body " b" }]))
93+ (is (= (jdbc/query spec [" SELECT * FROM foo WHERE id = ?" 1 ])
94+ [{:id 1 , :body " a" }]))
95+ (is (= (jdbc/query spec [" SELECT * FROM foo WHERE id = ? AND body = ?" 1 " a" ])
96+ [{:id 1 , :body " a" }]))
97+ (is (empty? @logs))))
You can’t perform that action at this time.
0 commit comments