Skip to content

Commit 95c42a4

Browse files
committed
fix #102
1 parent 6f51a51 commit 95c42a4

File tree

6 files changed

+24
-24
lines changed

6 files changed

+24
-24
lines changed

src/SQLite.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@ show(io::IO,::NullType) = print(io,"#NULL")
2121
# Normal constructor from filename
2222
sqliteopen(file,handle) = sqlite3_open(file,handle)
2323
sqliteopen(file::UTF16String,handle) = sqlite3_open16(file,handle)
24-
sqliteerror() = throw(SQLiteException(bytestring(sqlite3_errmsg())))
25-
sqliteerror(db) = throw(SQLiteException(bytestring(sqlite3_errmsg(db.handle))))
24+
sqliteerror() = throw(SQLiteException(Compat.bytestring(sqlite3_errmsg())))
25+
sqliteerror(db) = throw(SQLiteException(Compat.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::@compat(String)
29+
file::Compat.UTF8String
3030
handle::Ptr{Void}
3131
changes::Int
3232

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

5252
function _close(db::DB)
5353
sqlite3_close_v2(db.handle)
@@ -105,7 +105,7 @@ function bind!{V}(stmt::Stmt, values::Dict{Symbol, V})
105105
nparams = sqlite3_bind_parameter_count(stmt.handle)
106106
@assert nparams == length(values) "you must provide values for all placeholders"
107107
for i in 1:nparams
108-
name = bytestring(sqlite3_bind_parameter_name(stmt.handle, i))
108+
name = Compat.bytestring(sqlite3_bind_parameter_name(stmt.handle, i))
109109
@assert !isempty(name) "nameless parameters should be passed as a Vector"
110110
# name is returned with the ':', '@' or '$' at the start
111111
name = name[2:end]
@@ -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(@compat(String),A))
134+
return bind!(stmt, i, convert(Compat.UTF8String,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::@compat(String)
313+
tablename::Compat.UTF8String
314314
stmt::Stmt
315315
end
316316

src/Source.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ 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(@compat(String),cols)
22+
header = Array(Compat.UTF8String,cols)
2323
types = Array(DataType,cols)
2424
for i = 1:cols
25-
header[i] = bytestring(SQLite.sqlite3_column_name(stmt.handle,i))
25+
header[i] = Compat.bytestring(SQLite.sqlite3_column_name(stmt.handle,i))
2626
# do better column type inference; query what the column was created for?
2727
types[i] = stricttypes ? SQLite.juliatype(stmt.handle,i) : Any
2828
end
@@ -41,13 +41,13 @@ 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 ? @compat(String) : Any
44+
juliatype(x) = x == SQLITE_INTEGER ? Int : x == SQLITE_FLOAT ? Float64 : x == SQLITE_TEXT ? Compat.UTF8String : 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
4848
sqlitevalue{T<:FLOAT_TYPES}(::Type{T},handle,col) = convert(T, sqlite3_column_double(handle,col))
4949
#TODO: test returning a PointerString instead of calling `bytestring`
50-
sqlitevalue{T<:AbstractString}(::Type{T},handle,col) = convert(T,bytestring(sqlite3_column_text(handle,col)))
50+
sqlitevalue{T<:AbstractString}(::Type{T},handle,col) = convert(T,Compat.bytestring(sqlite3_column_text(handle,col)))
5151
function sqlitevalue{T}(::Type{T},handle,col)
5252
blob = convert(Ptr{UInt8},SQLite.sqlite3_column_blob(handle,col))
5353
b = SQLite.sqlite3_column_bytes(handle,col)

src/UDF.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ function sqlvalue(values, i)
33
valuetype = sqlite3_value_type(temp_val_ptr)
44

55
if valuetype == SQLITE_INTEGER
6-
if WORD_SIZE == 64
6+
if Sys.WORD_SIZE == 64
77
return sqlite3_value_int64(temp_val_ptr)
88
else
99
return sqlite3_value_int(temp_val_ptr)
@@ -12,7 +12,7 @@ function sqlvalue(values, i)
1212
return sqlite3_value_double(temp_val_ptr)
1313
elseif valuetype == SQLITE_TEXT
1414
# TODO: have a way to return UTF16
15-
return bytestring(sqlite3_value_text(temp_val_ptr))
15+
return Compat.bytestring(sqlite3_value_text(temp_val_ptr))
1616
elseif valuetype == SQLITE_BLOB
1717
nbytes = sqlite3_value_bytes(temp_val_ptr)
1818
blob = sqlite3_value_blob(temp_val_ptr)

src/old_ui.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ function bind{V}(stmt, values::Dict{Symbol, V})
8989
nparams = sqlite3_bind_parameter_count(stmt.handle)
9090
@assert nparams == length(values) "you must provide values for all placeholders"
9191
for i in 1:nparams
92-
name = bytestring(sqlite3_bind_parameter_name(stmt.handle, i))
92+
name = Compat.bytestring(sqlite3_bind_parameter_name(stmt.handle, i))
9393
@assert !isempty(name) "nameless parameters should be passed as a Vector"
9494
# name is returned with the ':', '@' or '$' at the start
9595
name = name[2:end]
@@ -143,7 +143,7 @@ function query(db::SQLiteDB,sql::AbstractString, values=[])
143143
colnames = Array(AbstractString,ncols)
144144
results = Array(Any,ncols)
145145
for i = 1:ncols
146-
colnames[i] = bytestring(sqlite3_column_name(stmt.handle,i))
146+
colnames[i] = Compat.bytestring(sqlite3_column_name(stmt.handle,i))
147147
results[i] = Any[]
148148
end
149149
while status == SQLITE_ROW
@@ -155,7 +155,7 @@ function query(db::SQLiteDB,sql::AbstractString, values=[])
155155
r = sqlite3_column_double(stmt.handle,i)
156156
elseif t == SQLITE_TEXT
157157
#TODO: have a way to return text16?
158-
r = bytestring( sqlite3_column_text(stmt.handle,i) )
158+
r = Compat.bytestring( sqlite3_column_text(stmt.handle,i) )
159159
elseif t == SQLITE_BLOB
160160
blob = sqlite3_column_blob(stmt.handle,i)
161161
b = sqlite3_column_bytes(stmt.handle,i)

src/show.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#' summary(DataFrame(A = 1:10))
1515
function Base.summary(adf::ResultSet) # -> UTF8String
1616
nrows, ncols = size(adf)
17-
return utf8(@sprintf "%dx%d %s" nrows ncols typeof(adf))
17+
return Compat.utf8(@sprintf "%dx%d %s" nrows ncols typeof(adf))
1818
end
1919

2020
#' @description

test/runtests.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ results = SQLite.query(db,"SELECT * FROM Employee;")
2525
@test length(results.data) == 15
2626
@test size(results) == (8,15)
2727
@test typeof(results[1,1]) == Nullable{Int}
28-
@test typeof(results[1,2]) == Nullable{@compat(String)}
28+
@test typeof(results[1,2]) == Nullable{Compat.UTF8String}
2929
@test isnull(results[1,5])
3030

3131
SQLite.query(db,"SELECT * FROM Album;")
@@ -277,10 +277,10 @@ dt = Data.stream!(source3,Data.Table)
277277

278278
#Make sure we handle undefined values
279279
db = SQLite.DB() #In case the order of tests is changed
280-
arr = Array(@compat(String),2)
280+
arr = Array(Compat.UTF8String,2)
281281
arr[1] = "1" #Now an array with the second value undefined
282282
nv = NullableArrays.NullableArray(arr, [false, true])
283-
schema = DataStreams.Data.Schema(["nv"], [@compat(String)],2)
283+
schema = DataStreams.Data.Schema(["nv"], [Compat.UTF8String],2)
284284
d = NullableArrays.NullableVector[nv]
285285
dt = DataStreams.Data.Table(schema, d,0)
286286
SQLite.drop!(db, "temp", ifexists=true)
@@ -294,10 +294,10 @@ dt2 = SQLite.query(db, "Select * from temp")
294294
#Test removeduplicates!
295295
db = SQLite.DB() #In case the order of tests is changed
296296
ints = Int64[1,1,2,2,3]
297-
strs = @compat(String)["A", "A", "B", "C", "C"]
297+
strs = Compat.UTF8String["A", "A", "B", "C", "C"]
298298
nvInts = NullableArrays.NullableArray(ints)
299299
nvStrs = NullableArrays.NullableArray(strs)
300-
schema = DataStreams.Data.Schema(["ints", "strs"], [Int64, @compat(String)],5)
300+
schema = DataStreams.Data.Schema(["ints", "strs"], [Int64, Compat.UTF8String],5)
301301
d = NullableArrays.NullableVector[nvInts, nvStrs]
302302
dt = DataStreams.Data.Table(schema, d,0)
303303
SQLite.drop!(db, "temp", ifexists=true)

0 commit comments

Comments
 (0)