File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -32,6 +32,17 @@ def test_query_aggregation(db):
3232 assert rows (result ) == [[2 ]]
3333
3434
35+ def test_whole_entity_projection_is_a_display_literal (db ):
36+ """Pins the result contract: a whole node or relationship projects as an
37+ openCypher display-literal string, not a property map. Changing this shape
38+ is an API break for every consumer of query()."""
39+ db .query ("CREATE (:Person {name: 'Ada'})-[:KNOWS {since: 2020}]->(:Person {name: 'Bob'})" )
40+ nodes = json .loads (db .query ("MATCH (n:Person {name: 'Ada'}) RETURN n" ))
41+ assert rows (nodes ) == [["(:Person {name: 'Ada'})" ]]
42+ rels = json .loads (db .query ("MATCH ()-[r:KNOWS]->() RETURN r" ))
43+ assert rows (rels ) == [["[:KNOWS {since: 2020}]" ]]
44+
45+
3546def test_explain_returns_plan_text (db ):
3647 plan = db .explain ("MATCH (n:Person) RETURN n.name" )
3748 assert isinstance (plan , str )
Original file line number Diff line number Diff line change @@ -345,6 +345,23 @@ async fn cypher_query_returns_columns_and_records() {
345345 assert_eq ! ( body[ "records" ] , json!( [ [ "Ada" ] , [ "Grace" ] ] ) ) ;
346346}
347347
348+ #[ tokio:: test]
349+ async fn whole_entity_projection_is_a_display_literal ( ) {
350+ // Pins the result contract: a whole node projects as an openCypher
351+ // display-literal string, not a property map. Changing this shape is an
352+ // API break for every consumer of /v1/query.
353+ let ( graph, _dir) = fresh_graph ( ) ;
354+ create_node ( & graph, "Person" , json ! ( { "name" : "Ada" } ) ) . await ;
355+
356+ let ( status, body) = send (
357+ & graph,
358+ post ( "/v1/query" , json ! ( { "query" : "MATCH (n:Person) RETURN n" } ) ) ,
359+ )
360+ . await ;
361+ assert_eq ! ( status, StatusCode :: OK , "query body: {body}" ) ;
362+ assert_eq ! ( body[ "records" ] , json!( [ [ "(:Person {name: 'Ada'})" ] ] ) ) ;
363+ }
364+
348365#[ tokio:: test]
349366async fn cypher_query_with_params ( ) {
350367 let ( graph, _dir) = fresh_graph ( ) ;
You can’t perform that action at this time.
0 commit comments