Skip to content

Commit 02a6d82

Browse files
committed
Add async_execute with SQLStrings.Sql
1 parent f628057 commit 02a6d82

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

src/asyncresults.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,15 @@ function _multi_async_execute(jl_conn::Connection, query::AbstractString; kwargs
236236
return async_result
237237
end
238238

239+
function async_execute(
240+
jl_conn::Connection,
241+
query::SQLStrings.Sql;
242+
kwargs...
243+
)
244+
query_str, parameters = SQLStrings.prepare(query)
245+
async_execute(jl_conn, query_str, parameters; kwargs...)
246+
end
247+
239248
function async_execute(
240249
jl_conn::Connection,
241250
query::AbstractString,

src/results.jl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -301,12 +301,11 @@ end
301301

302302
function execute(
303303
jl_conn::Connection,
304-
sql::SQLStrings.Sql;
305-
throw_error::Bool=true,
304+
query::SQLStrings.Sql;
306305
kwargs...
307306
)
308-
query, parameters = SQLStrings.prepare(sql)
309-
execute(jl_conn, query, parameters; throw_error=throw_error, kwargs...)
307+
query_str, parameters = SQLStrings.prepare(query)
308+
execute(jl_conn, query_str, parameters; kwargs...)
310309
end
311310

312311
function execute(

test/runtests.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1548,6 +1548,11 @@ end
15481548
bar_id = 3
15491549
result = execute(conn, sql`SELECT * from libpq_test_users where id = $bar_id`)
15501550
@test first(result).name == "Bar"
1551+
1552+
# Async with SqlStrings
1553+
ar = async_execute(conn, sql`SELECT * from libpq_test_users where id = 1`)
1554+
result = fetch(ar)
1555+
@test first(result).name == "Foo"
15511556
end
15521557

15531558
@testset "Query Errors" begin

0 commit comments

Comments
 (0)