Skip to content

Commit

Permalink
Default params to []
Browse files Browse the repository at this point in the history
This way we have a shorthand:

    iex> Postgrex.query!(pid, "SELECT NOW()")

This also matches MyXQL API.
  • Loading branch information
wojtekmach committed Nov 6, 2024
1 parent 66325e4 commit 7a180c4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/postgrex.ex
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ defmodule Postgrex do
"""
@spec query(conn, iodata, list, [execute_option]) ::
{:ok, Postgrex.Result.t()} | {:error, Exception.t()}
def query(conn, statement, params, opts \\ []) when is_list(params) do
def query(conn, statement, params \\ [], opts \\ []) when is_list(params) and is_list(opts) do
name = Keyword.get(opts, :cache_statement)

if comment_not_present!(opts) && name do
Expand Down Expand Up @@ -349,7 +349,7 @@ defmodule Postgrex do
there was an error. See `query/3`.
"""
@spec query!(conn, iodata, list, [execute_option]) :: Postgrex.Result.t()
def query!(conn, statement, params, opts \\ []) when is_list(params) do
def query!(conn, statement, params \\ [], opts \\ []) when is_list(params) and is_list(opts) do
case query(conn, statement, params, opts) do
{:ok, result} -> result
{:error, err} -> raise err
Expand Down

0 comments on commit 7a180c4

Please sign in to comment.