spmallette commented on code in PR #3458: URL: https://github.com/apache/tinkerpop/pull/3458#discussion_r3443997744
########## gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/filter/HasTraversal.feature: ########## @@ -0,0 +1,433 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +@StepClassFilter @StepHas +Feature: Step - has() with traversal arguments + + @GraphComputerVerificationMidVNotSupported + Scenario: g_V_hasXname_VXvid1X_valuesXnameXX + Given the modern graph + And using the parameter vid1 defined as "v[marko].id" + And the traversal of + """ + g.V().has("name", __.V(vid1).values("name")) + """ + When iterated to list + Then the result should be unordered + | result | + | v[marko] | + + @GraphComputerVerificationMidVNotSupported + # has(key, traversal) with multi-result child traversal - takes first result (order-dependent) + @InsertionOrderingRequired + Scenario: g_V_hasXname_VXvid1X_outXknowsX_valuesXnameXX + Given the modern graph + And using the parameter vid1 defined as "v[marko].id" + And the traversal of + """ + g.V().has("name", __.V(vid1).out("knows").values("name")) + """ + When iterated to list + Then the result should be unordered + | result | + | v[vadas] | + + # has(key, traversal) with multi-result child traversal (age) - takes first result (order-dependent) + @GraphComputerVerificationMidVNotSupported + @InsertionOrderingRequired + Scenario: g_V_hasXage_VXvid1X_outXknowsX_valuesXageXX + Given the modern graph + And using the parameter vid1 defined as "v[marko].id" + And the traversal of + """ + g.V().has("age", __.V(vid1).out("knows").values("age")) + """ + When iterated to list + Then the result should be unordered + | result | + | v[vadas] | + + @GraphComputerVerificationMidVNotSupported + Scenario: g_V_hasXname_VXvid1X_valuesXnonexistentXX + Given the modern graph + And using the parameter vid1 defined as "v[marko].id" + And the traversal of + """ + g.V().has("name", __.V(vid1).values("nonexistent")) + """ + When iterated to list + Then the result should be empty + + @GraphComputerVerificationMidVNotSupported + Scenario: g_V_hasXname_notXidentityXX + Given the modern graph + And the traversal of + """ + g.V().has("name", __.not(__.identity())) + """ + When iterated to list + Then the result should be empty + + @GraphComputerVerificationMidVNotSupported + Scenario: g_V_hasXage_gtXVXvid1X_valuesXageXXX + Given the modern graph + And using the parameter vid1 defined as "v[marko].id" + And the traversal of + """ + g.V().has("age", P.gt(__.V(vid1).values("age"))) + """ + When iterated to list + Then the result should be unordered + | result | + | v[josh] | + | v[peter] | + + @GraphComputerVerificationMidVNotSupported + Scenario: g_V_hasXage_lteXVXvid2X_valuesXageXXX + Given the modern graph + And using the parameter vid2 defined as "v[vadas].id" + And the traversal of + """ + g.V().has("age", P.lte(__.V(vid2).values("age"))) + """ + When iterated to list + Then the result should be unordered + | result | + | v[vadas] | + + @GraphComputerVerificationMidVNotSupported + Scenario: g_V_hasXage_neqXVXvid3X_valuesXageXXX + Given the modern graph + And using the parameter vid3 defined as "v[josh].id" + And the traversal of + """ + g.V().has("age", P.neq(__.V(vid3).values("age"))) + """ + When iterated to list + Then the result should be unordered + | result | + | v[marko] | + | v[vadas] | + | v[peter] | + + @GraphComputerVerificationMidVNotSupported + Scenario: g_V_hasXname_eqXVXvid1X_valuesXnameXXX + Given the modern graph + And using the parameter vid1 defined as "v[marko].id" + And the traversal of + """ + g.V().has("name", P.eq(__.V(vid1).values("name"))) + """ + When iterated to list + Then the result should be unordered + | result | + | v[marko] | + + @GraphComputerVerificationMidVNotSupported + Scenario: g_V_hasXage_ltXVXvid1X_valuesXageXXX + Given the modern graph + And using the parameter vid1 defined as "v[marko].id" + And the traversal of + """ + g.V().has("age", P.lt(__.V(vid1).values("age"))) + """ + When iterated to list + Then the result should be unordered + | result | + | v[vadas] | + + @GraphComputerVerificationMidVNotSupported + Scenario: g_V_hasXage_gteXVXvid3X_valuesXageXXX + Given the modern graph + And using the parameter vid3 defined as "v[josh].id" + And the traversal of + """ + g.V().has("age", P.gte(__.V(vid3).values("age"))) + """ + When iterated to list + Then the result should be unordered + | result | + | v[josh] | + | v[peter] | + + @GraphComputerVerificationMidVNotSupported + Scenario: g_V_hasXage_eqXVXvid1X_valuesXnonexistentXXX + Given the modern graph + And using the parameter vid1 defined as "v[marko].id" + And the traversal of + """ + g.V().has("age", P.eq(__.V(vid1).values("nonexistent"))) + """ + When iterated to list + Then the result should be empty + + @GraphComputerVerificationMidVNotSupported + Scenario: g_V_hasXlabel_VXvid1X_labelXX + Given the modern graph + And using the parameter vid1 defined as "v[marko].id" + And the traversal of + """ + g.V().has(T.label, __.V(vid1).label()) + """ + When iterated to list + Then the result should be unordered + | result | + | v[marko] | + | v[vadas] | + | v[josh] | + | v[peter] | + + @GraphComputerVerificationMidVNotSupported + Scenario: g_V_hasXperson_name_VXvid1X_valuesXnameXX_age + Given the modern graph + And using the parameter vid1 defined as "v[marko].id" + And the traversal of + """ + g.V().has("person", "name", __.V(vid1).values("name")).values("age") + """ + When iterated to list + Then the result should be unordered + | result | + | d[29].i | + + # Multi-traversal within() where one traversal produces multiple results - use fold() to collect + @GraphComputerVerificationMidVNotSupported + Scenario: g_V_hasXname_withinXVXvid1X_outXknowsX_valuesXnameX_constantXpeterXXX + Given the modern graph + And using the parameter vid1 defined as "v[marko].id" + And the traversal of + """ + g.V().has("name", P.within(__.V(vid1).out("knows").values("name").fold(), __.constant("peter"))) + """ + When iterated to list + Then the result should be unordered + | result | + | v[vadas] | + | v[josh] | + | v[peter] | + + # Multi-traversal within() where one traversal produces no results - still matches on the other + @GraphComputerVerificationMidVNotSupported + Scenario: g_V_hasXname_withinXVXvid1X_valuesXnonexistentX_constantXmarkoXXX + Given the modern graph + And using the parameter vid1 defined as "v[marko].id" + And the traversal of + """ + g.V().has("name", P.within(__.V(vid1).values("nonexistent"), __.constant("marko"))) + """ + When iterated to list + Then the result should be unordered + | result | + | v[marko] | + + # Multi-traversal within() where all traversals produce no results - filters everything + @GraphComputerVerificationMidVNotSupported + Scenario: g_V_hasXname_withinXVXvid1X_valuesXnonexistentX_VXvid1X_valuesXnonexistentXXX + Given the modern graph + And using the parameter vid1 defined as "v[marko].id" + And the traversal of + """ + g.V().has("name", P.within(__.V(vid1).values("nonexistent"), __.V(vid1).values("nonexistent"))) + """ + When iterated to list + Then the result should be empty + + # Multi-traversal without() with three traversals + @GraphComputerVerificationMidVNotSupported + Scenario: g_V_hasXname_withoutXVXvid1X_valuesXnameX_VXvid2X_valuesXnameX_VXvid3X_valuesXnameXXX + Given the modern graph + And using the parameter vid1 defined as "v[marko].id" + And using the parameter vid2 defined as "v[vadas].id" + And using the parameter vid3 defined as "v[peter].id" + And the traversal of + """ + g.V().has("name", P.without(__.V(vid1).values("name"), __.V(vid2).values("name"), __.V(vid3).values("name"))) + """ + When iterated to list + Then the result should be unordered + | result | + | v[josh] | + | v[lop] | + | v[ripple] | + + # Multi-traversal within() - union of relationship traversals from different sources + @GraphComputerVerificationMidVNotSupported + Scenario: g_V_hasXname_withinXVXvid1X_outXknowsX_valuesXnameX_VXvid3X_outXcreatedX_valuesXnameXXX + Given the modern graph + And using the parameter vid1 defined as "v[marko].id" + And using the parameter vid3 defined as "v[josh].id" + And the traversal of + """ + g.V().has("name", P.within(__.V(vid1).out("knows").values("name").fold(), __.V(vid3).out("created").values("name").fold())) + """ + When iterated to list + Then the result should be unordered + | result | + | v[vadas] | + | v[josh] | + | v[ripple] | + | v[lop] | + + # Multi-traversal without() - exclusion from multiple relationship sources Review Comment: I don't believe the multi-traversal semantics are correct. In the reference docs we describe it as: > * The multi-traversal form `within(trav1, trav2, ...)` takes the first result from each traversal and combines them into a collection for membership testing. but `within` doesn't really work like that: ``` gremlin> g.V().has('name',within(['josh','lop'], 'vadas')) ==>v[2] ``` It only expands the list if the first and singular argument is a collection: ``` gremlin> g.V().has('name',within(['vadas','josh','lop'])) ==>v[2] ==>v[3] ==>v[4] ``` Otherwise, as shown in the first example, it will treat it like comparing on a `List` and a `String`. `V` and `E` have similar semantics, but oddly: ``` gremlin> g.V().hasId(2, [3, 1]) ==>v[2] ==>v[3] ==>v[1] gremlin> g.V(2, [3, 1]) Expected an id that is convertible to class java.lang.Integer but received class java.util.ArrayList - [[3, 1]] Type ':help' or ':h' for help. Display stack trace? [yN] ``` This goes back to https://issues.apache.org/jira/browse/TINKERPOP-2863 where I think there is a bug in the implementation which tried to get `hasId` to be like `V` and `E` but allowed a little too much to happen. I think all of this needs to be rectified. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
