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

Executing multiple lookup gets with different types fails

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.7.15
    • 2.7.16
    • None
    • None
    • 1

    Description

      Raised by gitter user mfeerick.

      I am wondering if you can help with an issue I am facing regarding SubDoc LookupIn chaining as I am getting a ClientFailure and looking at the Exception message it is nable to cast object of type 'System.Collections.Generic.List`1[Couchbase.Core.IO.SubDocument.OperationSpec]' to type 'My Document POCO Type'
      var lookupBuilder = bucket.LookupIn<T>(identifier);
      lookupBuilder.Get(lookup.Path1).Get(lookup.Path2)
      var documentFragmentResult = await lookupBuilder.ExecuteAsync();
      this is failing, however if I do not chain the Get() and only do one Get() it works
      what am i doing wrong?
       
      Jeffry Morris @jeffrymorris Dec 27 2019 22:42
      @mfeerick sounds like a bug. What is the SDK version you are using?
       
      mfeerick @mfeerick Jan 06 08:52
      @jeffrymorris I am using 2.7.15 which afaik is the latest.
       
      mfeerick @mfeerick Jan 06 10:53
      couchbase-net-client/src/Couchbase/IO/Operations/SubDocument/MultiLookup.cs:line 115
      return (T)_lookupCommands;
       
      Mike Goldsmith @MikeGoldsmith Jan 06 13:13
      Hi @mfeerick - just FYI @jeffrymorris is based on West coast so won’t be available to respond for a little while.
      Can you give some context to the cs file & line number you pointed out?
       
      mfeerick @mfeerick Jan 06 14:25
      @MikeGoldsmith This is where an exception is thrown when attempting to do a MultiLookup
      var lookupBuilder = bucket.LookupIn<T>(identifier);
      lookupBuilder.Get(lookup.Path1).Get(lookup.Path2)
      var documentFragmentResult = await lookupBuilder.ExecuteAsync();
       
      Mike Goldsmith @MikeGoldsmith Jan 06 15:35
      Please can you provide a full example with both code and JSON document you’re using that generates the error?
       
      mfeerick @mfeerick Jan 07 22:33
      @MikeGoldsmith sure ive created a simple example at: https://dotnetfiddle.net/lsLpqH
      The result of the lookupBuilder.Execute() will be a "ClientFailure"
      My debugging the CouchbaseNetClient source shows the issue on line 115 of couchbase-net-client/src/Couchbase/IO/Operations/SubDocument/MultiLookup.cs
       
      mfeerick @mfeerick Jan 07 22:40
      where it is attempting to cast a List<Couchbase.Core.IO.SubDocument.OperationSpec> to a <T> so in my example a "Test"
      I also figured out why it works if you dont chain multiple Gets, and that is because it runs different code.
       
      @jeffrymorris @MikeGoldsmith I have fixed this issue in MultiLookup.cs with a small change, do you accept pull requests on github?
      

      Attachments

        For Gerrit Dashboard: NCBC-2235
        # Subject Branch Project Status CR V

        Activity

          There are no comments yet on this issue.

          People

            jmorris Jeff Morris
            mike.goldsmith Michael Goldsmith
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty