DotNet4Neo4j / Neo4jClient

.NET client binding for Neo4j
https://www.nuget.org/packages/Neo4jClient
Microsoft Public License
431 stars 146 forks source link

DebugQueryText should serialize object property names without quotes #436

Closed Clooney24 closed 2 years ago

Clooney24 commented 2 years ago

Description

When using objects in .Merge or .Set statements, they are embedded in DebugQueryText with quoted names. Formatted like this, those cyphers can't be executed in Neo4jDesktop. This makes troubleshooting larger cyphers much more difficult.

Versions:

To Reproduce

var dummyObject = new { key = "value" };
var query = new CypherFluentQuery(client)
  .Merge("(foo:Foo $object)")
  .WithParam("object", dummyObject)
  .Query;

results in this DebugQueryText:

MERGE (foo:Foo {
  "key": "value"
})

Executing this in Neo4j will lead to this error:

Invalid input '"': expected whitespace, comment, a property key name

Expected behaviour I would expect to NOT enclose the property names in quotes, so that DebugQueryString will be executable and should look like this:

MERGE (foo:Foo {
  key: "value"
})

Additional context This could simply be achieved by adding this line in CypherQuery.DebugQueryText before line 106:

serializer.QuoteName = false;

@cskardon I could create a PR including a test if there aren't any concerns from your side.

Clooney24 commented 2 years ago

see PR https://github.com/DotNet4Neo4j/Neo4jClient/pull/437