You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by fl...@apache.org on 2018/12/26 12:22:37 UTC

[tinkerpop] branch TINKERPOP-2113 created (now ccd6236)

This is an automated email from the ASF dual-hosted git repository.

florianhockmann pushed a change to branch TINKERPOP-2113
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git.


      at ccd6236  TINKERPOP-2113 Fix P.Within() for list arguments

This branch includes the following new commits:

     new ccd6236  TINKERPOP-2113 Fix P.Within() for list arguments

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[tinkerpop] 01/01: TINKERPOP-2113 Fix P.Within() for list arguments

Posted by fl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

florianhockmann pushed a commit to branch TINKERPOP-2113
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git

commit ccd6236887a05dcd4f926272ba738924647e446b
Author: Florian Hockmann <fh...@florian-hockmann.de>
AuthorDate: Wed Dec 26 13:18:33 2018 +0100

    TINKERPOP-2113 Fix P.Within() for list arguments
---
 gremlin-dotnet/glv/P.template                               |  8 ++++----
 gremlin-dotnet/src/Gremlin.Net/Process/Traversal/P.cs       | 10 +++++-----
 .../Traversal/DriverRemoteConnection/PredicateTests.cs      | 13 +++++++++++++
 3 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/gremlin-dotnet/glv/P.template b/gremlin-dotnet/glv/P.template
index cc5af54..6c5f7d2 100644
--- a/gremlin-dotnet/glv/P.template
+++ b/gremlin-dotnet/glv/P.template
@@ -22,7 +22,7 @@
 #endregion
 
 // THIS IS A GENERATED FILE - DO NOT MODIFY THIS FILE DIRECTLY - see pom.xml
-using System.Collections.Generic;
+using System.Collections;
 using System.Linq;
 
 namespace Gremlin.Net.Process.Traversal
@@ -91,16 +91,16 @@ namespace Gremlin.Net.Process.Traversal
 <% } %><% pmethods.findAll{ it in ["within", "without"] }.each { method -> %>
         public static P <%= toCSharpMethodName.call(method) %>(params object[] args)
         {
-            if (args.Length == 1 && args[0] is ICollection<object> collection)
+            if (args.Length == 1 && args[0] is ICollection collection)
                 return new P("<%= method %>", ToGenericArray(collection));
             else
                 return new P("<%= method %>", args);
         }
 <% } %>
 
-        private static TT[] ToGenericArray<TT>(ICollection<TT> collection)
+        private static object[] ToGenericArray(IEnumerable collection)
         {
-            return collection?.ToArray() ?? new TT[0];
+            return collection?.Cast<object>().ToArray() ?? new object[0];
         }
 
         /// <inheritdoc />
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/P.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/P.cs
index 229f720..86521e2 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/P.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/P.cs
@@ -22,7 +22,7 @@
 #endregion
 
 // THIS IS A GENERATED FILE - DO NOT MODIFY THIS FILE DIRECTLY - see pom.xml
-using System.Collections.Generic;
+using System.Collections;
 using System.Linq;
 
 namespace Gremlin.Net.Process.Traversal
@@ -151,7 +151,7 @@ namespace Gremlin.Net.Process.Traversal
 
         public static P Within(params object[] args)
         {
-            if (args.Length == 1 && args[0] is ICollection<object> collection)
+            if (args.Length == 1 && args[0] is ICollection collection)
                 return new P("within", ToGenericArray(collection));
             else
                 return new P("within", args);
@@ -159,16 +159,16 @@ namespace Gremlin.Net.Process.Traversal
 
         public static P Without(params object[] args)
         {
-            if (args.Length == 1 && args[0] is ICollection<object> collection)
+            if (args.Length == 1 && args[0] is ICollection collection)
                 return new P("without", ToGenericArray(collection));
             else
                 return new P("without", args);
         }
 
 
-        private static TT[] ToGenericArray<TT>(ICollection<TT> collection)
+        private static object[] ToGenericArray(IEnumerable collection)
         {
-            return collection?.ToArray() ?? new TT[0];
+            return collection?.Cast<object>().ToArray() ?? new object[0];
         }
 
         /// <inheritdoc />
diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/PredicateTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/PredicateTests.cs
index e1a929b..16e6542 100644
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/PredicateTests.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/PredicateTests.cs
@@ -21,6 +21,7 @@
 
 #endregion
 
+using System.Collections.Generic;
 using Gremlin.Net.Process.Traversal;
 using Xunit;
 
@@ -51,5 +52,17 @@ namespace Gremlin.Net.IntegrationTest.Process.Traversal.DriverRemoteConnection
 
             Assert.Equal(2, count);
         }
+        
+        [Fact]
+        public void ShouldUsePWithinWithListArgumentInHasStep()
+        {
+            var connection = _connectionFactory.CreateRemoteConnection();
+            var g = AnonymousTraversalSource.Traversal().WithRemote(connection);
+            var names = new List<string> {"josh", "vadas"};
+
+            var count = g.V().Has("name", P.Within(names)).Count().Next();
+
+            Assert.Equal(2, count);
+        }
     }
 }
\ No newline at end of file