diff --git a/Cargo.lock b/Cargo.lock index d5abbcdf..0cbdd27d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1731,6 +1731,7 @@ dependencies = [ "serde_json", "sqlformat", "tiberius", + "tokio-stream", "tracing", ] diff --git a/crates/ndc-sqlserver/tests/goldenfiles/select_many.json b/crates/ndc-sqlserver/tests/goldenfiles/select_many.json new file mode 100644 index 00000000..98a5a04c --- /dev/null +++ b/crates/ndc-sqlserver/tests/goldenfiles/select_many.json @@ -0,0 +1,14 @@ +{ + "collection": "Album", + "query": { + "fields": { + "ArtistId": { "type": "column", "column": "ArtistId" }, + "Title": { + "type": "column", + "column": "Title" + } + } + }, + "arguments": {}, + "collection_relationships": {} +} diff --git a/crates/ndc-sqlserver/tests/query_tests.rs b/crates/ndc-sqlserver/tests/query_tests.rs index e059064f..2d787094 100644 --- a/crates/ndc-sqlserver/tests/query_tests.rs +++ b/crates/ndc-sqlserver/tests/query_tests.rs @@ -19,6 +19,12 @@ mod basic { let result = run_query("select_int_and_string").await; insta::assert_json_snapshot!(result); } + + #[tokio::test] + async fn select_many() { + let result = run_query("select_many").await; + insta::assert_json_snapshot!(result); + } } mod predicates { diff --git a/crates/ndc-sqlserver/tests/snapshots/query_tests__basic__select_many.snap b/crates/ndc-sqlserver/tests/snapshots/query_tests__basic__select_many.snap new file mode 100644 index 00000000..403d8475 --- /dev/null +++ b/crates/ndc-sqlserver/tests/snapshots/query_tests__basic__select_many.snap @@ -0,0 +1,1398 @@ +--- +source: crates/ndc-sqlserver/tests/query_tests.rs +expression: result +--- +[ + { + "rows": [ + { + "ArtistId": 1, + "Title": "For Those About To Rock We Salute You" + }, + { + "ArtistId": 2, + "Title": "Balls to the Wall" + }, + { + "ArtistId": 2, + "Title": "Restless and Wild" + }, + { + "ArtistId": 1, + "Title": "Let There Be Rock" + }, + { + "ArtistId": 3, + "Title": "Big Ones" + }, + { + "ArtistId": 4, + "Title": "Jagged Little Pill" + }, + { + "ArtistId": 5, + "Title": "Facelift" + }, + { + "ArtistId": 6, + "Title": "Warner 25 Anos" + }, + { + "ArtistId": 7, + "Title": "Plays Metallica By Four Cellos" + }, + { + "ArtistId": 8, + "Title": "Audioslave" + }, + { + "ArtistId": 8, + "Title": "Out Of Exile" + }, + { + "ArtistId": 9, + "Title": "BackBeat Soundtrack" + }, + { + "ArtistId": 10, + "Title": "The Best Of Billy Cobham" + }, + { + "ArtistId": 11, + "Title": "Alcohol Fueled Brewtality Live! [Disc 1]" + }, + { + "ArtistId": 11, + "Title": "Alcohol Fueled Brewtality Live! [Disc 2]" + }, + { + "ArtistId": 12, + "Title": "Black Sabbath" + }, + { + "ArtistId": 12, + "Title": "Black Sabbath Vol. 4 (Remaster)" + }, + { + "ArtistId": 13, + "Title": "Body Count" + }, + { + "ArtistId": 14, + "Title": "Chemical Wedding" + }, + { + "ArtistId": 15, + "Title": "The Best Of Buddy Guy - The Millenium Collection" + }, + { + "ArtistId": 16, + "Title": "Prenda Minha" + }, + { + "ArtistId": 16, + "Title": "Sozinho Remix Ao Vivo" + }, + { + "ArtistId": 17, + "Title": "Minha Historia" + }, + { + "ArtistId": 18, + "Title": "Afrociberdelia" + }, + { + "ArtistId": 18, + "Title": "Da Lama Ao Caos" + }, + { + "ArtistId": 19, + "Title": "Acústico MTV [Live]" + }, + { + "ArtistId": 19, + "Title": "Cidade Negra - Hits" + }, + { + "ArtistId": 20, + "Title": "Na Pista" + }, + { + "ArtistId": 21, + "Title": "Axé Bahia 2001" + }, + { + "ArtistId": 22, + "Title": "BBC Sessions [Disc 1] [Live]" + }, + { + "ArtistId": 23, + "Title": "Bongo Fury" + }, + { + "ArtistId": 21, + "Title": "Carnaval 2001" + }, + { + "ArtistId": 24, + "Title": "Chill: Brazil (Disc 1)" + }, + { + "ArtistId": 6, + "Title": "Chill: Brazil (Disc 2)" + }, + { + "ArtistId": 50, + "Title": "Garage Inc. (Disc 1)" + }, + { + "ArtistId": 51, + "Title": "Greatest Hits II" + }, + { + "ArtistId": 52, + "Title": "Greatest Kiss" + }, + { + "ArtistId": 53, + "Title": "Heart of the Night" + }, + { + "ArtistId": 54, + "Title": "International Superhits" + }, + { + "ArtistId": 55, + "Title": "Into The Light" + }, + { + "ArtistId": 56, + "Title": "Meus Momentos" + }, + { + "ArtistId": 57, + "Title": "Minha História" + }, + { + "ArtistId": 58, + "Title": "MK III The Final Concerts [Disc 1]" + }, + { + "ArtistId": 22, + "Title": "Physical Graffiti [Disc 1]" + }, + { + "ArtistId": 21, + "Title": "Sambas De Enredo 2001" + }, + { + "ArtistId": 59, + "Title": "Supernatural" + }, + { + "ArtistId": 37, + "Title": "The Best of Ed Motta" + }, + { + "ArtistId": 68, + "Title": "The Essential Miles Davis [Disc 1]" + }, + { + "ArtistId": 68, + "Title": "The Essential Miles Davis [Disc 2]" + }, + { + "ArtistId": 58, + "Title": "The Final Concerts (Disc 2)" + }, + { + "ArtistId": 69, + "Title": "Up An' Atom" + }, + { + "ArtistId": 70, + "Title": "Vinícius De Moraes - Sem Limite" + }, + { + "ArtistId": 21, + "Title": "Vozes do MPB" + }, + { + "ArtistId": 76, + "Title": "Chronicle, Vol. 1" + }, + { + "ArtistId": 76, + "Title": "Chronicle, Vol. 2" + }, + { + "ArtistId": 77, + "Title": "Cássia Eller - Coleção Sem Limite [Disc 2]" + }, + { + "ArtistId": 77, + "Title": "Cássia Eller - Sem Limite [Disc 1]" + }, + { + "ArtistId": 58, + "Title": "Come Taste The Band" + }, + { + "ArtistId": 58, + "Title": "Deep Purple In Rock" + }, + { + "ArtistId": 58, + "Title": "Fireball" + }, + { + "ArtistId": 58, + "Title": "Knocking at Your Back Door: The Best Of Deep Purple in the 80's" + }, + { + "ArtistId": 58, + "Title": "Machine Head" + }, + { + "ArtistId": 58, + "Title": "Purpendicular" + }, + { + "ArtistId": 58, + "Title": "Slaves And Masters" + }, + { + "ArtistId": 58, + "Title": "Stormbringer" + }, + { + "ArtistId": 58, + "Title": "The Battle Rages On" + }, + { + "ArtistId": 78, + "Title": "Vault: Def Leppard's Greatest Hits" + }, + { + "ArtistId": 79, + "Title": "Outbreak" + }, + { + "ArtistId": 80, + "Title": "Djavan Ao Vivo - Vol. 02" + }, + { + "ArtistId": 80, + "Title": "Djavan Ao Vivo - Vol. 1" + }, + { + "ArtistId": 41, + "Title": "Elis Regina-Minha História" + }, + { + "ArtistId": 81, + "Title": "The Cream Of Clapton" + }, + { + "ArtistId": 81, + "Title": "Unplugged" + }, + { + "ArtistId": 82, + "Title": "Album Of The Year" + }, + { + "ArtistId": 82, + "Title": "Angel Dust" + }, + { + "ArtistId": 82, + "Title": "King For A Day Fool For A Lifetime" + }, + { + "ArtistId": 82, + "Title": "The Real Thing" + }, + { + "ArtistId": 83, + "Title": "Deixa Entrar" + }, + { + "ArtistId": 84, + "Title": "In Your Honor [Disc 1]" + }, + { + "ArtistId": 84, + "Title": "In Your Honor [Disc 2]" + }, + { + "ArtistId": 84, + "Title": "One By One" + }, + { + "ArtistId": 84, + "Title": "The Colour And The Shape" + }, + { + "ArtistId": 85, + "Title": "My Way: The Best Of Frank Sinatra [Disc 1]" + }, + { + "ArtistId": 86, + "Title": "Roda De Funk" + }, + { + "ArtistId": 27, + "Title": "As Canções de Eu Tu Eles" + }, + { + "ArtistId": 27, + "Title": "Quanta Gente Veio Ver (Live)" + }, + { + "ArtistId": 27, + "Title": "Quanta Gente Veio ver--Bônus De Carnaval" + }, + { + "ArtistId": 87, + "Title": "Faceless" + }, + { + "ArtistId": 54, + "Title": "American Idiot" + }, + { + "ArtistId": 88, + "Title": "Appetite for Destruction" + }, + { + "ArtistId": 88, + "Title": "Use Your Illusion I" + }, + { + "ArtistId": 88, + "Title": "Use Your Illusion II" + }, + { + "ArtistId": 89, + "Title": "Blue Moods" + }, + { + "ArtistId": 90, + "Title": "A Matter of Life and Death" + }, + { + "ArtistId": 90, + "Title": "A Real Dead One" + }, + { + "ArtistId": 90, + "Title": "A Real Live One" + }, + { + "ArtistId": 90, + "Title": "Brave New World" + }, + { + "ArtistId": 90, + "Title": "Dance Of Death" + }, + { + "ArtistId": 90, + "Title": "Fear Of The Dark" + }, + { + "ArtistId": 90, + "Title": "Iron Maiden" + }, + { + "ArtistId": 90, + "Title": "Killers" + }, + { + "ArtistId": 90, + "Title": "Live After Death" + }, + { + "ArtistId": 90, + "Title": "Live At Donington 1992 (Disc 1)" + }, + { + "ArtistId": 90, + "Title": "Live At Donington 1992 (Disc 2)" + }, + { + "ArtistId": 90, + "Title": "No Prayer For The Dying" + }, + { + "ArtistId": 90, + "Title": "Piece Of Mind" + }, + { + "ArtistId": 90, + "Title": "Powerslave" + }, + { + "ArtistId": 90, + "Title": "Rock In Rio [CD1]" + }, + { + "ArtistId": 90, + "Title": "Rock In Rio [CD2]" + }, + { + "ArtistId": 90, + "Title": "Seventh Son of a Seventh Son" + }, + { + "ArtistId": 90, + "Title": "Somewhere in Time" + }, + { + "ArtistId": 90, + "Title": "The Number of The Beast" + }, + { + "ArtistId": 90, + "Title": "The X Factor" + }, + { + "ArtistId": 90, + "Title": "Virtual XI" + }, + { + "ArtistId": 91, + "Title": "Sex Machine" + }, + { + "ArtistId": 92, + "Title": "Emergency On Planet Earth" + }, + { + "ArtistId": 92, + "Title": "Synkronized" + }, + { + "ArtistId": 92, + "Title": "The Return Of The Space Cowboy" + }, + { + "ArtistId": 93, + "Title": "Get Born" + }, + { + "ArtistId": 94, + "Title": "Are You Experienced?" + }, + { + "ArtistId": 95, + "Title": "Surfing with the Alien (Remastered)" + }, + { + "ArtistId": 46, + "Title": "Jorge Ben Jor 25 Anos" + }, + { + "ArtistId": 96, + "Title": "Jota Quest-1995" + }, + { + "ArtistId": 97, + "Title": "Cafezinho" + }, + { + "ArtistId": 98, + "Title": "Living After Midnight" + }, + { + "ArtistId": 52, + "Title": "Unplugged [Live]" + }, + { + "ArtistId": 22, + "Title": "BBC Sessions [Disc 2] [Live]" + }, + { + "ArtistId": 22, + "Title": "Coda" + }, + { + "ArtistId": 22, + "Title": "Houses Of The Holy" + }, + { + "ArtistId": 22, + "Title": "In Through The Out Door" + }, + { + "ArtistId": 22, + "Title": "IV" + }, + { + "ArtistId": 22, + "Title": "Led Zeppelin I" + }, + { + "ArtistId": 22, + "Title": "Led Zeppelin II" + }, + { + "ArtistId": 22, + "Title": "Led Zeppelin III" + }, + { + "ArtistId": 22, + "Title": "Physical Graffiti [Disc 2]" + }, + { + "ArtistId": 22, + "Title": "Presence" + }, + { + "ArtistId": 22, + "Title": "The Song Remains The Same (Disc 1)" + }, + { + "ArtistId": 22, + "Title": "The Song Remains The Same (Disc 2)" + }, + { + "ArtistId": 99, + "Title": "A TempestadeTempestade Ou O Livro Dos Dias" + }, + { + "ArtistId": 99, + "Title": "Mais Do Mesmo" + }, + { + "ArtistId": 100, + "Title": "Greatest Hits" + }, + { + "ArtistId": 101, + "Title": "Lulu Santos - RCA 100 Anos De Música - Álbum 01" + }, + { + "ArtistId": 101, + "Title": "Lulu Santos - RCA 100 Anos De Música - Álbum 02" + }, + { + "ArtistId": 102, + "Title": "Misplaced Childhood" + }, + { + "ArtistId": 103, + "Title": "Barulhinho Bom" + }, + { + "ArtistId": 104, + "Title": "Seek And Shall Find: More Of The Best (1963-1981)" + }, + { + "ArtistId": 105, + "Title": "The Best Of Men At Work" + }, + { + "ArtistId": 50, + "Title": "Black Album" + }, + { + "ArtistId": 50, + "Title": "Garage Inc. (Disc 2)" + }, + { + "ArtistId": 50, + "Title": "Kill 'Em All" + }, + { + "ArtistId": 50, + "Title": "Load" + }, + { + "ArtistId": 50, + "Title": "Master Of Puppets" + }, + { + "ArtistId": 50, + "Title": "ReLoad" + }, + { + "ArtistId": 50, + "Title": "Ride The Lightning" + }, + { + "ArtistId": 50, + "Title": "St. Anger" + }, + { + "ArtistId": 50, + "Title": "...And Justice For All" + }, + { + "ArtistId": 68, + "Title": "Miles Ahead" + }, + { + "ArtistId": 42, + "Title": "Milton Nascimento Ao Vivo" + }, + { + "ArtistId": 42, + "Title": "Minas" + }, + { + "ArtistId": 106, + "Title": "Ace Of Spades" + }, + { + "ArtistId": 108, + "Title": "Demorou..." + }, + { + "ArtistId": 109, + "Title": "Motley Crue Greatest Hits" + }, + { + "ArtistId": 110, + "Title": "From The Muddy Banks Of The Wishkah [Live]" + }, + { + "ArtistId": 110, + "Title": "Nevermind" + }, + { + "ArtistId": 111, + "Title": "Compositores" + }, + { + "ArtistId": 112, + "Title": "Olodum" + }, + { + "ArtistId": 113, + "Title": "Acústico MTV" + }, + { + "ArtistId": 113, + "Title": "Arquivo II" + }, + { + "ArtistId": 113, + "Title": "Arquivo Os Paralamas Do Sucesso" + }, + { + "ArtistId": 114, + "Title": "Bark at the Moon (Remastered)" + }, + { + "ArtistId": 114, + "Title": "Blizzard of Ozz" + }, + { + "ArtistId": 114, + "Title": "Diary of a Madman (Remastered)" + }, + { + "ArtistId": 114, + "Title": "No More Tears (Remastered)" + }, + { + "ArtistId": 114, + "Title": "Tribute" + }, + { + "ArtistId": 115, + "Title": "Walking Into Clarksdale" + }, + { + "ArtistId": 116, + "Title": "Original Soundtracks 1" + }, + { + "ArtistId": 117, + "Title": "The Beast Live" + }, + { + "ArtistId": 118, + "Title": "Live On Two Legs [Live]" + }, + { + "ArtistId": 118, + "Title": "Pearl Jam" + }, + { + "ArtistId": 118, + "Title": "Riot Act" + }, + { + "ArtistId": 118, + "Title": "Ten" + }, + { + "ArtistId": 118, + "Title": "Vs." + }, + { + "ArtistId": 120, + "Title": "Dark Side Of The Moon" + }, + { + "ArtistId": 121, + "Title": "Os Cães Ladram Mas A Caravana Não Pára" + }, + { + "ArtistId": 51, + "Title": "Greatest Hits I" + }, + { + "ArtistId": 51, + "Title": "News Of The World" + }, + { + "ArtistId": 122, + "Title": "Out Of Time" + }, + { + "ArtistId": 124, + "Title": "Green" + }, + { + "ArtistId": 124, + "Title": "New Adventures In Hi-Fi" + }, + { + "ArtistId": 124, + "Title": "The Best Of R.E.M.: The IRS Years" + }, + { + "ArtistId": 125, + "Title": "Cesta Básica" + }, + { + "ArtistId": 126, + "Title": "Raul Seixas" + }, + { + "ArtistId": 127, + "Title": "Blood Sugar Sex Magik" + }, + { + "ArtistId": 127, + "Title": "By The Way" + }, + { + "ArtistId": 127, + "Title": "Californication" + }, + { + "ArtistId": 128, + "Title": "Retrospective I (1974-1980)" + }, + { + "ArtistId": 59, + "Title": "Santana - As Years Go By" + }, + { + "ArtistId": 59, + "Title": "Santana Live" + }, + { + "ArtistId": 130, + "Title": "Maquinarama" + }, + { + "ArtistId": 130, + "Title": "O Samba Poconé" + }, + { + "ArtistId": 131, + "Title": "Judas 0: B-Sides and Rarities" + }, + { + "ArtistId": 131, + "Title": "Rotten Apples: Greatest Hits" + }, + { + "ArtistId": 132, + "Title": "A-Sides" + }, + { + "ArtistId": 53, + "Title": "Morning Dance" + }, + { + "ArtistId": 133, + "Title": "In Step" + }, + { + "ArtistId": 134, + "Title": "Core" + }, + { + "ArtistId": 135, + "Title": "Mezmerize" + }, + { + "ArtistId": 136, + "Title": "[1997] Black Light Syndrome" + }, + { + "ArtistId": 137, + "Title": "Live [Disc 1]" + }, + { + "ArtistId": 137, + "Title": "Live [Disc 2]" + }, + { + "ArtistId": 138, + "Title": "The Singles" + }, + { + "ArtistId": 139, + "Title": "Beyond Good And Evil" + }, + { + "ArtistId": 139, + "Title": "Pure Cult: The Best Of The Cult (For Rockers, Ravers, Lovers & Sinners) [UK]" + }, + { + "ArtistId": 140, + "Title": "The Doors" + }, + { + "ArtistId": 141, + "Title": "The Police Greatest Hits" + }, + { + "ArtistId": 142, + "Title": "Hot Rocks, 1964-1971 (Disc 1)" + }, + { + "ArtistId": 142, + "Title": "No Security" + }, + { + "ArtistId": 142, + "Title": "Voodoo Lounge" + }, + { + "ArtistId": 143, + "Title": "Tangents" + }, + { + "ArtistId": 143, + "Title": "Transmission" + }, + { + "ArtistId": 144, + "Title": "My Generation - The Very Best Of The Who" + }, + { + "ArtistId": 145, + "Title": "Serie Sem Limite (Disc 1)" + }, + { + "ArtistId": 145, + "Title": "Serie Sem Limite (Disc 2)" + }, + { + "ArtistId": 146, + "Title": "Acústico" + }, + { + "ArtistId": 146, + "Title": "Volume Dois" + }, + { + "ArtistId": 147, + "Title": "Battlestar Galactica: The Story So Far" + }, + { + "ArtistId": 147, + "Title": "Battlestar Galactica, Season 3" + }, + { + "ArtistId": 148, + "Title": "Heroes, Season 1" + }, + { + "ArtistId": 149, + "Title": "Lost, Season 3" + }, + { + "ArtistId": 149, + "Title": "Lost, Season 1" + }, + { + "ArtistId": 149, + "Title": "Lost, Season 2" + }, + { + "ArtistId": 150, + "Title": "Achtung Baby" + }, + { + "ArtistId": 150, + "Title": "All That You Can't Leave Behind" + }, + { + "ArtistId": 150, + "Title": "B-Sides 1980-1990" + }, + { + "ArtistId": 150, + "Title": "How To Dismantle An Atomic Bomb" + }, + { + "ArtistId": 150, + "Title": "Pop" + }, + { + "ArtistId": 150, + "Title": "Rattle And Hum" + }, + { + "ArtistId": 150, + "Title": "The Best Of 1980-1990" + }, + { + "ArtistId": 150, + "Title": "War" + }, + { + "ArtistId": 150, + "Title": "Zooropa" + }, + { + "ArtistId": 151, + "Title": "UB40 The Best Of - Volume Two [UK]" + }, + { + "ArtistId": 152, + "Title": "Diver Down" + }, + { + "ArtistId": 152, + "Title": "The Best Of Van Halen, Vol. I" + }, + { + "ArtistId": 152, + "Title": "Van Halen" + }, + { + "ArtistId": 152, + "Title": "Van Halen III" + }, + { + "ArtistId": 153, + "Title": "Contraband" + }, + { + "ArtistId": 72, + "Title": "Vinicius De Moraes" + }, + { + "ArtistId": 155, + "Title": "Ao Vivo [IMPORT]" + }, + { + "ArtistId": 156, + "Title": "The Office, Season 1" + }, + { + "ArtistId": 156, + "Title": "The Office, Season 2" + }, + { + "ArtistId": 156, + "Title": "The Office, Season 3" + }, + { + "ArtistId": 157, + "Title": "Un-Led-Ed" + }, + { + "ArtistId": 158, + "Title": "Battlestar Galactica (Classic), Season 1" + }, + { + "ArtistId": 159, + "Title": "Aquaman" + }, + { + "ArtistId": 150, + "Title": "Instant Karma: The Amnesty International Campaign to Save Darfur" + }, + { + "ArtistId": 114, + "Title": "Speak of the Devil" + }, + { + "ArtistId": 179, + "Title": "20th Century Masters - The Millennium Collection: The Best of Scorpions" + }, + { + "ArtistId": 180, + "Title": "House of Pain" + }, + { + "ArtistId": 36, + "Title": "Radio Brasil (O Som da Jovem Vanguarda) - Seleccao de Henrique Amaro" + }, + { + "ArtistId": 196, + "Title": "Cake: B-Sides and Rarities" + }, + { + "ArtistId": 149, + "Title": "LOST, Season 4" + }, + { + "ArtistId": 197, + "Title": "Quiet Songs" + }, + { + "ArtistId": 198, + "Title": "Muso Ko" + }, + { + "ArtistId": 199, + "Title": "Realize" + }, + { + "ArtistId": 200, + "Title": "Every Kind of Light" + }, + { + "ArtistId": 201, + "Title": "Duos II" + }, + { + "ArtistId": 202, + "Title": "Worlds" + }, + { + "ArtistId": 203, + "Title": "The Best of Beethoven" + }, + { + "ArtistId": 204, + "Title": "Temple of the Dog" + }, + { + "ArtistId": 205, + "Title": "Carry On" + }, + { + "ArtistId": 8, + "Title": "Revelations" + }, + { + "ArtistId": 206, + "Title": "Adorate Deum: Gregorian Chant from the Proper of the Mass" + }, + { + "ArtistId": 207, + "Title": "Allegri: Miserere" + }, + { + "ArtistId": 208, + "Title": "Pachelbel: Canon & Gigue" + }, + { + "ArtistId": 209, + "Title": "Vivaldi: The Four Seasons" + }, + { + "ArtistId": 210, + "Title": "Bach: Violin Concertos" + }, + { + "ArtistId": 211, + "Title": "Bach: Goldberg Variations" + }, + { + "ArtistId": 212, + "Title": "Bach: The Cello Suites" + }, + { + "ArtistId": 213, + "Title": "Handel: The Messiah (Highlights)" + }, + { + "ArtistId": 214, + "Title": "The World of Classical Favourites" + }, + { + "ArtistId": 215, + "Title": "Sir Neville Marriner: A Celebration" + }, + { + "ArtistId": 216, + "Title": "Mozart: Wind Concertos" + }, + { + "ArtistId": 217, + "Title": "Haydn: Symphonies 99 - 104" + }, + { + "ArtistId": 218, + "Title": "Beethoven: Symhonies Nos. 5 & 6" + }, + { + "ArtistId": 219, + "Title": "A Soprano Inspired" + }, + { + "ArtistId": 220, + "Title": "Great Opera Choruses" + }, + { + "ArtistId": 221, + "Title": "Wagner: Favourite Overtures" + }, + { + "ArtistId": 222, + "Title": "Fauré: Requiem, Ravel: Pavane & Others" + }, + { + "ArtistId": 223, + "Title": "Tchaikovsky: The Nutcracker" + }, + { + "ArtistId": 224, + "Title": "The Last Night of the Proms" + }, + { + "ArtistId": 225, + "Title": "Puccini: Madama Butterfly - Highlights" + }, + { + "ArtistId": 226, + "Title": "Holst: The Planets, Op. 32 & Vaughan Williams: Fantasies" + }, + { + "ArtistId": 227, + "Title": "Pavarotti's Opera Made Easy" + }, + { + "ArtistId": 228, + "Title": "Great Performances - Barber's Adagio and Other Romantic Favorites for Strings" + }, + { + "ArtistId": 229, + "Title": "Carmina Burana" + }, + { + "ArtistId": 230, + "Title": "A Copland Celebration, Vol. I" + }, + { + "ArtistId": 231, + "Title": "Bach: Toccata & Fugue in D Minor" + }, + { + "ArtistId": 232, + "Title": "Prokofiev: Symphony No.1" + }, + { + "ArtistId": 233, + "Title": "Scheherazade" + }, + { + "ArtistId": 234, + "Title": "Bach: The Brandenburg Concertos" + }, + { + "ArtistId": 235, + "Title": "Chopin: Piano Concertos Nos. 1 & 2" + }, + { + "ArtistId": 236, + "Title": "Mascagni: Cavalleria Rusticana" + }, + { + "ArtistId": 237, + "Title": "Sibelius: Finlandia" + }, + { + "ArtistId": 238, + "Title": "Beethoven Piano Sonatas: Moonlight & Pastorale" + }, + { + "ArtistId": 240, + "Title": "Great Recordings of the Century - Mahler: Das Lied von der Erde" + }, + { + "ArtistId": 241, + "Title": "Elgar: Cello Concerto & Vaughan Williams: Fantasias" + }, + { + "ArtistId": 242, + "Title": "Adams, John: The Chairman Dances" + }, + { + "ArtistId": 243, + "Title": "Tchaikovsky: 1812 Festival Overture, Op.49, Capriccio Italien & Beethoven: Wellington's Victory" + }, + { + "ArtistId": 244, + "Title": "Palestrina: Missa Papae Marcelli & Allegri: Miserere" + }, + { + "ArtistId": 245, + "Title": "Prokofiev: Romeo & Juliet" + }, + { + "ArtistId": 226, + "Title": "Strauss: Waltzes" + }, + { + "ArtistId": 245, + "Title": "Berlioz: Symphonie Fantastique" + }, + { + "ArtistId": 246, + "Title": "Bizet: Carmen Highlights" + }, + { + "ArtistId": 247, + "Title": "English Renaissance" + }, + { + "ArtistId": 208, + "Title": "Handel: Music for the Royal Fireworks (Original Version 1749)" + }, + { + "ArtistId": 248, + "Title": "Grieg: Peer Gynt Suites & Sibelius: Pelléas et Mélisande" + }, + { + "ArtistId": 249, + "Title": "Mozart Gala: Famous Arias" + }, + { + "ArtistId": 250, + "Title": "SCRIABIN: Vers la flamme" + }, + { + "ArtistId": 251, + "Title": "Armada: Music from the Courts of England and Spain" + }, + { + "ArtistId": 248, + "Title": "Mozart: Symphonies Nos. 40 & 41" + }, + { + "ArtistId": 252, + "Title": "Back to Black" + }, + { + "ArtistId": 252, + "Title": "Frank" + }, + { + "ArtistId": 253, + "Title": "Carried to Dust (Bonus Track Version)" + }, + { + "ArtistId": 254, + "Title": "Beethoven: Symphony No. 6 'Pastoral' Etc." + }, + { + "ArtistId": 255, + "Title": "Bartok: Violin & Viola Concertos" + }, + { + "ArtistId": 256, + "Title": "Mendelssohn: A Midsummer Night's Dream" + }, + { + "ArtistId": 257, + "Title": "Bach: Orchestral Suites Nos. 1 - 4" + }, + { + "ArtistId": 258, + "Title": "Charpentier: Divertissements, Airs & Concerts" + }, + { + "ArtistId": 259, + "Title": "South American Getaway" + }, + { + "ArtistId": 260, + "Title": "Górecki: Symphony No. 3" + }, + { + "ArtistId": 261, + "Title": "Purcell: The Fairy Queen" + }, + { + "ArtistId": 262, + "Title": "The Ultimate Relexation Album" + }, + { + "ArtistId": 263, + "Title": "Purcell: Music for the Queen Mary" + }, + { + "ArtistId": 264, + "Title": "Weill: The Seven Deadly Sins" + }, + { + "ArtistId": 265, + "Title": "J.S. Bach: Chaconne, Suite in E Minor, Partita in E Major & Prelude, Fugue and Allegro" + }, + { + "ArtistId": 248, + "Title": "Prokofiev: Symphony No.5 & Stravinksy: Le Sacre Du Printemps" + }, + { + "ArtistId": 266, + "Title": "Szymanowski: Piano Works, Vol. 1" + }, + { + "ArtistId": 267, + "Title": "Nielsen: The Six Symphonies" + }, + { + "ArtistId": 268, + "Title": "Great Recordings of the Century: Paganini's 24 Caprices" + }, + { + "ArtistId": 269, + "Title": "Liszt - 12 Études D'Execution Transcendante" + }, + { + "ArtistId": 270, + "Title": "Great Recordings of the Century - Shubert: Schwanengesang, 4 Lieder" + }, + { + "ArtistId": 271, + "Title": "Locatelli: Concertos for Violin, Strings and Continuo, Vol. 3" + }, + { + "ArtistId": 226, + "Title": "Respighi:Pines of Rome" + }, + { + "ArtistId": 272, + "Title": "Schubert: The Late String Quartets & String Quintet (3 CD's)" + }, + { + "ArtistId": 273, + "Title": "Monteverdi: L'Orfeo" + }, + { + "ArtistId": 274, + "Title": "Mozart: Chamber Music" + }, + { + "ArtistId": 275, + "Title": "Koyaanisqatsi (Soundtrack from the Motion Picture)" + } + ] + } +] diff --git a/crates/query-engine/Cargo.toml b/crates/query-engine/Cargo.toml index c4f10e7c..a0a8a1ac 100644 --- a/crates/query-engine/Cargo.toml +++ b/crates/query-engine/Cargo.toml @@ -20,6 +20,7 @@ serde = { version = "1.0.188", features = ["derive"] } serde_json = "1.0.108" sqlformat = "0.2.2" tracing = "0.1.40" +tokio-stream = "0.1.14" [dev-dependencies] insta = { version = "1.34.0", features = ["json"] } diff --git a/crates/query-engine/src/phases/execution.rs b/crates/query-engine/src/phases/execution.rs index e38edf83..073c28e5 100644 --- a/crates/query-engine/src/phases/execution.rs +++ b/crates/query-engine/src/phases/execution.rs @@ -1,12 +1,11 @@ //! Execute an execution plan against the database. -use std::collections::BTreeMap; - -use serde_json; - -use ndc_sdk::models; - use super::translation::sql; +use ndc_sdk::models; +use serde_json; +use std::collections::BTreeMap; +use tiberius::QueryItem; +use tokio_stream::StreamExt; /// Execute a query against sqlserver. pub async fn mssql_execute( @@ -114,14 +113,28 @@ async fn execute_mssql_query( } // go! - let stream = mssql_query.query(&mut connection).await.unwrap(); + let mut stream = mssql_query.query(&mut connection).await.unwrap(); - // Nothing is fetched, the first result set starts. - let rows = stream.into_row().await.unwrap().unwrap(); + // collect big lump of json here + let mut result_str = String::new(); - let single_item: &str = rows.get(0).unwrap(); + // stream it out and collect it here: + while let Some(item) = stream.try_next().await.unwrap() { + match item { + // ignore these + QueryItem::Metadata(_meta) => { + // .. handling + } + // ...concatenate these + QueryItem::Row(row) => { + let item = row.get(0).unwrap(); + result_str.push_str(item) + } + } + } - let json_value = serde_json::from_str(single_item).unwrap(); + // once we're happy this is stable, we should stream the JSON string straight out + let json_value = serde_json::from_str(&result_str).unwrap(); Ok(json_value) }