Skip to content

Commit d5fb3da

Browse files
committed
Fix #1497: UpdateDescriptor not properly serializing fields when using expressions
1 parent 4f8a62c commit d5fb3da

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

Diff for: src/Nest/DSL/UpdateDescriptor.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ public UpdateDescriptor<TDocument,TPartialDocument> Fields(params Expression<Fun
202202
if (!typedPathLookups.HasAny())
203203
return this;
204204

205-
this.Request.RequestParameters.AddQueryString("fields",typedPathLookups);
205+
this.Request.RequestParameters.AddQueryString("fields",typedPathLookups.Select(e => (PropertyPathMarker)e).ToList());
206206
return this;
207207
}
208208

Diff for: src/Tests/Nest.Tests.Unit/Nest.Tests.Unit.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,7 @@
423423
<Compile Include="Reproduce\Reproduce1199Tests.cs" />
424424
<Compile Include="Reproduce\Reproduce1146Tests.cs" />
425425
<Compile Include="Reproduce\Reproduce1440Tests.cs" />
426+
<Compile Include="Reproduce\Reproduce1497Tests.cs" />
426427
<Compile Include="Reproduce\Reproduce1528Tests.cs" />
427428
<Compile Include="Reproduce\Reproduce1464Tests.cs" />
428429
<Compile Include="Reproduce\Reproduce629Tests.cs" />
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using NUnit.Framework;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
using FluentAssertions;
8+
using Nest.Tests.MockData.Domain;
9+
10+
namespace Nest.Tests.Unit.Reproduce
11+
{
12+
[TestFixture]
13+
public class Reproduce1497Tests : BaseJsonTests
14+
{
15+
[Test]
16+
public void UpdateDescriptorFieldsExpressionSerialization()
17+
{
18+
var update = this._client.Update<ElasticsearchProject>(u => u
19+
.Id(1)
20+
.Fields(p => p.Name, p => p.Id)
21+
);
22+
update.ConnectionStatus.RequestUrl.Should().EndWith("fields=name%2Cid");
23+
}
24+
}
25+
}

0 commit comments

Comments
 (0)