Skip to content

Error in generated AQL when upserting a generic document #124

@isen-ng

Description

@isen-ng

I'm trying to upsert a document that involves a generic.
The document collection has not been created yet, and I assume the collection will be automatically created like in the Insert method (please correct me if I'm wrong).

This is the code I have:

private async Task<TState> Store(string key, TState state)
{
    using (var db = _arangoDb.CreateWithSetting())
    {
        var wrapped = Wrapper.Wrap(key, state);
        
        await Task.Run(() => db.Query()
            .Upsert(_ => new { _key = key },
                    _ => wrapped,
                   (_, old) => wrapped)
            .In<Wrapper<TState>>()
            .Execute());
    }

    return state;
}

Upon executing, I received an exception:

ArangoDB.Client.ArangoServerException: AQL: syntax error, unexpected integer number near '1` ' at position 1:56 (while parsing). ErrorNumber: 1501 HttpStatusCode: 400
   at ArangoDB.Client.BaseResultAnalyzer.ThrowIfNeeded(BaseResult baseResult)
   at ArangoDB.Client.Cursor.CursorAsyncEnumerator`1.SetCurrent()
   at ArangoDB.Client.Cursor.CursorAsyncEnumerator`1.MoveNextAsync()
   at ArangoDB.Client.Utility.TaskUtils.ResultSynchronizer[T](Task`1 task)
   at ArangoDB.Client.Cursor.CursorEnumerator`1.MoveNext()
   at System.Collections.Generic.List`1.AddEnumerable(IEnumerable`1 enumerable)
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at ArangoDB.Client.Data.Cursor`1.ToList()
   at ArangoDB.Client.QueryableExtensions.Execute[T](IAqlModifiable`1 source)
   ...

The generated AQL from doing .GetQueryData().Query is:

upsert  @P1  insert  @P2  update  @P3  in `Wrapper`1`  return   `_`

The generated AQL is wrong as there is an extra back tick in Wrapper`1.

I'm not sure about this, but Wrapper1 seems wrong as well, because different types for the generic will be mapped to the same collection. Assuming typeof(TState) is object, the collection should have been Wrapper_object (or with any other delimiter).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions