From 6f126650fab06ee8086ceda21ff4423036c06bf4 Mon Sep 17 00:00:00 2001 From: Jacob Quinn Date: Tue, 19 Oct 2021 22:58:51 -0600 Subject: [PATCH] Convert NULL type columns to Julia Missing type Takes the work of @TacHawkes and fixes the failing test. --- src/SQLite.jl | 1 + test/runtests.jl | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/SQLite.jl b/src/SQLite.jl index 022df3d..445ccd3 100644 --- a/src/SQLite.jl +++ b/src/SQLite.jl @@ -372,6 +372,7 @@ juliatype(x::Integer) = x == SQLITE_INTEGER ? Int64 : x == SQLITE_FLOAT ? Float64 : x == SQLITE_TEXT ? String : + x == SQLITE_NULL ? Missing : Any # convert SQLite declared type into Julia equivalent, diff --git a/test/runtests.jl b/test/runtests.jl index 799adc4..05d9aed 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -104,7 +104,7 @@ end empty_tbl = DBInterface.execute(columntable, db, "SELECT * FROM Employee WHERE FirstName='Joanne'") all_tbl = DBInterface.execute(columntable, db, "SELECT * FROM Employee") @test propertynames(empty_tbl) == propertynames(all_tbl) - @test all(col -> eltype(empty_tbl[col]) >: eltype(all_tbl[col]), propertynames(all_tbl)) + @test all(col -> eltype(empty_tbl[col]) == Missing || eltype(empty_tbl[col]) >: eltype(all_tbl[col]), propertynames(all_tbl)) end DBInterface.execute(db, "create table temp as select * from album")