Skip to content

Commit 744d179

Browse files
authored
Merge pull request #20 from queryverse/update
Update to SQLite 1.0
2 parents 6d34745 + aa3bde5 commit 744d179

5 files changed

Lines changed: 21 additions & 8 deletions

File tree

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ DataValues = "0.4.11"
1919
IteratorInterfaceExtensions = "0.1.1, 1"
2020
MacroTools = "0.5"
2121
QueryOperators = "0.9"
22-
SQLite = "0.8.1, 0.9"
22+
SQLite = "1"
2323
TableShowUtils = "0.2.5"
2424
TableTraits = "0.4.1, 1"
2525
julia = "1"

src/QuerySQLite.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import QueryOperators
1515
import Random: randstring
1616
import SQLite
1717
import SQLite: getvalue
18-
using SQLite: columns, DB, execute!, generate_namedtuple, juliatype,
18+
using SQLite: columns, DB, execute, juliatype,
1919
SQLITE_DONE, SQLITE_NULL, SQLITE_ROW, sqlite3_column_count, sqlite3_column_name,
2020
sqlite3_column_type, sqlite3_step, sqlitevalue, Stmt, tables
2121
import Statistics: mean, sum

src/iterate.jl

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
function generate_namedtuple(::Type{NamedTuple{names, types}}, q) where {names, types}
2+
if @generated
3+
vals = Tuple(:(getvalue(q, $i, $(fieldtype(types, i)))) for i = 1:fieldcount(types))
4+
return :(NamedTuple{names, types}(($(vals...),)))
5+
else
6+
return NamedTuple{names, types}(Tuple(getvalue(q, i, fieldtype(types, i)) for i = 1:fieldcount(types)))
7+
end
8+
end
9+
110
# This section of the code hijacks SQLite internals to make queryverse-compatible iterators
211
# TODO: submit as a PR to SQLite
312
struct SQLiteCursor{Row}
@@ -105,7 +114,7 @@ function getiterator(source_code::SourceCode)
105114
string(finalize(translate(source_code.code)))
106115
)
107116
# bind!(statement, values)
108-
status = execute!(statement)
117+
status = execute(statement)
109118
handle = statement.handle
110119
schema = ntuple(
111120
let handle = handle

test/runtests.jl

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ using Dates: Date, DateTime, format, Time
55
using Documenter: doctest
66
using Query
77
using QueryTables
8-
using SQLite: DB, drop!, execute!, Stmt
8+
using SQLite: DB, drop!, execute, Stmt
99
using Statistics: mean
1010
using Test
1111

@@ -103,10 +103,13 @@ end
103103

104104
@testset "Systematic tests" begin
105105

106-
filename = joinpath(@__DIR__, "test.sqlite")
106+
filename = joinpath(@__DIR__, "tmp", "test.sqlite")
107+
isfifo(filename) && rm(filename)
108+
cp(joinpath(@__DIR__, "test.sqlite"), filename)
109+
107110
connection = DB(filename)
108-
execute!(Stmt(connection, """DROP TABLE IF EXISTS test"""))
109-
execute!(Stmt(connection, """
111+
execute(Stmt(connection, """DROP TABLE IF EXISTS test"""))
112+
execute(Stmt(connection, """
110113
CREATE TABLE test (
111114
zero Int,
112115
one Int,
@@ -123,7 +126,7 @@ execute!(Stmt(connection, """
123126
datetime_text Text,
124127
format Text
125128
)"""))
126-
execute!(Stmt(connection, """
129+
execute(Stmt(connection, """
127130
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")
128131
"""))
129132
small = Database(connection)

test/tmp/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*

0 commit comments

Comments
 (0)