Skip to content

Commit 8a2b362

Browse files
authored
Default params to [] (#715)
This way we have a shorthand: iex> Postgrex.query!(pid, "SELECT NOW()") This also matches MyXQL API.
1 parent 66325e4 commit 8a2b362

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/postgrex.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ defmodule Postgrex do
297297
"""
298298
@spec query(conn, iodata, list, [execute_option]) ::
299299
{:ok, Postgrex.Result.t()} | {:error, Exception.t()}
300-
def query(conn, statement, params, opts \\ []) when is_list(params) do
300+
def query(conn, statement, params \\ [], opts \\ []) when is_list(params) and is_list(opts) do
301301
name = Keyword.get(opts, :cache_statement)
302302

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

0 commit comments

Comments
 (0)