Skip to content

Commit

Permalink
Update go-sqlite3 to 1.14.16 (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
hangyas authored Aug 22, 2023
1 parent dcc850d commit 529e899
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.15
require (
github.com/google/uuid v1.3.0 // indirect
github.com/jackpal/bencode-go v1.0.0
github.com/mattn/go-sqlite3 v1.14.11
github.com/mattn/go-sqlite3 v1.14.16
github.com/pborman/uuid v1.2.1 // indirect
github.com/russolsen/ohyeah v0.0.0-20160324131710-f4938c005315 // indirect
github.com/russolsen/same v0.0.0-20160222130632-f089df61f51d // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ github.com/jackpal/bencode-go v1.0.0 h1:lzbSPPqqSfWQnqVNe/BBY1NXdDpncArxShL10+fm
github.com/jackpal/bencode-go v1.0.0/go.mod h1:5FSBQ74yhCl5oQ+QxRPYzWMONFnxbL68/23eezsBI5c=
github.com/mattn/go-sqlite3 v1.14.11 h1:gt+cp9c0XGqe9S/wAHTL3n/7MqY+siPWgWJgqdsFrzQ=
github.com/mattn/go-sqlite3 v1.14.11/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y=
github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
github.com/pborman/uuid v1.2.1 h1:+ZZIw58t/ozdjRaXh/3awHfmWRbzYxJoAdNJxe/3pvw=
github.com/pborman/uuid v1.2.1/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=
github.com/russolsen/ohyeah v0.0.0-20160324131710-f4938c005315 h1:H3hCXwP92pH/hSgNrCLtjxvsKJ50sq26nICbZuoR1tQ=
Expand Down
13 changes: 9 additions & 4 deletions test/script.clj
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@

(.delete (io/file "/tmp/foo.db"))

(prn (sqlite/execute! "/tmp/foo.db" ["create table if not exists foo (the_text TEXT, the_int INTEGER, the_real REAL, the_blob BLOB)"]))
(prn (sqlite/execute! "/tmp/foo.db" ["create table if not exists foo (the_text TEXT, the_int INTEGER, the_real REAL, the_blob BLOB, the_json JSON)"]))
(prn (sqlite/execute! "/tmp/foo.db" ["delete from foo"]))

(def png (java.nio.file.Files/readAllBytes (.toPath (io/file "resources/babashka.png"))))

(prn (sqlite/execute! "/tmp/foo.db" ["insert into foo (the_text, the_int, the_real, the_blob) values (?,?,?,?)" "foo" 1 3.14 png]))
(prn (sqlite/execute! "/tmp/foo.db" ["insert into foo (the_text, the_int, the_real, the_blob, the_json) values (?,?,?,?,?)" "foo" 1 3.14 png "{\"bar\": \"hello\"}"]))
(prn (sqlite/execute! "/tmp/foo.db" ["insert into foo (the_text, the_int, the_real) values (?,?,?)" "foo" 2 1.5]))

(testing "multiple results"
Expand All @@ -27,7 +27,7 @@

(def results (sqlite/query "/tmp/foo.db" ["select * from foo order by the_int asc"]))

(def results-min-png (mapv #(dissoc % :the_blob) results))
(def results-min-png (mapv #(dissoc % :the_blob :the_json) results))

(def expected [{:the_int 1, :the_real 3.14, :the_text "foo"}
{:the_int 2, :the_real 1.5, :the_text "foo"}
Expand All @@ -39,14 +39,19 @@

(def direct-results (sqlite/query "/tmp/foo.db" "select * from foo order by the_int asc"))

(def direct-results-min-png (mapv #(dissoc % :the_blob) direct-results))
(def direct-results-min-png (mapv #(dissoc % :the_blob :the_json) direct-results))

(deftest direct-results-test
(is (= expected direct-results-min-png)))

(deftest bytes-roundtrip
(is (= (count png) (count (get-in results [0 :the_blob])))))

(def json-field-result (sqlite/query "/tmp/foo.db" ["select the_json->>'$.bar' as bar from foo where the_json is not null"]))

(deftest json-field-test
(is (= [{:bar "hello"}] json-field-result)))

(deftest error-test
(is (thrown-with-msg?
Exception #"no such column: non_existing"
Expand Down

0 comments on commit 529e899

Please sign in to comment.