File tree Expand file tree Collapse file tree 4 files changed +13
-5
lines changed
gremlin-python/src/main/python Expand file tree Collapse file tree 4 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -82,6 +82,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
8282* Added `idleConnectionTimeout` setting for Gremlin Driver and automatic closing of idle connections
8383* Enabled TCP Keep-Alive in GremlinServer.
8484* Updated Python GLV examples to use HTTP and to run as part of the integration tests.
85+ * Fixed `gremlin-python` `to()` and `from_()` methods to wrap Vertex objects with `__.V()` for proper edge creation.
8586
8687== TinkerPop 3.8.0 (Grix Greven)
8788
Original file line number Diff line number Diff line change @@ -40,8 +40,8 @@ def main():
4040
4141 # be sure to use a terminating step like next() or iterate() so that the traversal "executes"
4242 # iterate() does not return any data and is used to just generate side-effects (i.e. write data to the database)
43- g .V (v1 ).add_e ('knows' ).to (__ . V ( v2 ) ).property ('weight' , 0.75 ).iterate ()
44- g .V (v1 ).add_e ('knows' ).to (__ . V ( v3 ) ).property ('weight' , 0.75 ).iterate ()
43+ g .V (v1 ).add_e ('knows' ).to (v2 ).property ('weight' , 0.75 ).iterate ()
44+ g .V (v1 ).add_e ('knows' ).to (v3 ).property ('weight' , 0.75 ).iterate ()
4545
4646 # retrieve the data from the "marko" vertex
4747 marko = g .V ().has (VERTEX_LABEL , 'name' , 'marko' ).values ('name' ).next ()
Original file line number Diff line number Diff line change 2828from ..driver .remote_connection import RemoteStrategy
2929from .. import statics
3030from ..statics import long
31+ from ..structure .graph import Vertex
3132
3233log = logging .getLogger ("gremlinpython" )
3334
@@ -506,7 +507,10 @@ def format_(self, *args):
506507 return self
507508
508509 def from_ (self , * args ):
509- self .gremlin_lang .add_step ("from" , * args )
510+ if len (args ) == 1 and isinstance (args [0 ], Vertex ):
511+ self .gremlin_lang .add_step ("from" , __ .V (args [0 ].id ))
512+ else :
513+ self .gremlin_lang .add_step ("from" , * args )
510514 return self
511515
512516 def group (self , * args ):
@@ -943,7 +947,10 @@ def times(self, *args):
943947 return self
944948
945949 def to (self , * args ):
946- self .gremlin_lang .add_step ("to" , * args )
950+ if len (args ) == 1 and isinstance (args [0 ], Vertex ):
951+ self .gremlin_lang .add_step ("to" , __ .V (args [0 ].id ))
952+ else :
953+ self .gremlin_lang .add_step ("to" , * args )
947954 return self
948955
949956 def toE (self , * args ):
Original file line number Diff line number Diff line change @@ -370,7 +370,7 @@ def test_should_extract_id_from_vertex(self):
370370
371371 # Test edge creation with from/to vertices
372372 from_to = g .add_e ("Edge" ).from_ (Vertex (1 )).to (Vertex (2 ))
373- assert "g.addE('Edge').from(1) .to(2 )" == from_to .gremlin_lang .get_gremlin ()
373+ assert "g.addE('Edge').from(__.V(1)) .to(__.V(2) )" == from_to .gremlin_lang .get_gremlin ()
374374
375375 # Test mergeE() with Vertex in dictionary
376376 merge_map = {
You can’t perform that action at this time.
0 commit comments