Skip to content

Commit 7b13fbc

Browse files
committed
Change Serialization to immutable, also a few Uint8s to UInt8s
1 parent fc6557d commit 7b13fbc

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/SQLite.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const NULL = NullType()
2222
Base.show(io::IO,::NullType) = print(io,"NULL")
2323

2424
# internal wrapper type to, in-effect, mark something which has been serialized
25-
type Serialization
25+
immutable Serialization
2626
object
2727
end
2828

@@ -142,6 +142,8 @@ Base.bind(stmt::SQLiteStmt,i::Int,val::Int64) = @CHECK stmt.db sqlite3_
142142
Base.bind(stmt::SQLiteStmt,i::Int,val::NullType) = @CHECK stmt.db sqlite3_bind_null(stmt.handle,i)
143143
Base.bind(stmt::SQLiteStmt,i::Int,val::AbstractString) = @CHECK stmt.db sqlite3_bind_text(stmt.handle,i,val)
144144
Base.bind(stmt::SQLiteStmt,i::Int,val::UTF16String) = @CHECK stmt.db sqlite3_bind_text16(stmt.handle,i,val)
145+
# We may want to track the new ByteVec type proposed at https://github.com/JuliaLang/julia/pull/8964
146+
# as the "official" bytes type instead of Vector{UInt8}
145147
Base.bind(stmt::SQLiteStmt,i::Int,val::Vector{UInt8}) = @CHECK stmt.db sqlite3_bind_blob(stmt.handle,i,val)
146148
# Fallback is BLOB and defaults to serializing the julia value
147149
function sqlserialize(x)
@@ -219,8 +221,8 @@ function query(db::SQLiteDB,sql::AbstractString, values=[])
219221
elseif t == SQLITE_BLOB
220222
blob = sqlite3_column_blob(stmt.handle,i-1)
221223
b = sqlite3_column_bytes(stmt.handle,i-1)
222-
buf = zeros(Uint8,b)
223-
unsafe_copy!(pointer(buf), convert(Ptr{Uint8},blob), b)
224+
buf = zeros(UInt8,b)
225+
unsafe_copy!(pointer(buf), convert(Ptr{UInt8},blob), b)
224226
r = sqldeserialize(buf)
225227
else
226228
r = NULL

0 commit comments

Comments
 (0)