Skip to content

Commit 2cc1868

Browse files
committed
Fix issue where passing config overrides default options
1 parent f4e82b3 commit 2cc1868

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

lib/algolia.ex

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ defmodule Algolia do
295295
@doc """
296296
Save multiple objects
297297
"""
298-
def save_objects(index, objects, opts \\ [id_attribute: :objectID]) when is_list(objects) do
298+
def save_objects(index, objects, opts \\ []) when is_list(objects) do
299299
{config, opts} = Keyword.pop_lazy(opts, :config, &default_config/0)
300300
id_attribute = opts[:id_attribute] || :objectID
301301

@@ -308,8 +308,12 @@ defmodule Algolia do
308308
@doc """
309309
Partially updates an object, takes option upsert: true or false
310310
"""
311-
def partial_update_object(index, object, object_id, opts \\ [upsert?: true]) do
312-
{config, opts} = Keyword.pop_lazy(opts, :config, &default_config/0)
311+
def partial_update_object(index, object, object_id, opts \\ []) do
312+
{config, opts} =
313+
opts
314+
|> Keyword.put_new(:upsert?, true)
315+
|> Keyword.pop_lazy(:config, &default_config/0)
316+
313317
body = Jason.encode!(object)
314318
path = Paths.partial_object(index, object_id, opts[:upsert?])
315319

@@ -326,8 +330,12 @@ defmodule Algolia do
326330
@doc """
327331
Partially updates multiple objects
328332
"""
329-
def partial_update_objects(index, objects, opts \\ [upsert?: true, id_attribute: :objectID]) do
330-
{config, opts} = Keyword.pop_lazy(opts, :config, &default_config/0)
333+
def partial_update_objects(index, objects, opts \\ []) do
334+
{config, opts} =
335+
opts
336+
|> Keyword.put_new(:upsert?, true)
337+
|> Keyword.pop_lazy(:config, &default_config/0)
338+
331339
id_attribute = opts[:id_attribute] || :objectID
332340

333341
upsert =

0 commit comments

Comments
 (0)