Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup DBInterface support #289

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
16 changes: 9 additions & 7 deletions src/dbinterface.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
DBInterface.connect(::Type{Connection}, args...; kws...) = Connection(args...; kws...)

DBInterface.prepare(conn::Connection, args...; kws...) = prepare(conn, args...; kws...)

function DBInterface.execute(conn::Union{Connection,Statement}, args...; kws...)
return execute(conn, args...; kws...)
struct DBConnection <: DBInterface.Connection
conn::Connection
end

DBInterface.close!(conn::Connection) = close(conn)
DBInterface.connect(::Type{Connection}, args...; kws...) = DBConnection(Connection(args...; kws...))

Check warning on line 5 in src/dbinterface.jl

View workflow job for this annotation

GitHub Actions / format

[JuliaFormatter] reported by reviewdog 🐶 Raw Output: src/dbinterface.jl:5:-DBInterface.connect(::Type{Connection}, args...; kws...) = DBConnection(Connection(args...; kws...)) src/dbinterface.jl:6:-DBInterface.prepare(conn::DBConnection, args...; kws...) = prepare(conn.conn, args...; kws...) src/dbinterface.jl:7:-DBInterface.execute(conn::DBConnection, args...; kws...) = execute(conn.conn, args...; kws...) src/dbinterface.jl:8:-DBInterface.execute(conn::DBConnection, str::AbstractString; kws...) = execute(conn.conn, str; kws...) src/dbinterface.jl:9:-DBInterface.execute(conn::DBConnection, str::AbstractString, params; kws...) = execute(conn.conn, str, params; kws...) src/dbinterface.jl:5:+function DBInterface.connect(::Type{Connection}, args...; kws...) src/dbinterface.jl:6:+ return DBConnection(Connection(args...; kws...)) src/dbinterface.jl:7:+end src/dbinterface.jl:8:+function DBInterface.prepare(conn::DBConnection, args...; kws...) src/dbinterface.jl:9:+ return prepare(conn.conn, args...; kws...) src/dbinterface.jl:10:+end src/dbinterface.jl:11:+function DBInterface.execute(conn::DBConnection, args...; kws...) src/dbinterface.jl:12:+ return execute(conn.conn, args...; kws...) src/dbinterface.jl:13:+end src/dbinterface.jl:14:+function DBInterface.execute(conn::DBConnection, str::AbstractString; kws...) src/dbinterface.jl:15:+ return execute(conn.conn, str; kws...) src/dbinterface.jl:16:+end src/dbinterface.jl:17:+function DBInterface.execute(conn::DBConnection, str::AbstractString, params; kws...) src/dbinterface.jl:18:+ return execute(conn.conn, str, params; kws...) src/dbinterface.jl:19:+end
DBInterface.prepare(conn::DBConnection, args...; kws...) = prepare(conn.conn, args...; kws...)
DBInterface.execute(conn::DBConnection, args...; kws...) = execute(conn.conn, args...; kws...)
DBInterface.execute(conn::DBConnection, str::AbstractString; kws...) = execute(conn.conn, str; kws...)
DBInterface.execute(conn::DBConnection, str::AbstractString, params; kws...) = execute(conn.conn, str, params; kws...)
DBInterface.execute(stmt::Statement, args...; kws...) = execute(stmt, args...; kws...)
DBInterface.close!(conn::DBConnection) = close(conn)
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1895,11 +1895,11 @@
close(conn)
end

@testset "DBInterface integration" begin

Check warning on line 1898 in test/runtests.jl

View workflow job for this annotation

GitHub Actions / format

[JuliaFormatter] reported by reviewdog 🐶 Raw Output: test/runtests.jl:1898:- @testset "DBInterface integration" begin test/runtests.jl:1899:- conn = DBInterface.connect(LibPQ.Connection, "dbname=postgres user=$DATABASE_USER") test/runtests.jl:1900:- @test conn isa LibPQ.DBConnection test/runtests.jl:2449:+ ar = async_execute(conn, "SELECT pg_sleep(3); SELECT * FROM pg_type;") test/runtests.jl:2450:+ yield() test/runtests.jl:2451:+ @async Base.throwto( test/runtests.jl:2452:+ ar.result_task, test/runtests.jl:2453:+ Base.IOError("FDWatcher: bad file descriptor (EBADF)", -9), test/runtests.jl:2454:+ ) test/runtests.jl:2455:+ try test/runtests.jl:2456:+ wait(ar) test/runtests.jl:2457:+ @test false test/runtests.jl:2458:+ catch err test/runtests.jl:2459:+ while err isa TaskFailedException test/runtests.jl:2460:+ err = err.task.exception test/runtests.jl:2461:+ end test/runtests.jl:2462:+ @test err isa LibPQ.Errors.JLConnectionError test/runtests.jl:2463:+ end
conn = DBInterface.connect(LibPQ.Connection, "dbname=postgres user=$DATABASE_USER")
@test conn isa LibPQ.Connection
@test conn isa LibPQ.DBConnection

result = DBInterface.execute(

Check warning on line 1902 in test/runtests.jl

View workflow job for this annotation

GitHub Actions / format

[JuliaFormatter] reported by reviewdog 🐶 Raw Output: test/runtests.jl:1902:- result = DBInterface.execute( test/runtests.jl:1903:- conn, test/runtests.jl:1904:- "SELECT typname FROM pg_type WHERE oid = 16"; test/runtests.jl:1905:- ) test/runtests.jl:1906:- @test result isa LibPQ.Result test/runtests.jl:1907:- @test status(result) == LibPQ.libpq_c.PGRES_TUPLES_OK test/runtests.jl:1908:- @test isopen(result) test/runtests.jl:1909:- @test LibPQ.num_columns(result) == 1 test/runtests.jl:1910:- @test LibPQ.num_rows(result) == 1 test/runtests.jl:1911:- @test LibPQ.column_name(result, 1) == "typname" test/runtests.jl:1912:- @test LibPQ.column_number(result, "typname") == 1 test/runtests.jl:1913:- data = columntable(result) test/runtests.jl:1914:- @test data[:typname][1] == "bool" test/runtests.jl:2465:+ close(conn) test/runtests.jl:2466:+ end
conn,
"SELECT typname FROM pg_type WHERE oid = 16";
)
Expand Down
Loading