Set PATCH operation with empty array

63 views
Skip to first unread message

Korayem

unread,
Mar 7, 2012, 11:00:42 AM3/7/12
to rav...@googlegroups.com
I am trying to PATCH an documents in an index with an empty array

[{Type: Set,Name: 'NewProperty',Value: {} }]

I am getting "Error": "System.InvalidCastException: Unable to cast object of type 'Raven.Json.Linq.RavenJObject' to type 'Raven.Json.Linq.RavenJValue'.\

I also tried [{Type: Set,Name: 'NewProperty',Value: [] }]

Any ideas? do I have to patch using C# instead of API?

Oren Eini (Ayende Rahien)

unread,
Mar 7, 2012, 1:39:58 PM3/7/12
to rav...@googlegroups.com
Can you try producing a full failing test?

Korayem

unread,
Mar 8, 2012, 6:51:12 AM3/8/12
to rav...@googlegroups.com
Err...

You can just try it on RavenDb 701. Just curl a patch on ANY column setting its value to an array with either [] or {} and it won't work.

Oren Eini (Ayende Rahien)

unread,
Mar 11, 2012, 8:49:15 AM3/11/12
to rav...@googlegroups.com
These two tests passes:

[Fact]
public void AddingEmptyArray()
{
var patchedDoc = new JsonPatcher(doc).Apply(
new[]
{
new PatchRequest
{
Type = PatchCommandType.Set,
Name = "NewProp",
Value = new RavenJArray()

}
});

Assert.Equal(@"{""title"":""A Blog Post"",""body"":""html markup"",""comments"":[{""author"":""ayende"",""text"":""good post 1""},{""author"":""ayende"",""text"":""good post 2""}],""NewProp"":[]}",
patchedDoc.ToString(Formatting.None));
}

[Fact]
public void AddingEmptyObject()
{
var patchedDoc = new JsonPatcher(doc).Apply(
new[]
{
new PatchRequest
{
Type = PatchCommandType.Set,
Name = "NewProp",
Value = new RavenJObject()

}
});

Assert.Equal(@"{""title"":""A Blog Post"",""body"":""html markup"",""comments"":[{""author"":""ayende"",""text"":""good post 1""},{""author"":""ayende"",""text"":""good post 2""}],""NewProp"":{}}",
patchedDoc.ToString(Formatting.None));
}



Can you try providing a failing test?

On Wed, Mar 7, 2012 at 6:00 PM, Korayem <kora...@gmail.com> wrote:

Mohamed Salem Korayem

unread,
Mar 11, 2012, 2:58:09 PM3/11/12
to rav...@googlegroups.com
I was using fiddler for the matter to construct a PATCH request.

I will do it using C# code instead of an HTTP request.

Sorry for the trouble mate


Reply all
Reply to author
Forward
0 new messages