File tree 4 files changed +20
-0
lines changed 4 files changed +20
-0
lines changed Original file line number Diff line number Diff line change 98
98
(when-let [conn (get old connection)]
99
99
(.close ^java.lang.AutoCloseable conn))))
100
100
101
+ (defn prepare
102
+ ([conn statement] (prepare conn statement nil ))
103
+ ([conn statement opts]
104
+ (jdbc/prepare conn statement opts)))
105
+
101
106
(def transact @#'t /transact* )
102
107
103
108
(defn transaction-begin
Original file line number Diff line number Diff line change 25
25
(is (= [#:FOO{:FOO 1 } #:FOO{:FOO 2 } #:FOO{:FOO 3 }]
26
26
(db/execute! conn [" select * from foo;" ])))
27
27
(db/close-connection conn)))
28
+ (testing " prepared statements"
29
+ (let [conn (db/get-connection db)]
30
+ (with-open [ps (db/prepare conn [" select * from foo where foo = ?" 1 ])]
31
+ (let [result (db/execute-one! ps)]
32
+ (is (= result #:foo{:foo 1 }))))))
28
33
(testing " transaction"
29
34
(let [conn (db/get-connection db)]
30
35
(transaction/begin conn)
Original file line number Diff line number Diff line change 53
53
(is (= [#:foo{:foo 1 } #:foo{:foo 2 } #:foo{:foo 3 }]
54
54
(db/execute! conn [" select * from foo;" ])))
55
55
(db/close-connection conn)))
56
+ (testing " prepared statements"
57
+ (let [conn (db/get-connection db)]
58
+ (with-open [ps (db/prepare conn [" select * from foo where foo = ?" 1 ])]
59
+ (let [result (db/execute-one! ps)]
60
+ (is (= result #:foo{:foo 1 }))))))
56
61
(testing " input parameters"
57
62
(try (db/execute! db [" drop table foo_timed;" ])
58
63
(catch Exception _ nil ))
Original file line number Diff line number Diff line change 46
46
(db/execute! x [" insert into foo_timed values (?, ?)" 1 start-date])
47
47
(let [result (db/execute! x [" select foo from foo_timed where created <= ?" start-date])]
48
48
(is (= result [{:foo_timed/foo 1 }]))))))
49
+ (testing " prepared statements"
50
+ (let [conn (db/get-connection db)]
51
+ (with-open [ps (db/prepare conn [" select * from foo where foo = ?" 1 ])]
52
+ (let [result (db/execute-one! ps)]
53
+ (is (= result #:foo{:foo 1 }))))))
49
54
(testing " transaction"
50
55
(let [conn (db/get-connection db)]
51
56
(transaction/begin conn)
You can’t perform that action at this time.
0 commit comments