-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect query when using P.Within() #41
Comments
Yep. That's definitely a bug in the serialization logic. I'm guessing it's being treated as an object and is therefore getting the quotes. The code linked by @BenjaBobs would be a good place to start on a fix. I won't be able to get to this any time soon due to the season, unfortunately, but would be happy to look at any pull requests you may have for a fix. Otherwise, I will address this when I can. Thank you for your patience. |
I investigated a bit, and this turned out to be more complex than I initially thought.
[Fact]
public void Within_serializes_properly()
{
var g = new GraphTraversalSource();
var priceObjectArray = new object[] { 5, 13, 27 };
var priceIntArray = new int[] { 5, 13, 27 };
var queryObject = g.V<Product>().Has(p => p.Price, P.Within(priceObjectArray));
var queryInt = g.V<Product>().Has(p => p.Price, P.Within(priceIntArray));
var queryObjectString = queryObject.ToGremlinQuery();
var queryIntString = queryInt.ToGremlinQuery();
queryObjectString.Should().Be("g.V().hasLabel(\"product\").has(\"Price\",within(5, 13, 27))");
queryIntString.Should().Be("g.V().hasLabel(\"product\").has(\"Price\",within(\"[5, 13, 27]\"))");
} Because of the way the type is inferred and the way |
When I add an additional overload to the private void Serialize(IEnumerable<int> array)
{
var serializedObj = JsonConvert.SerializeObject(array, Formatting.None, _serializerSettings);
_writer.Write(serializedObj);
} The replace functionality in |
I'm still not sure this is the best method of solving this, as the underlying data is still formatted wrong and might lead to errors in the future.
While
Due to the signature of |
I believe this issue was previously documented as this issue: Soon after, it was addressed by this commit: This test scenario is passing, and it seems to be almost the same as the one from the original post. Gremlin.Net.CosmosDb/test/Gremlin.Net.CosmosDb.Tests/TraversalSerialization/QuerySerializerTests.cs Line 225 in 94e1fe8
|
When querying using the method
P.Within()
there never seem to yield any results. When inspecting the produced query I noticed it has some additional quotes around the array. When removing these quotes I get the expected behavior which are the requested vertexes.Example code:
The text was updated successfully, but these errors were encountered: