dotnet-arangodb icon indicating copy to clipboard operation
dotnet-arangodb copied to clipboard

ExecuteAsync FormattableString causing an unexpected answer

Open mordebip opened this issue 1 year ago • 2 comments

Hello, i have been trying to make a generic get method for an easier generic implementation (with dynamic filters)

i am basically trying to build a query following this model

FormattableString limits = $"";
  if (pagingAndFilter.paging != null && pagingAndFilter.paging.numberOfElements != 0) 
    limits = $"limit {pagingAndFilter.paging.startPoint}, {pagingAndFilter.paging.numberOfElements}";

FormattableString filters = $"";
  if (pagingAndFilter.filters != null && pagingAndFilter.filters != "")
    filters = $"FILTER {pagingAndFilter.filters}";
    
FormattableString query = $" FOR c IN {collectionName} {filters} {limits} RETURN c";

For the situation where i will send the following arguments

{
  "paging": {
    "startPoint": 0,
    "numberOfElements": 10
  },
  "filters": "c.name == 'filteringName'"
}

The fiilters aren't being applied even if the value of query is "FOR c IN Product filter c.name == 'filteringName' limit 0, 10 RETURN c" which is a correctly formatted query

I was also thinking about sending the Filtering and Limit part as a static string, but it raised a lot of other issues, having a method to execute AQL from a simple and plain string could solve a lot of issues and offer a last ressort alternative

Edit : When trying to flatten the Filter part (@P2) with Invariant i get the following error

AQL: syntax error, unexpected bind parameter near '@P2 limit @P3, @P4 RETURN c' at position 1:14 (while parsing)

mordebip avatar May 11 '23 02:05 mordebip