@@ -2369,7 +2369,45 @@ def test_select_bare_relationship_alias_multiple_rows(self):
23692369 "[:WORKS_AT {workFrom: 2015}]" ,
23702370 ]
23712371
2372+ def test_select_bare_relationship_alias_with_edge_id_property_renders_entity_not_scalar_id (self ):
2373+ edges = pd .DataFrame ([{"s" : "p3" , "d" : "c1" , "type" : "WORKS_AT" , "id" : "edge-1" , "workFrom" : 2010 }])
2374+ g = self ._binding_graph (edges = edges )
2375+ select_result = g .gfql (self ._binding_ops () + [select (items = [("rel" , "workAt" )])])
2376+ return_result = g .gfql (self ._binding_ops () + [return_ ([("rel" , "workAt" )])])
2377+ assert select_result ._nodes ["rel" ].tolist () == ["[:WORKS_AT {id: 'edge-1', workFrom: 2010}]" ]
2378+ assert select_result ._nodes ["rel" ].tolist () == return_result ._nodes ["rel" ].tolist ()
2379+
2380+ def test_select_bare_relationship_alias_with_only_id_property_parity (self ):
2381+ edges = pd .DataFrame ([{"s" : "p3" , "d" : "c1" , "type" : "WORKS_AT" , "id" : "edge-1" }])
2382+ g = self ._binding_graph (edges = edges )
2383+ select_result = g .gfql (self ._binding_ops () + [select (items = [("rel" , "workAt" )])])
2384+ return_result = g .gfql (self ._binding_ops () + [return_ ([("rel" , "workAt" )])])
2385+ assert select_result ._nodes ["rel" ].tolist () == ["[:WORKS_AT {id: 'edge-1'}]" ]
2386+ assert select_result ._nodes ["rel" ].tolist () == return_result ._nodes ["rel" ].tolist ()
2387+
2388+ def test_select_bare_relationship_alias_with_empty_type_treated_as_missing_type (self ):
2389+ edges = pd .DataFrame ([{"s" : "p3" , "d" : "c1" , "type" : "" , "workFrom" : 2010 }])
2390+ g = self ._binding_graph (edges = edges )
2391+ select_result = g .gfql (self ._binding_ops (edge_match = {}) + [select (items = [("rel" , "workAt" )])])
2392+ return_result = g .gfql (self ._binding_ops (edge_match = {}) + [return_ ([("rel" , "workAt" )])])
2393+ assert select_result ._nodes ["rel" ].tolist () == ["[{workFrom: 2010}]" ]
2394+ assert select_result ._nodes ["rel" ].tolist () == return_result ._nodes ["rel" ].tolist ()
2395+
23722396 def test_select_node_alias_without_node_id_does_not_render_as_relationship (self ):
23732397 g = self ._binding_graph ()
23742398 with pytest .raises ((ValueError , GFQLTypeError ), match = "unsupported token in row expression" ):
23752399 g .gfql (self ._binding_ops () + [drop_cols (["friend" , "friend.id" ]), select (items = [("x" , "friend" )])])
2400+
2401+ def test_select_node_alias_with_type_property_without_node_id_does_not_render_as_relationship (self ):
2402+ nodes = pd .DataFrame ([
2403+ {"id" : "p3" , "label__Person" : True , "label__Company" : False , "name" : "" , "type" : "PERSON" },
2404+ {"id" : "c1" , "label__Person" : False , "label__Company" : True , "name" : "Acme" , "type" : "COMPANY" },
2405+ ])
2406+ g = self ._binding_graph (nodes = nodes )
2407+ with pytest .raises ((ValueError , GFQLTypeError ), match = "unsupported token in row expression" ):
2408+ g .gfql (self ._binding_ops () + [drop_cols (["friend" , "friend.id" ]), select (items = [("x" , "friend" )])])
2409+
2410+ def test_select_plain_rows_alias_like_columns_do_not_render_relationship_text (self ):
2411+ nodes_df = pd .DataFrame ({"id" : ["a" ], "a.type" : ["X" ], "a.k" : [1 ]})
2412+ with pytest .raises ((ValueError , GFQLTypeError ), match = "unsupported token in row expression" ):
2413+ _run_node_steps (nodes_df , [rows (), select ([("x" , "a" )])], edges_df = _self_loop_edges (nodes_df ))
0 commit comments