Skip to content

Commit 45c02cf

Browse files
committed
Test sqlserialize and sqldeserialize more thoroughly.
1 parent e5b2869 commit 45c02cf

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

test/runtests.jl

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,34 @@ r = query(db, "SELECT * FROM temp WHERE AlbumId = 0")
114114
@test r == ResultSet(Any["AlbumId", "Title", "ArtistId"], Any[Any[0], Any["Test Album"], Any[0]])
115115
drop(db, "temp")
116116

117+
binddb = SQLiteDB()
118+
query(binddb, "CREATE TABLE temp (n NULL, i6 INT, f REAL, s TEXT, a BLOB)")
119+
query(binddb, "INSERT INTO temp VALUES (?1, ?2, ?3, ?4, ?5)", Any[NULL, int64(6), 6.4, "some text", b"bytearray"])
120+
r = query(binddb, "SELECT * FROM temp")
121+
for (v, t) in zip(r.values, [SQLite.NullType, Int64, Float64, AbstractString, Vector{UInt8}])
122+
@test isa(v[1], t)
123+
end
124+
query(binddb, "CREATE TABLE blobtest (a BLOB, b BLOB)")
125+
query(binddb, "INSERT INTO blobtest VALUES (?1, ?2)", Any[b"a", b"b"])
126+
query(binddb, "INSERT INTO blobtest VALUES (?1, ?2)", Any[b"a", BigInt(2)])
127+
type Point{T}
128+
x::T
129+
y::T
130+
end
131+
==(a::Point, b::Point) = a.x == b.x && a.y == b.y
132+
p1 = Point(1, 2)
133+
p2 = Point(1.3, 2.4)
134+
query(binddb, "INSERT INTO blobtest VALUES (?1, ?2)", Any[b"a", p1])
135+
query(binddb, "INSERT INTO blobtest VALUES (?1, ?2)", Any[b"a", p2])
136+
r = query(binddb, "SELECT * FROM blobtest")
137+
for v in r.values[1]
138+
@test v == b"a"
139+
end
140+
for (v1, v2) in zip(r.values[2], Any[b"b", BigInt(2), p1, p2])
141+
@test v1 == v2
142+
end
143+
close(binddb)
144+
117145
# I can't be arsed to create a new one using old dictionary syntax
118146
if VERSION > v"0.4.0-"
119147
query(db,"CREATE TABLE temp AS SELECT * FROM Album")

0 commit comments

Comments
 (0)