Skip to content

Commit dab1455

Browse files
authored
Better tracking of prepared statements & other enhancements (#223)
* DBHandle/StmtHandle aliases for Ptr{Cvoid} * specify types for db and name params * export SQLiteException * check[dup]names(): throw SQLiteException rather than error(). Also show the name of the duplicate column. * bind!() relax type constraints * execute/bind(): add params type annotations using types defined in DBInterface in 2.3.0, so the required version is updated * bind! param checks: assert => SQLiteException assert should be used only as internal logic checks * bind!(): fix whitespace * load!(): reduce code duplication * load!(): escape column names upon insert * load!(): cleanup getting existing table info We don't need the special TableInfo structure, in particular if the table does not exist. The current version uses execute(f, db, sql) call to avoid leaving behind prepared statements. Fixes the table existence check (Query always returns NamesTuple). * load!()/createtable!(): remove escaped name param this is confusing and error-prone * tables/indices/columns(): use execute(f, db, sql) so that the statement is closed immediately upon completion * support Bool Julia type (as SQLite INT) * bind!/execute(): support kwargs for param passing update the docstring and add (very) basic tests * DBInterface.execute(): test kwargs for params * track prepared statements in DB object - fixes #211 - closes all prepared statements upon close!(db) - adds SQLite3.finalize_statements!(db) call - execute(db, sql): close the internal prepared statement immediately, don't wait for GC * improve show(DB) test * basic immediate execute test * basic commit/rollback tests * generalize sqlitetype() so Union{T, Missing} is handled automatically. This also fixes "BLOB NOT NULL" case. * sqliteexception(): just the handle is enough we don't need to create DB just to raise an exception * sqliteprepare(): param type annotations * add CI GitHub action ci.yml taken from JSON3.jl
1 parent a826caa commit dab1455

File tree

5 files changed

+472
-181
lines changed

5 files changed

+472
-181
lines changed

.github/workflows/ci.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: CI
2+
on:
3+
pull_request:
4+
branches:
5+
- master
6+
push:
7+
branches:
8+
- master
9+
tags: '*'
10+
jobs:
11+
test:
12+
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
version:
18+
- '1.0'
19+
- '1' # automatically expands to the latest stable 1.x release of Julia
20+
- 'nightly'
21+
os:
22+
- ubuntu-latest
23+
arch:
24+
- x64
25+
include:
26+
- os: windows-latest
27+
version: '1'
28+
arch: x86
29+
steps:
30+
- uses: actions/checkout@v2
31+
- uses: julia-actions/setup-julia@v1
32+
with:
33+
version: ${{ matrix.version }}
34+
arch: ${{ matrix.arch }}
35+
- uses: actions/cache@v1
36+
env:
37+
cache-name: cache-artifacts
38+
with:
39+
path: ~/.julia/artifacts
40+
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
41+
restore-keys: |
42+
${{ runner.os }}-test-${{ env.cache-name }}-
43+
${{ runner.os }}-test-
44+
${{ runner.os }}-
45+
- uses: julia-actions/julia-buildpkg@v1
46+
- uses: julia-actions/julia-runtest@v1
47+
- uses: julia-actions/julia-processcoverage@v1
48+
- uses: codecov/codecov-action@v1
49+
with:
50+
file: lcov.info
51+
docs:
52+
name: Documentation
53+
runs-on: ubuntu-latest
54+
steps:
55+
- uses: actions/checkout@v2
56+
- uses: julia-actions/setup-julia@v1
57+
with:
58+
version: '1'
59+
- run: |
60+
julia --project=docs -e '
61+
using Pkg
62+
Pkg.develop(PackageSpec(path=pwd()))
63+
Pkg.instantiate()'
64+
- run: julia --project=docs docs/make.jl
65+
env:
66+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67+
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ WeakRefStrings = "ea10d353-3f73-51f8-a26c-33c1cb351aa5"
1717

1818
[compat]
1919
BinaryProvider = "0.5"
20-
DBInterface = "2"
20+
DBInterface = "2.3"
2121
SQLite_jll = "3"
2222
Tables = "1"
2323
WeakRefStrings = "0.4,0.5,0.6"

0 commit comments

Comments
 (0)