Skip to content

Unable to create queries from variables #104

Closed
@PulFur

Description

@PulFur

After updating from 1.2.1 to latest 2.0.2 version conditions from variables stopped working. This same issue seems to happen in 2.0 version also.

I am able to call the Where method with variables in expressions without exceptions, but it returns with invalid results.

I would expect it to return the documents that matches with variables values, but it returns 0 documents instead. This worked like I would expect in earlier 1.2.1 version.

Running condition with constants in 2.0 / 2.0.2 version works as expected; it returns the documents that match with given condition.

It seems that the Where clause generates proper mango query that works as expected when run from CouchDb web administrative control panel. The same mango query doesn't get sent with CouchClient although. It is sending parameter name instead of its value

CouchDB testdb database document:

{
	"id":"someid",
	"property1" : "a"
}

Not working C# POC Code:

var database = GetDatabase<TestDocument>("testdb");
var variable1 = "a";
var mangoQuery = database.Where(d => d.Property1 == variable1);
var documentResults = mangoQuery.ToList();

Working C# POC Code:

var database = GetDatabase<TestDocument>("testdb");
var mangoQuery = database.Where(d => d.Property1 == "a");
var documentResults = mangoQuery.ToList();

Where clause generated mango query:

   "selector": {
      "$and": [
         {
            "property1": "a"
         }
      ]
   }

Actual what is being sent (checked from OnBeforeCallAsync httpCall param):

   "selector": {
      "$and": [
         {
            "property1": "variable1"
         }
      ]
   }

Expected:

   "selector": {
      "$and": [
         {
            "property1": "a"
         }
      ]
   }

EDIT1:
Checked that the call on
OnBeforeCallAsync
doesn't match the generated mango query. Seems that my example was little different. I'll update this soon

EDIT2:
Seems it was not about multi query after all. Updated the question, apologies for not noticing this earlier.

EDIT3:
Updated question + title

Metadata

Metadata

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions