Why does this Patch request C# code create an array value = [1] when JavaScript patch creates an int = 1?

61 views
Skip to first unread message

Michael Hanney

unread,
Feb 27, 2015, 3:40:08 PM2/27/15
to rav...@googlegroups.com
I executed the following UpdateByIndex command expecting my documents to have a new property added with Name = HighLevelAnalysisModelsVersion and Value = 1. A pretty simple request. But the property was created with the value [1] , which does not deserialize to the C# model. Since the data does not deserialize my application has become completely dysfunctional.

I had to rescue my data by running a new patch request in the web studio UI to delete the property, and then re-add it. The javascript was more reliable, but took hours.

I am using build #3599, licensed.

Here is the C# used to to the patch.

 private static void Patch()
 
{
     
var store = container.Resolve<IDocumentStore>();
     store
.DatabaseCommands.UpdateByIndex("AssetsIndex", new IndexQuery(), new[]
     
{
         
new PatchRequest
         
{
             
Type = PatchCommandType.Add, Name = "HighLevelAnalysisModelsVersion", Value = 1
         
}
     
});
}

The index definition

public class AssetsIndex : AbstractIndexCreationTask<AudioAsset>
   
{
       
public class Result
       
{
           
public bool HasLowLevelAnalysis { get; set; }
           
public bool HasHighLevelAnalysis { get; set; }
       
}

       
public AssetsIndex()
       
{
           
Map = assets => from asset in assets

                           
select new Result
                           
{
                               
HasLowLevelAnalysis = !String.IsNullOrEmpty(asset.LowLevelAnalysis),
                               
HasHighLevelAnalysis = !String.IsNullOrEmpty(asset.HighLevelAnalysis)
                           
};
       
}
   
}

the model with the property added (nullable int)

public class AudioAsset
{
   
public string LowLevelAnalysis { get; set; }    
   
public string HighLevelAnalysis { get; set; }    
   
public int? HighLevelAnalysisModelsVersion { get; set; }
}


This is the javascript I had to use to remove the property (then waited 4 hours for re-indexing):

delete this.HighLevelAnalysisModelsVersion;

and the javascript I used to add the property again, which eventually worked (took 4 hours to re-index):

this.HighLevelAnalysisModelsVersion = 1;

Please explain what is wrong in my expectation, and do not ask me to submit a failing test, or steps to repo, unless you are willing to pay me to do so. Having to delete and re-add 1 property on 200,000 docs (each around 75K) took 8 hours to re-index (on a Dell 2900 with 8 cores and 6GB of ram, 15,000 rpm data disk) - so about a day of wasted billable time for my company.

I am quite cross. Again. I have recently come off a project where I regularly used BCP to move 200 million docs in and out of SQL server in about 45 minutes. Can RavenDB really not manage to successfully patch just 200 thousand docs in less than 8 hours? I'm struggling to find the value in no sql here. I cannot believe you charge money for this and basically ask your user base to do the QA & beta testing for you upon each "stable" release. 


Oren Eini (Ayende Rahien)

unread,
Feb 27, 2015, 3:43:45 PM2/27/15
to ravendb
/// <summary>
/// Add an item to an array
/// </summary>
PatchCommandType
.Add 

You need to use Set, instead.

Hibernating Rhinos Ltd  

Oren Eini l CEO Mobile: + 972-52-548-6969

Office: +972-4-622-7811 l Fax: +972-153-4-622-7811

 


--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages