From 8a2b3626d3743c80f62f5739c1208d9d7421bd9c Mon Sep 17 00:00:00 2001 From: Wojtek Mach Date: Wed, 6 Nov 2024 14:32:30 +0100 Subject: [PATCH] Default params to [] (#715) This way we have a shorthand: iex> Postgrex.query!(pid, "SELECT NOW()") This also matches MyXQL API. --- lib/postgrex.ex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/postgrex.ex b/lib/postgrex.ex index 5d3eedef..2da0c960 100644 --- a/lib/postgrex.ex +++ b/lib/postgrex.ex @@ -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 @@ -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