Skip to content

Commit 198468b

Browse files
committed
0.5 Compat
1 parent bd9ba73 commit 198468b

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

src/SQLite.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ sqliteerror(db) = throw(SQLiteException(bytestring(sqlite3_errmsg(db.handle))))
2626

2727
"represents an SQLite database, either backed by an on-disk file or in-memory"
2828
type DB
29-
file::UTF8String
29+
file::@compat(String)
3030
handle::Ptr{Void}
3131
changes::Int
3232

33-
function DB(f::UTF8String)
33+
function DB(f::@compat(String))
3434
handle = Ref{Ptr{Void}}()
3535
f = isempty(f) ? f : expanduser(f)
3636
if @OK sqliteopen(f,handle)
@@ -45,7 +45,7 @@ type DB
4545
end
4646
end
4747
"`SQLite.DB(file::AbstractString)` opens or creates an SQLite database with `file`"
48-
DB(f::AbstractString) = DB(utf8(f))
48+
DB(f::AbstractString) = DB(f)
4949
"`SQLite.DB()` creates an in-memory SQLite database"
5050
DB() = DB(":memory:")
5151

@@ -79,7 +79,7 @@ function _close(stmt::Stmt)
7979
return
8080
end
8181

82-
sqliteprepare(db,sql,stmt,null) = @CHECK db sqlite3_prepare_v2(db.handle,utf8(sql),stmt,null)
82+
sqliteprepare(db,sql,stmt,null) = @CHECK db sqlite3_prepare_v2(db.handle,sql,stmt,null)
8383

8484
# TO DEPRECATE
8585
type SQLiteDB{T<:AbstractString}
@@ -131,7 +131,7 @@ bind!(stmt::Stmt,i::Int,val::PointerString{UInt16}) = (sqlite3_bind_text16(stmt
131131
bind!(stmt::Stmt,i::Int,val::UTF16String) = (sqlite3_bind_text16(stmt.handle,i,val); return nothing)
132132
function bind!(stmt::Stmt,i::Int,val::PointerString{UInt32})
133133
A = UTF32String(pointer_to_array(val.ptr, val.len+1, false))
134-
return bind!(stmt, i, convert(UTF8String,A))
134+
return bind!(stmt, i, convert(@compat(String),A))
135135
end
136136
# We may want to track the new ByteVec type proposed at https://github.com/JuliaLang/julia/pull/8964
137137
# as the "official" bytes type instead of Vector{UInt8}
@@ -310,7 +310,7 @@ end
310310
type Sink <: Data.Sink # <: IO
311311
schema::Data.Schema
312312
db::DB
313-
tablename::UTF8String
313+
tablename::@compat(String)
314314
stmt::Stmt
315315
end
316316

src/Sink.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function Sink(schema::Data.Schema,db::DB,tablename::AbstractString="julia_"*rand
1919
SQLite.execute!(db,"CREATE $temp TABLE $ifnotexists $(esc_id(tablename)) ($(join(columns,',')))")
2020
params = chop(repeat("?,",cols))
2121
stmt = SQLite.Stmt(db,"INSERT INTO $(esc_id(tablename)) VALUES ($params)")
22-
return Sink(schema,db,utf8(tablename),stmt)
22+
return Sink(schema,db,tablename,stmt)
2323
end
2424

2525
"constructs a new SQLite.Sink from the given `SQLite.Source`; uses `source` schema to create the SQLite table"

src/Source.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function Source(db::DB, sql::AbstractString, values=[]; rows::Int=0, stricttypes
1919
bind!(stmt, values)
2020
status = SQLite.execute!(stmt)
2121
cols = SQLite.sqlite3_column_count(stmt.handle)
22-
header = Array(UTF8String,cols)
22+
header = Array(@compat(String),cols)
2323
types = Array(DataType,cols)
2424
for i = 1:cols
2525
header[i] = bytestring(SQLite.sqlite3_column_name(stmt.handle,i))
@@ -41,7 +41,7 @@ function juliatype(handle,col)
4141
return juliatype(x)
4242
end
4343
end
44-
juliatype(x) = x == SQLITE_INTEGER ? Int : x == SQLITE_FLOAT ? Float64 : x == SQLITE_TEXT ? UTF8String : Any
44+
juliatype(x) = x == SQLITE_INTEGER ? Int : x == SQLITE_FLOAT ? Float64 : x == SQLITE_TEXT ? @compat(String) : Any
4545

4646
sqlitevalue{T<:Union{Signed,Unsigned}}(::Type{T},handle,col) = convert(T, sqlite3_column_int64(handle,col))
4747
const FLOAT_TYPES = Union{Float16,Float32,Float64} # exclude BigFloat

src/api.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ end
6666
function sqlite3_bind_parameter_index(stmt::Ptr{Void},value::AbstractString)
6767
return ccall( (:sqlite3_bind_parameter_index, sqlite3_lib),
6868
Cint, (Ptr{Void},Ptr{UInt8}),
69-
stmt,utf8(value))
69+
stmt,value)
7070
end
7171
# SQLITE_API int sqlite3_bind_double(sqlite3_stmt*, int, double);
7272
function sqlite3_bind_double(stmt::Ptr{Void},col::Int,value::Float64)

0 commit comments

Comments
 (0)