Skip to content

Commit

Permalink
added statement_options for query_pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
cocoa-xu committed Apr 14, 2024
1 parent 28b23f4 commit 6afffbb
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions lib/adbc_connection.ex
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,10 @@ defmodule Adbc.Connection do
the duration of the function. The function may call
native code that consumes the ArrowStream accordingly.
"""
def query_pointer(conn, query, params \\ [], fun)
when (is_binary(query) or is_reference(query)) and is_list(params) and is_function(fun) do
stream(conn, {:query, query, params}, fn stream_ref, rows_affected ->
def query_pointer(conn, query, params \\ [], fun, statement_options \\ [])
when (is_binary(query) or is_reference(query)) and is_list(params) and is_function(fun) and
is_list(statement_options) do
stream(conn, {:query, query, params, statement_options}, fn stream_ref, rows_affected ->
{:ok, fun.(Adbc.Nif.adbc_arrow_array_stream_get_pointer(stream_ref), rows_affected)}
end)
end
Expand Down Expand Up @@ -489,13 +490,6 @@ defmodule Adbc.Connection do
end
end

defp handle_stream({:query, query_or_prepared, params}, conn) do
with {:ok, stmt} <- ensure_statement(conn, query_or_prepared),
:ok <- maybe_bind(stmt, params) do
Adbc.Nif.adbc_statement_execute_query(stmt)
end
end

defp handle_stream({:query, query_or_prepared, params, statement_options}, conn) do
with {:ok, stmt} <- ensure_statement(conn, query_or_prepared, statement_options),
:ok <- maybe_bind(stmt, params) do
Expand All @@ -509,8 +503,6 @@ defmodule Adbc.Connection do
end
end

defp ensure_statement(conn, query, statement_options \\ [])

defp ensure_statement(conn, query, statement_options)
when is_binary(query) and is_list(statement_options),
do: create_statement(conn, query, statement_options)
Expand Down

0 comments on commit 6afffbb

Please sign in to comment.