diff --git a/Project.toml b/Project.toml index 1df5739..48a9614 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "SQLite" uuid = "0aa819cd-b072-5ff4-a722-6bc24af294d9" authors = ["Jacob Quinn ", "JuliaData Contributors"] -version = "1.6.0" +version = "1.6.1" [deps] DBInterface = "a10d1c49-ce27-4219-8d33-6db1a4562965" diff --git a/src/tables.jl b/src/tables.jl index d643a80..633a487 100644 --- a/src/tables.jl +++ b/src/tables.jl @@ -77,7 +77,12 @@ end ) end -function getvalue(q::Query{strict}, col::Int, rownumber::Int, ::Type{T}) where {strict, T} +function getvalue( + q::Query{strict}, + col::Int, + rownumber::Int, + ::Type{T}, +) where {strict,T} rownumber == q.current_rownumber[] || wrongrow(rownumber) handle = _get_stmt_handle(q.stmt) t = C.sqlite3_column_type(handle, col - 1) @@ -144,6 +149,11 @@ function DBInterface.execute( allowduplicates::Bool = false, strict::Bool = false, ) + if isa(params, NamedTuple) && + isempty(setdiff(keys(params), [:strict, :allowduplicates])) + strict = get(params, :strict, false) + allowduplicates = get(params, :allowduplicates, false) + end status = execute(stmt, params) handle = _get_stmt_handle(stmt) cols = C.sqlite3_column_count(handle) @@ -298,7 +308,7 @@ function load!( st = nothing; temp::Bool = false, ifnotexists::Bool = false, - on_conflict::Union{String, Nothing} = nothing, + on_conflict::Union{String,Nothing} = nothing, replace::Bool = false, analyze::Bool = false, ) diff --git a/test/runtests.jl b/test/runtests.jl index 7c460c3..b676e5f 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -222,6 +222,21 @@ end end end + @testset "strict=true || isempty(query)" begin + setup_clean_test_db() do db + empty_query = + DBInterface.execute(db, "SELECT * FROM Employee LIMIT 0") + sch = Tables.schema(empty_query) + @test sch == Tables.Schema(empty_query.names, empty_query.types) + strict_query = + DBInterface.execute(db, "SELECT * FROM Employee"; strict = true) + @test strict_query isa SQLite.Query{true} + sch2 = Tables.schema(strict_query) + @test sch2 == Tables.Schema(strict_query.names, strict_query.types) + @test sch.names == sch2.names + end + end + @testset "empty query has correct schema and return type" begin setup_clean_test_db() do db empty_scheme = DBInterface.execute(