coronabytes / dotnet-arangodb

.NET Driver for ArangoDB
Apache License 2.0
66 stars 18 forks source link

CreateAsync always creates collection with Document type #68

Closed Lozko1991 closed 11 months ago

Lozko1991 commented 11 months ago

Even I pass ArangoCollectionType.Edge in DB will be created Document collection. I have updated version to 3.11.2 and error still exists.

await _arangoContext.Collection.CreateAsync(_arangoDBName, new ArangoCollection
{
    Name = collectionName,
    Type = ArangoCollectionType.Edge,
    KeyOptions = new ArangoKeyOptions
    {
        Type = ArangoKeyType.Traditional,
        AllowUserKeys = allowUserKeys
    }
});
coronabytes commented 11 months ago

remove the keyoptions please and try again, doesn't make sense for edge maybe an argango "bug" options outweigh type or so

Lozko1991 commented 11 months ago

I found, what was the problem. I add to my default Newtonsoft serializer settings StringEnumConverter. Then parameter ArangoCollectionType.Edge was serialized as "type": "Edge" with capitlized first letter and passed via http request to ArangoDB. But parameter must be in lower case as "edge" or "3" as number. Value "Edge" was wrong interpreted by DB and document-type collection was created.

To fix this i used new StringEnumConverter() { NamingStrategy = new CamelCaseNamingStrategy() } for coreect serialization. And it works for now.