Different result using C# driver vs. shell

,

Hi all,

Not sure if this is a bug but it sure seems like it.

I have following query:

Let({
  blocks: Select(["data", "blocks"], Get(Ref(Collection("notes"), "xyz"))),
  find: Filter(Var("blocks"), entity => Equals(Select("refs", entity), Ref(Collection("notes"), "xyz")))
}, 
Var("find")
)

I’m trying to use this query with the C# driver:

var result = await client.Query(
Let("blocks", 
      Select(Arr("data", "blocks"), 
             Get(Ref(Collection("notes"), "xyz"))), 
    "find", 
      Filter(Var("blocks"), entity => Equals(
              Select("refs", entity), 
              Ref(Collection("notes"), "xyz")))).In(Var("find"))
            );

The query works perfectly in the Fauna shell but does return an empty result while using the C# driver.
Syntax for C# seems to be correct, no error.

Any idea why that is?

Thank you.

Hi @gllanfranchi,
thanks for posting this issue.

Can I ask you to provide more details: a sample document you are running this query against and a result you get would help us in debugging it further.

Kind regards,
Stan

Hi @parkhomenko,
thank you for your reply.

I’m sorry but I don’t have any examples since I’ve used a different logic to work around it. But I can try to rebuild it:

Sample document:

  "ref": Ref(Collection("notes"), "123"),
  "ts": 123,
  "data": {
    "title": "Note1",
    "blocks": [
        {"text": "Text1", "refs": Ref(Collection("notes"), xyz) }, 
        {"text": "Text2", "refs": Ref(Collection("notes"), 1234) }
       ]
   }
}

Result in Fauna shell: the blocks which match their ref value with the value given in the query.

{"text": "Text1", "refs": Ref(Collection("notes"), xyz) },

Result with C# driver: empty

Hope that helps.

Hi @gllanfranchi,

Now I see, thanks for this additional info.

You are using a standard C# Equals function instead of the fauna’s EqualsFn. Here are the docs for it: Equals | Fauna Documentation

I’ve also had to remove the very last bracket to make it work in my c# test app (besides the change EqualsEqualsFn):

var queryTest = Let("blocks", Select(Arr("data", "blocks"), Get(Ref(Collection("notes"), "123"))),
                "find", Filter(Var("blocks"), entity => EqualsFn(
                        Select("refs", entity),
                        Ref(Collection("notes"), "456")
                    )
                )
            ).In(Var("find"));
            
var res = await client.Query(queryTest);

Kind regards,
Stan

2 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.