Skip to content

Commit f211e7f

Browse files
committed
Merge pull request #89 from amellnik/master
Handle NullableArrays with missing, undefined vals
2 parents 29de2b6 + a408335 commit f211e7f

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

src/Sink.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,11 @@ end
3434
# create a new SQLite table
3535
# Data.Table
3636
function getbind!{T}(dt::NullableVector{T},row,col,stmt)
37-
@inbounds val, isnull = dt.values[row]::T, dt.isnull[row]
37+
@inbounds isnull = dt.isnull[row]
3838
if isnull
3939
SQLite.bind!(stmt,col,NULL)
4040
else
41+
@inbounds val = dt.values[row]::T
4142
SQLite.bind!(stmt,col,val)
4243
end
4344
return

test/Chinook_Sqlite.sqlite

-60 KB
Binary file not shown.

test/runtests.jl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,3 +274,19 @@ dt = Data.stream!(source3,Data.Table)
274274
@test get(dt[1,1]) == 1
275275
@test string(get(dt[1,2])) == "For Those About To Rock We Salute You"
276276
@test get(dt[1,3]) == 1
277+
278+
#Make sure we handle undefined values
279+
db = SQLite.DB() #In case the order of tests is changed
280+
arr = Array(UTF8String,2)
281+
arr[1] = "1" #Now an array with the second value undefined
282+
nv = NullableArrays.NullableArray(arr, [false, true])
283+
schema = DataStreams.Data.Schema(["nv"], [UTF8String],2)
284+
d = NullableArrays.NullableVector[nv]
285+
dt = DataStreams.Data.Table(schema, d,0)
286+
SQLite.drop!(db, "temp", ifexists=true)
287+
sink = SQLite.Sink(dt, db, "temp")
288+
Data.stream!(dt, sink)
289+
dt2 = SQLite.query(db, "Select * from temp")
290+
#There might be a better way to check this
291+
@test dt.data[1][1].value==dt2.data[1][1].value
292+
@test dt.data[1][2].isnull==dt2.data[1][2].isnull

0 commit comments

Comments
 (0)