File tree Expand file tree Collapse file tree 4 files changed +15
-2
lines changed Expand file tree Collapse file tree 4 files changed +15
-2
lines changed Original file line number Diff line number Diff line change 5
5
pom.xml.asc
6
6
* .jar
7
7
* .class
8
+ * .iml
9
+ /.idea
8
10
/.lein- *
9
11
/.nrepl-port
Original file line number Diff line number Diff line change 7
7
:url " http://github.com/alaisi/postgres.async.git" }
8
8
:dependencies [[org.clojure/clojure " 1.6.0" ]
9
9
[org.clojure/core.async " 0.1.346.0-17112a-alpha" ]
10
- [com.github.alaisi.pgasync/postgres-async-driver " 0.3 " ]]
10
+ [com.github.alaisi.pgasync/postgres-async-driver " 0.4-SNAPSHOT " ]]
11
11
:global-vars {*warn-on-reflection* true }
12
12
:target-path " target/%s" )
Original file line number Diff line number Diff line change 17
17
`(reify Consumer (accept [_# ~param]
18
18
(~@body ))))
19
19
20
+ (defn column->value [^PgRow row ^String col]
21
+ (let [r (.get row col)]
22
+ (if (-> r .getClass .isArray)
23
+ (vec r)
24
+ r)))
25
+
20
26
(defn result->map [^ResultSet result]
21
27
(let [columns (.getColumns result)
22
28
row->map (fn [^PgRow row rowmap ^String col]
23
- (assoc rowmap (keyword (.toLowerCase col)) (.get row col)))]
29
+ (assoc rowmap (keyword (.toLowerCase col)) (column->value row col)))]
24
30
{:updated (.updatedRows result)
25
31
:rows (vec (map (fn [row]
26
32
(reduce (partial row->map row) {} columns))
Original file line number Diff line number Diff line change 38
38
(let [rs (wait (<query! *db* [" select 1 as x" ]))]
39
39
(is (= 1 (get-in rs [0 :x ]))))))
40
40
41
+ (deftest query-for-array
42
+ (testing " arrays are converted to vectors"
43
+ (let [rs (wait (<query! *db* [" select '{1,2}'::INT[] as a" ]))]
44
+ (is (= [1 2 ] (get-in rs [0 :a ]))))))
45
+
41
46
(deftest inserts
42
47
(testing " insert returns row count"
43
48
(let [rs (wait (<insert! *db* {:table table} {:t " x" }))]
You can’t perform that action at this time.
0 commit comments