Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ DataValues = "0.4.11"
IteratorInterfaceExtensions = "0.1.1, 1"
MacroTools = "0.5"
QueryOperators = "0.9"
SQLite = "0.8.1, 0.9"
SQLite = "1"
TableShowUtils = "0.2.5"
TableTraits = "0.4.1, 1"
julia = "1"
Expand Down
2 changes: 1 addition & 1 deletion src/QuerySQLite.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import QueryOperators
import Random: randstring
import SQLite
import SQLite: getvalue
using SQLite: columns, DB, execute!, generate_namedtuple, juliatype,
using SQLite: columns, DB, execute, juliatype,
SQLITE_DONE, SQLITE_NULL, SQLITE_ROW, sqlite3_column_count, sqlite3_column_name,
sqlite3_column_type, sqlite3_step, sqlitevalue, Stmt, tables
import Statistics: mean, sum
Expand Down
11 changes: 10 additions & 1 deletion src/iterate.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
function generate_namedtuple(::Type{NamedTuple{names, types}}, q) where {names, types}
if @generated
vals = Tuple(:(getvalue(q, $i, $(fieldtype(types, i)))) for i = 1:fieldcount(types))
return :(NamedTuple{names, types}(($(vals...),)))
else
return NamedTuple{names, types}(Tuple(getvalue(q, i, fieldtype(types, i)) for i = 1:fieldcount(types)))
end
end

# This section of the code hijacks SQLite internals to make queryverse-compatible iterators
# TODO: submit as a PR to SQLite
struct SQLiteCursor{Row}
Expand Down Expand Up @@ -105,7 +114,7 @@ function getiterator(source_code::SourceCode)
string(finalize(translate(source_code.code)))
)
# bind!(statement, values)
status = execute!(statement)
status = execute(statement)
handle = statement.handle
schema = ntuple(
let handle = handle
Expand Down
13 changes: 8 additions & 5 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ using Dates: Date, DateTime, format, Time
using Documenter: doctest
using Query
using QueryTables
using SQLite: DB, drop!, execute!, Stmt
using SQLite: DB, drop!, execute, Stmt
using Statistics: mean
using Test

Expand Down Expand Up @@ -103,10 +103,13 @@ end

@testset "Systematic tests" begin

filename = joinpath(@__DIR__, "test.sqlite")
filename = joinpath(@__DIR__, "tmp", "test.sqlite")
isfifo(filename) && rm(filename)
cp(joinpath(@__DIR__, "test.sqlite"), filename)

connection = DB(filename)
execute!(Stmt(connection, """DROP TABLE IF EXISTS test"""))
execute!(Stmt(connection, """
execute(Stmt(connection, """DROP TABLE IF EXISTS test"""))
execute(Stmt(connection, """
CREATE TABLE test (
zero Int,
one Int,
Expand All @@ -123,7 +126,7 @@ execute!(Stmt(connection, """
datetime_text Text,
format Text
)"""))
execute!(Stmt(connection, """
execute(Stmt(connection, """
INSERT INTO test VALUES(0, 1, -1, "ab", NULL, 65, "a", "b", " a ", "_a_", "a%", 1.11, "2019-12-08T11:09:00", "%Y-%m-%d %H:%M:%S")
"""))
small = Database(connection)
Expand Down
1 change: 1 addition & 0 deletions test/tmp/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*