Skip to content

Commit

Permalink
fix: saveObject throwing "data should not be IEnumerable" with JObject
Browse files Browse the repository at this point in the history
[changelog]

fix #654
  • Loading branch information
Ant-hem committed Sep 24, 2019
1 parent 34b68bb commit df6eaf8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/Algolia.Search.Test/EndToEnd/Index/IndexingTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;

namespace Algolia.Search.Test.EndToEnd.Index
{
Expand Down Expand Up @@ -267,12 +268,12 @@ public async Task ClearObjects()
[Parallelizable]
public async Task MoveIndexTest()
{
var objectOne = new AlgoliaStub { ObjectId = "one" };
var objectOne = new JObject { { "objectID", "one" } };
var addObject = await _indexMove.SaveObjectAsync(objectOne);

addObject.Wait();

string indexDestName = TestHelper.GetTestIndexName("move_test_dest");
var indexDestName = TestHelper.GetTestIndexName("move_test_dest");

var move = await BaseTest.SearchClient.MoveIndexAsync(_indexMoveName, indexDestName);
move.Wait();
Expand Down
3 changes: 2 additions & 1 deletion src/Algolia.Search/Clients/SearchIndex.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
using Algolia.Search.Models.Synonyms;
using Algolia.Search.Transport;
using Algolia.Search.Utils;
using Newtonsoft.Json.Linq;
using System;
using System.Collections;
using System.Collections.Generic;
Expand Down Expand Up @@ -150,7 +151,7 @@ internal SearchIndex(HttpTransport transport, AlgoliaConfig config, string index
throw new ArgumentNullException(nameof(data));
}

if (data is IEnumerable)
if (data is IEnumerable && !(data is JObject))
{
throw new ArgumentException($"{nameof(data)} should not be an IEnumerable/List/Collection");
}
Expand Down

0 comments on commit df6eaf8

Please sign in to comment.