This blog was originally posted on David Ostrovsky's personal blog. To see to original blog post, click here

TL;DR: SELECT myBucket.* FROM myBucket

A change in the way N1QL returns results for star queries in Couchbase Server 4.1 seems to have broken how the .NET SDK deserializes the returned results. It causes the Query<> method to return the correct number of results, but with all properties at their default value. The reason is that a query like SELECT * FROM default default now produces the following JSON result:

As you can see, each document is returned as a property under the name of the bucket, whereas the .NET SDK implementation expects the results like they used to be in the earlier versions of N1QL, as an array of JSON document bodies:

Luckily, we can easily fix this by selecting the content of the defaultproperty instead of * in our query, like so: SELECT default.* FROM default which will now return the results in the format the .NET SDK expects.

Try it out and see that the Query<> method now returns objects with all the values correctly deserialized.

Author

Posted by David Ostrovsky, Senior Solutions Architect, Couchbase

David Ostrovsky is a Senior Solutions Architect at Couchbase. As a solutions architect, David worked with existing and potential Couchbase customers to design, implement and support deployments of Couchbase Server.

Leave a reply