Changed order of `select()` scopes. Maps (local objects) come firstm then 
side-effects, then paths.


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/24f629b5
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/24f629b5
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/24f629b5

Branch: refs/heads/master
Commit: 24f629b5f2cf80596b3ea258219e86ea8c903766
Parents: a35f009
Author: Daniel Kuppitz <daniel_kupp...@hotmail.com>
Authored: Wed Feb 21 13:52:53 2018 -0700
Committer: Daniel Kuppitz <daniel_kupp...@hotmail.com>
Committed: Wed Mar 7 08:36:39 2018 -0700

----------------------------------------------------------------------
 .../gremlin/process/traversal/step/Scoping.java   | 12 ++++++------
 .../process/traversal/step/map/SelectTest.java    | 18 ++++++++++++++++++
 2 files changed, 24 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/24f629b5/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/Scoping.java
----------------------------------------------------------------------
diff --git 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/Scoping.java
 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/Scoping.java
index c86f91f..da7b0eb 100644
--- 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/Scoping.java
+++ 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/Scoping.java
@@ -110,13 +110,13 @@ public interface Scoping {
     public enum Variable {START, END}
 
     public default <S> S getScopeValue(final Pop pop, final String key, final 
Traverser.Admin<?> traverser) throws IllegalArgumentException {
-        if (traverser.getSideEffects().exists(key))
-            return traverser.getSideEffects().get(key);
-        ///
         final Object object = traverser.get();
         if (object instanceof Map && ((Map<String, S>) 
object).containsKey(key))
             return ((Map<String, S>) object).get(key);
         ///
+        if (traverser.getSideEffects().exists(key))
+            return traverser.getSideEffects().get(key);
+        ///
         final Path path = traverser.path();
         if (path.hasLabel(key))
             return path.get(pop, key);
@@ -125,13 +125,13 @@ public interface Scoping {
     }
 
     public default <S> S getNullableScopeValue(final Pop pop, final String 
key, final Traverser.Admin<?> traverser) {
-        if (traverser.getSideEffects().exists(key))
-            return traverser.getSideEffects().get(key);
-        ///
         final Object object = traverser.get();
         if (object instanceof Map && ((Map<String, S>) 
object).containsKey(key))
             return ((Map<String, S>) object).get(key);
         ///
+        if (traverser.getSideEffects().exists(key))
+            return traverser.getSideEffects().get(key);
+        ///
         final Path path = traverser.path();
         if (path.hasLabel(key))
             return path.get(pop, key);

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/24f629b5/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/SelectTest.java
----------------------------------------------------------------------
diff --git 
a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/SelectTest.java
 
b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/SelectTest.java
index 3620456..3ca2068 100644
--- 
a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/SelectTest.java
+++ 
b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/SelectTest.java
@@ -83,6 +83,8 @@ public abstract class SelectTest extends 
AbstractGremlinProcessTest {
 
     public abstract Traversal<Vertex, Vertex> 
get_g_V_chooseXoutE_count_isX0X__asXaX__asXbXX_chooseXselectXaX__selectXaX__selectXbXX();
 
+    public abstract Traversal<Integer, String> 
get_g_withSideEffectXa_a_markoX_injectX1X_selectXaX_select_XaX();
+
     // below are original back()-tests
 
     public abstract Traversal<Vertex, Vertex> 
get_g_VX1X_asXhereX_out_selectXhereX(final Object v1Id);
@@ -341,6 +343,16 @@ public abstract class SelectTest extends 
AbstractGremlinProcessTest {
         assertEquals(3, xCounter);
     }
 
+    @Test
+    @LoadGraphWith(MODERN)
+    public void g_withSideEffectXa_a_markoX_injectX1X_selectXaX_select_XaX() {
+        final Traversal<Integer, String> traversal = 
get_g_withSideEffectXa_a_markoX_injectX1X_selectXaX_select_XaX();
+        printTraversalForm(traversal);
+        assertTrue(traversal.hasNext());
+        assertEquals("marko", traversal.next());
+        assertFalse(traversal.hasNext());
+    }
+
     // below are original back()-tests
 
     @Test
@@ -722,6 +734,12 @@ public abstract class SelectTest extends 
AbstractGremlinProcessTest {
             return g.V().choose(__.outE().count().is(0L), __.as("a"), 
__.as("b")).choose(__.select("a"), __.select("a"), __.select("b"));
         }
 
+        public Traversal<Integer, String> 
get_g_withSideEffectXa_a_markoX_injectX1X_selectXaX_select_XaX() {
+            final Map<String, String> m = new HashMap<>(1);
+            m.put("a", "marko");
+            return g.withSideEffect("a", m).inject(1).select("a").select("a");
+        }
+
         // below are original back()-tests
 
         @Override

Reply via email to