[ 
https://issues.apache.org/jira/browse/TINKERPOP-1920?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16401666#comment-16401666
 ] 

ASF GitHub Bot commented on TINKERPOP-1920:
-------------------------------------------

Github user jorgebay commented on a diff in the pull request:

    https://github.com/apache/tinkerpop/pull/817#discussion_r175035051
  
    --- Diff: gremlin-dotnet/src/Gremlin.Net/Process/Traversal/P.cs ---
    @@ -148,12 +154,29 @@ public static P Test(params object[] args)
     
             public static P Within(params object[] args)
             {
    -            return new P("within", args);
    +            if (args.Length == 1 && 
args[0].GetType().GetInterfaces().Contains(typeof(ICollection)))
    +                return new P("within", 
ToGenericArray((ICollection<object>) args[0]));
    +            else
    +                return new P("within", args);
             }
     
             public static P Without(params object[] args)
             {
    -            return new P("without", args);
    +            if (args.Length == 1 && 
args[0].GetType().GetInterfaces().Contains(typeof(ICollection)))
    +                return new P("without", 
ToGenericArray((ICollection<object>) args[0]));
    +            else
    +                return new P("without", args);
    +        }
    +
    +
    +        private static T[] ToGenericArray<T>(ICollection<T> collection)
    +        {
    +            if (collection == null)
    --- End diff --
    
    We can express the logic in this method using null-conditional and 
null-coalescing operators:
    
    ```csharp
    private static T[] ToGenericArray<T>(ICollection<T> collection)
    {
        return collection?.ToArray() ?? new T[0];
    }
    ```


> Tests fail because P.Within() arguments are wrapped in an array in Gremlin.Net
> ------------------------------------------------------------------------------
>
>                 Key: TINKERPOP-1920
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP-1920
>             Project: TinkerPop
>          Issue Type: Bug
>          Components: dotnet
>    Affects Versions: 3.2.7
>            Reporter: Florian Hockmann
>            Priority: Major
>             Fix For: 3.2.8, 3.3.2
>
>
> For the scenario {{g_V_hasIdXwithinXemptyXX_count}}, {{P.within([])}} will be 
> serialized as:
> {code}
> {
>     "@type": "g:P",
>     "@value": {
>         "predicate": "within",
>         "value": [
>             []
>         ]
>     }
> }
> {code}
> which fails on the server side as it tries to treat {{[]}} as an id:
>  {{Expected an id that is convertible to Integer but received class 
> java.util.ArrayList}}.
> This seems to be related to the changes made in 
> [TINKERPOP-1874|https://issues.apache.org/jira/browse/TINKERPOP-1874].



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to