Skip to content

Commit

Permalink
Fix issue where passing config overrides default options
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronrenner committed Feb 4, 2022
1 parent f4e82b3 commit 2cc1868
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions lib/algolia.ex
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ defmodule Algolia do
@doc """
Save multiple objects
"""
def save_objects(index, objects, opts \\ [id_attribute: :objectID]) when is_list(objects) do
def save_objects(index, objects, opts \\ []) when is_list(objects) do
{config, opts} = Keyword.pop_lazy(opts, :config, &default_config/0)
id_attribute = opts[:id_attribute] || :objectID

Expand All @@ -308,8 +308,12 @@ defmodule Algolia do
@doc """
Partially updates an object, takes option upsert: true or false
"""
def partial_update_object(index, object, object_id, opts \\ [upsert?: true]) do
{config, opts} = Keyword.pop_lazy(opts, :config, &default_config/0)
def partial_update_object(index, object, object_id, opts \\ []) do
{config, opts} =
opts
|> Keyword.put_new(:upsert?, true)
|> Keyword.pop_lazy(:config, &default_config/0)

body = Jason.encode!(object)
path = Paths.partial_object(index, object_id, opts[:upsert?])

Expand All @@ -326,8 +330,12 @@ defmodule Algolia do
@doc """
Partially updates multiple objects
"""
def partial_update_objects(index, objects, opts \\ [upsert?: true, id_attribute: :objectID]) do
{config, opts} = Keyword.pop_lazy(opts, :config, &default_config/0)
def partial_update_objects(index, objects, opts \\ []) do
{config, opts} =
opts
|> Keyword.put_new(:upsert?, true)
|> Keyword.pop_lazy(:config, &default_config/0)

id_attribute = opts[:id_attribute] || :objectID

upsert =
Expand Down

0 comments on commit 2cc1868

Please sign in to comment.