Skip to content

Commit

Permalink
Merge pull request #78 from hasura/djh/NDAT-1028/add-relationships-test
Browse files Browse the repository at this point in the history
chore: add very recursive relationship test
  • Loading branch information
danieljharvey authored Nov 20, 2023
2 parents d3c5950 + 2bd3790 commit 0ee9f0c
Show file tree
Hide file tree
Showing 3 changed files with 326 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
{
"collection": "Artist",
"query": {
"fields": {
"0Name": {
"type": "column",
"column": "Name",
"arguments": {}
},
"Albums": {
"type": "relationship",
"relationship": "ArtistAlbums",
"arguments": {},
"query": {
"fields": {
"0Title": {
"type": "column",
"column": "Title",
"arguments": {}
},
"Artist": {
"type": "relationship",
"relationship": "AlbumArtist",
"arguments": {},
"query": {
"fields": {
"0ArtistId": {
"type": "column",
"column": "ArtistId",
"arguments": {}
},

"Albums": {
"type": "relationship",
"relationship": "ArtistAlbums",
"arguments": {},
"query": {
"fields": {
"0Title": {
"type": "column",
"column": "Title",
"arguments": {}
},
"Artist": {
"type": "relationship",
"relationship": "AlbumArtist",
"arguments": {},
"query": {
"fields": {
"0Name": {
"type": "column",
"column": "Name",
"arguments": {}
}
}
}
}
},
"order_by": {
"elements": [
{
"order_direction": "asc",
"target": {
"type": "column",
"name": "AlbumId",
"path": []
}
}
]
},
"limit": 3
}
}
}
}
}
},
"order_by": {
"elements": [
{
"order_direction": "asc",
"target": {
"type": "column",
"name": "AlbumId",
"path": []
}
}
]
},
"limit": 3
}
}
},
"order_by": {
"elements": [
{
"order_direction": "asc",
"target": {
"type": "column",
"name": "ArtistId",
"path": []
}
}
]
},
"limit": 3
},
"arguments": {},
"collection_relationships": {
"ArtistAlbums": {
"column_mapping": {
"ArtistId": "ArtistId"
},
"relationship_type": "array",
"source_collection_or_type": "Artist",
"target_collection": "Album",
"arguments": {}
},
"AlbumArtist": {
"column_mapping": {
"ArtistId": "ArtistId"
},
"relationship_type": "object",
"source_collection_or_type": "Album",
"target_collection": "Artist",
"arguments": {}
}
}
}
6 changes: 6 additions & 0 deletions crates/ndc-sqlserver/tests/query_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,4 +268,10 @@ mod relationships {
let result = run_query("dup_array_relationship").await;
insta::assert_json_snapshot!(result);
}

#[tokio::test]
async fn very_nested_recursive_relationship() {
let result = run_query("very_nested_recursive_relationship").await;
insta::assert_json_snapshot!(result);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
---
source: crates/ndc-sqlserver/tests/query_tests.rs
expression: result
---
[
{
"rows": [
{
"0Name": "AC/DC",
"Albums": {
"rows": [
{
"0Title": "For Those About To Rock We Salute You",
"Artist": {
"rows": [
{
"0ArtistId": 1,
"Albums": {
"rows": [
{
"0Title": "For Those About To Rock We Salute You",
"Artist": {
"rows": [
{
"0Name": "AC/DC"
}
]
}
},
{
"0Title": "Let There Be Rock",
"Artist": {
"rows": [
{
"0Name": "AC/DC"
}
]
}
}
]
}
}
]
}
},
{
"0Title": "Let There Be Rock",
"Artist": {
"rows": [
{
"0ArtistId": 1,
"Albums": {
"rows": [
{
"0Title": "For Those About To Rock We Salute You",
"Artist": {
"rows": [
{
"0Name": "AC/DC"
}
]
}
},
{
"0Title": "Let There Be Rock",
"Artist": {
"rows": [
{
"0Name": "AC/DC"
}
]
}
}
]
}
}
]
}
}
]
}
},
{
"0Name": "Accept",
"Albums": {
"rows": [
{
"0Title": "Balls to the Wall",
"Artist": {
"rows": [
{
"0ArtistId": 2,
"Albums": {
"rows": [
{
"0Title": "Balls to the Wall",
"Artist": {
"rows": [
{
"0Name": "Accept"
}
]
}
},
{
"0Title": "Restless and Wild",
"Artist": {
"rows": [
{
"0Name": "Accept"
}
]
}
}
]
}
}
]
}
},
{
"0Title": "Restless and Wild",
"Artist": {
"rows": [
{
"0ArtistId": 2,
"Albums": {
"rows": [
{
"0Title": "Balls to the Wall",
"Artist": {
"rows": [
{
"0Name": "Accept"
}
]
}
},
{
"0Title": "Restless and Wild",
"Artist": {
"rows": [
{
"0Name": "Accept"
}
]
}
}
]
}
}
]
}
}
]
}
},
{
"0Name": "Aerosmith",
"Albums": {
"rows": [
{
"0Title": "Big Ones",
"Artist": {
"rows": [
{
"0ArtistId": 3,
"Albums": {
"rows": [
{
"0Title": "Big Ones",
"Artist": {
"rows": [
{
"0Name": "Aerosmith"
}
]
}
}
]
}
}
]
}
}
]
}
}
]
}
]

0 comments on commit 0ee9f0c

Please sign in to comment.