Uploaded image for project: 'Couchbase .NET client library'
  1. Couchbase .NET client library
  2. NCBC-2217

Deserialization issues with GetAsync<T>

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Cannot Reproduce
    • 3.0.0-beta.1
    • 3.0.0
    • library
    • None
    • .Net Core 3.0.1
    • 1

    Description

      I'm noticing some odd behavior when trying to do GetAsync<T> where T is a class I've specified. I would have expected that GetAsync<T> would have returned the document I've inserted, but it appears that it's returning the document within a document, with a field name of "". 

       

      Here's some sample code illustrating the issue, plus a workaround: 

       

      var connString = "couchbase://10.0.0.220";
                  var options = new ClusterOptions();            options.WithBucket("bugtest")            .WithCredentials("Administrator", "danger")            .WithServers(connString);
                  var cluster = new Cluster(connString, options);
                  var bucketResult = cluster.BucketAsync("bugtest");
                  bucketResult.Wait();
                  var collection = bucketResult.Result.DefaultCollection();
                  var testData = new TestData()            {                StringTest = "test",                IntTest = Int32.MaxValue,                DictTest = new Dictionary<string, int>(){                    {"key1", 1},                    {"key2", 2},                    {"key3", 3}                }            };
                  var key = "test:mydoc";
                  collection.InsertAsync(key, testData);
                  var getResult = collection.GetAsync(key, options =>            {            });
                  getResult.Wait();
                  var r = getResult.Result;            var badResult = r.ContentAs<TestData>(); // this should return the object we inserted, but it does not            /*
                      It looks like it's returning a document that looks like this: 
                      {"" : {<the actual document content>}}
                  */
                  //this is the workaround for Get
                  var correctResult = (JToken)(r.ContentAs<dynamic>()[""]);
                  var cr = (TestData)correctResult.ToObject(typeof(TestData)); //this returns what I would have expected.
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          jmorris Jeff Morris added a comment -

          Alex Cavnar -

          Thanks, for the bug report! I see this is beta1, have you tried to recreate in beta2?

          -Jeff

          jmorris Jeff Morris added a comment - Alex Cavnar - Thanks, for the bug report! I see this is beta1, have you tried to recreate in beta2? -Jeff
          alexcavnar Alex Cavnar added a comment -

          Hi there, 

          I haven't-- I reported NCBC-2216 on beta2, which kept me from attempting to replicate. Sorry! 

          alexcavnar Alex Cavnar added a comment - Hi there,  I haven't-- I reported NCBC-2216 on beta2, which kept me from attempting to replicate. Sorry! 

          This works against the current master, I've added a regression test in http://review.couchbase.org/#/c/123716/

          daschl Michael Nitschinger added a comment - This works against the current master, I've added a regression test in http://review.couchbase.org/#/c/123716/

          Added integration test, not seeing it anymore on 3.0.0

          daschl Michael Nitschinger added a comment - Added integration test, not seeing it anymore on 3.0.0

          People

            daschl Michael Nitschinger
            alexcavnar Alex Cavnar
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty