Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add very recursive relationship test #78

Merged
merged 1 commit into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
}
]
}
}
]
}
}
]
}
}
]
}
}
]
}
]