From 68d9383ba7c618ad010fd712fdca222f80d56bdd Mon Sep 17 00:00:00 2001 From: Daniel Harvey Date: Mon, 23 Oct 2023 11:02:03 +0100 Subject: [PATCH] Bump ndc_sdk --- Cargo.lock | 438 ++++++++++++++---- Cargo.toml | 7 +- crates/ndc-sqlserver/Cargo.toml | 6 +- crates/ndc-sqlserver/bin/main.rs | 2 +- crates/ndc-sqlserver/src/configuration.rs | 2 +- crates/ndc-sqlserver/src/connector.rs | 30 +- crates/ndc-sqlserver/src/metrics.rs | 2 +- crates/ndc-sqlserver/tests/common/mod.rs | 6 +- ...__aggregation__aggregate_count_albums.snap | 4 +- ...on__aggregate_count_albums_plus_field.snap | 4 +- ...gation__aggregate_count_artist_albums.snap | 20 +- ...regate_count_artist_albums_plus_field.snap | 60 +-- ...tionships__nested_array_relationships.snap | 28 +- ...ionships__nested_object_relationships.snap | 40 +- ...t_album_object_relationship_to_artist.snap | 20 +- ...ct_artist_array_relationship_to_album.snap | 20 +- ...select_order_by_artist_name_with_name.snap | 20 +- crates/query-engine/Cargo.toml | 7 +- crates/query-engine/src/phases/execution.rs | 2 +- .../phases/translation/query/aggregates.rs | 2 +- .../src/phases/translation/query/filtering.rs | 27 +- .../src/phases/translation/query/mod.rs | 2 +- .../phases/translation/query/relationships.rs | 2 +- .../src/phases/translation/query/root.rs | 2 +- .../src/phases/translation/query/sorting.rs | 2 +- 25 files changed, 501 insertions(+), 254 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 07774a88..06767fa6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -227,9 +227,9 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "base64" -version = "0.21.2" +version = "0.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d" +checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2" [[package]] name = "bb8" @@ -258,6 +258,21 @@ dependencies = [ "tokio-util", ] +[[package]] +name = "bit-set" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1" +dependencies = [ + "bit-vec", +] + +[[package]] +name = "bit-vec" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" + [[package]] name = "bitflags" version = "1.3.2" @@ -295,9 +310,9 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "bytes" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" +checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" [[package]] name = "cc" @@ -376,6 +391,17 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" +[[package]] +name = "colored" +version = "2.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2674ec482fbc38012cf31e6c42ba0177b431a0cb6f15fe40efa5aab1bda516f6" +dependencies = [ + "is-terminal", + "lazy_static", + "windows-sys 0.48.0", +] + [[package]] name = "connection-string" version = "0.2.0" @@ -429,14 +455,37 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "darling" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b750cb3417fd1b327431a470f388520309479ab0bf5e323505daf0290cd3850" +dependencies = [ + "darling_core 0.14.4", + "darling_macro 0.14.4", +] + [[package]] name = "darling" version = "0.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0209d94da627ab5605dcccf08bb18afa5009cfbef48d8a8b7d7bdbc79be25c5e" dependencies = [ - "darling_core", - "darling_macro", + "darling_core 0.20.3", + "darling_macro 0.20.3", +] + +[[package]] +name = "darling_core" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "109c1ca6e6b7f82cc233a97004ea8ed7ca123a9af07a8230878fcfda9b158bf0" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "syn 1.0.109", ] [[package]] @@ -453,13 +502,24 @@ dependencies = [ "syn 2.0.28", ] +[[package]] +name = "darling_macro" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e" +dependencies = [ + "darling_core 0.14.4", + "quote", + "syn 1.0.109", +] + [[package]] name = "darling_macro" version = "0.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" dependencies = [ - "darling_core", + "darling_core 0.20.3", "quote", "syn 2.0.28", ] @@ -597,6 +657,12 @@ dependencies = [ "termcolor", ] +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + [[package]] name = "errno" version = "0.3.2" @@ -727,6 +793,19 @@ dependencies = [ "slab", ] +[[package]] +name = "gdc_rust_types" +version = "1.0.2" +source = "git+https://github.com/hasura/gdc_rust_types?rev=bc57c40#bc57c406e530ffff2345c6a02f7b784959a600b5" +dependencies = [ + "indexmap 1.9.3", + "openapiv3", + "serde", + "serde-enum-str", + "serde_json", + "serde_with 3.4.0", +] + [[package]] name = "getrandom" version = "0.1.16" @@ -767,7 +846,7 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap", + "indexmap 1.9.3", "slab", "tokio", "tokio-util", @@ -780,6 +859,12 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +[[package]] +name = "hashbrown" +version = "0.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156" + [[package]] name = "heck" version = "0.4.1" @@ -939,7 +1024,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ "autocfg", - "hashbrown", + "hashbrown 0.12.3", + "serde", +] + +[[package]] +name = "indexmap" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8adf3ddd720272c6ea8bf59463c04e0f93d0bbf7c5439b691bca2987e0270897" +dependencies = [ + "equivalent", + "hashbrown 0.14.2", "serde", ] @@ -1019,6 +1115,12 @@ version = "0.2.147" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" +[[package]] +name = "libm" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" + [[package]] name = "linked-hash-map" version = "0.5.6" @@ -1137,40 +1239,45 @@ dependencies = [ [[package]] name = "ndc-client" version = "0.1.0" -source = "git+https://github.com/hasura/ndc-spec.git?tag=v0.1.0-rc.1#2763ec4df5f9276e1122abf88510c43befa12d2f" +source = "git+http://github.com/hasura/ndc-spec.git?tag=v0.1.0-rc.8#2c2def8a01af2f95100b4274599030c930525bee" dependencies = [ "async-trait", - "clap", - "indexmap", - "opentelemetry 0.18.0", - "opentelemetry_sdk 0.18.0", + "indexmap 1.9.3", + "opentelemetry", "reqwest", "schemars", "serde", "serde_derive", "serde_json", - "serde_with", - "tokio", + "serde_with 2.3.3", "url", - "uuid", ] [[package]] name = "ndc-sdk" version = "0.1.0" -source = "git+https://github.com/hasura/ndc-hub.git?tag=v0.1.0-rc.1#212e7e6953cacc65462e2371361a41094ae22f95" +source = "git+https://github.com/hasura/ndc-hub.git?rev=098b1c2#098b1c23e37df25102804d3222fb4313e0d8bbb4" dependencies = [ "async-trait", "axum", "axum-macros", + "base64 0.21.4", + "bytes", "clap", + "gdc_rust_types", + "http", + "indexmap 1.9.3", + "mime", "ndc-client", - "opentelemetry 0.20.0", + "ndc-test", + "opentelemetry", + "opentelemetry-http", "opentelemetry-otlp", "opentelemetry-semantic-conventions", - "opentelemetry_api 0.20.0", - "opentelemetry_sdk 0.20.0", + "opentelemetry_api", + "opentelemetry_sdk", "prometheus", + "reqwest", "schemars", "serde", "serde_json", @@ -1180,6 +1287,7 @@ dependencies = [ "tracing", "tracing-opentelemetry", "tracing-subscriber", + "url", "uuid", ] @@ -1211,6 +1319,25 @@ dependencies = [ "tracing", ] +[[package]] +name = "ndc-test" +version = "0.1.0" +source = "git+http://github.com/hasura/ndc-spec.git?tag=v0.1.0-rc.8#2c2def8a01af2f95100b4274599030c930525bee" +dependencies = [ + "async-trait", + "clap", + "colored", + "indexmap 1.9.3", + "ndc-client", + "proptest", + "reqwest", + "semver", + "serde", + "serde_json", + "thiserror", + "tokio", +] + [[package]] name = "nom" version = "7.1.3" @@ -1238,6 +1365,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" dependencies = [ "autocfg", + "libm", ] [[package]] @@ -1265,6 +1393,17 @@ version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +[[package]] +name = "openapiv3" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75e56d5c441965b6425165b7e3223cc933ca469834f4a8b4786817a1f9dc4f13" +dependencies = [ + "indexmap 1.9.3", + "serde", + "serde_json", +] + [[package]] name = "openssl" version = "0.10.56" @@ -1309,24 +1448,14 @@ dependencies = [ "vcpkg", ] -[[package]] -name = "opentelemetry" -version = "0.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69d6c3d7288a106c0a363e4b0e8d308058d56902adefb16f4936f417ffef086e" -dependencies = [ - "opentelemetry_api 0.18.0", - "opentelemetry_sdk 0.18.0", -] - [[package]] name = "opentelemetry" version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9591d937bc0e6d2feb6f71a559540ab300ea49955229c347a517a28d27784c54" dependencies = [ - "opentelemetry_api 0.20.0", - "opentelemetry_sdk 0.20.0", + "opentelemetry_api", + "opentelemetry_sdk", ] [[package]] @@ -1338,7 +1467,7 @@ dependencies = [ "async-trait", "bytes", "http", - "opentelemetry_api 0.20.0", + "opentelemetry_api", "reqwest", ] @@ -1354,8 +1483,8 @@ dependencies = [ "opentelemetry-http", "opentelemetry-proto", "opentelemetry-semantic-conventions", - "opentelemetry_api 0.20.0", - "opentelemetry_sdk 0.20.0", + "opentelemetry_api", + "opentelemetry_sdk", "prost", "reqwest", "thiserror", @@ -1369,8 +1498,8 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1e3f814aa9f8c905d0ee4bde026afd3b2577a97c10e1699912e3e44f0c4cbeb" dependencies = [ - "opentelemetry_api 0.20.0", - "opentelemetry_sdk 0.20.0", + "opentelemetry_api", + "opentelemetry_sdk", "prost", "tonic", ] @@ -1381,22 +1510,7 @@ version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73c9f9340ad135068800e7f1b24e9e09ed9e7143f5bf8518ded3d3ec69789269" dependencies = [ - "opentelemetry 0.20.0", -] - -[[package]] -name = "opentelemetry_api" -version = "0.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c24f96e21e7acc813c7a8394ee94978929db2bcc46cf6b5014fc612bf7760c22" -dependencies = [ - "futures-channel", - "futures-util", - "indexmap", - "js-sys", - "once_cell", - "pin-project-lite", - "thiserror", + "opentelemetry", ] [[package]] @@ -1407,7 +1521,7 @@ checksum = "8a81f725323db1b1206ca3da8bb19874bbd3f57c3bcd59471bfb04525b265b9b" dependencies = [ "futures-channel", "futures-util", - "indexmap", + "indexmap 1.9.3", "js-sys", "once_cell", "pin-project-lite", @@ -1415,24 +1529,6 @@ dependencies = [ "urlencoding", ] -[[package]] -name = "opentelemetry_sdk" -version = "0.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ca41c4933371b61c2a2f214bf16931499af4ec90543604ec828f7a625c09113" -dependencies = [ - "async-trait", - "crossbeam-channel", - "futures-channel", - "futures-executor", - "futures-util", - "once_cell", - "opentelemetry_api 0.18.0", - "percent-encoding", - "rand 0.8.5", - "thiserror", -] - [[package]] name = "opentelemetry_sdk" version = "0.20.0" @@ -1445,7 +1541,7 @@ dependencies = [ "futures-executor", "futures-util", "once_cell", - "opentelemetry_api 0.20.0", + "opentelemetry_api", "ordered-float", "percent-encoding", "rand 0.8.5", @@ -1574,6 +1670,26 @@ dependencies = [ "thiserror", ] +[[package]] +name = "proptest" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c003ac8c77cb07bb74f5f198bce836a689bcd5a42574612bf14d17bfd08c20e" +dependencies = [ + "bit-set", + "bit-vec", + "bitflags 2.3.3", + "lazy_static", + "num-traits", + "rand 0.8.5", + "rand_chacha 0.3.1", + "rand_xorshift", + "regex-syntax 0.7.4", + "rusty-fork", + "tempfile", + "unarray", +] + [[package]] name = "prost" version = "0.11.9" @@ -1609,7 +1725,8 @@ version = "0.1.0" dependencies = [ "bb8", "bb8-tiberius", - "indexmap", + "bytes", + "indexmap 1.9.3", "insta", "ndc-sdk", "schemars", @@ -1620,6 +1737,12 @@ dependencies = [ "tracing", ] +[[package]] +name = "quick-error" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" + [[package]] name = "quote" version = "1.0.32" @@ -1700,6 +1823,15 @@ dependencies = [ "rand_core 0.5.1", ] +[[package]] +name = "rand_xorshift" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d25bf25ec5ae4a3f1b92f929810509a2f53d7dca2f50b794ff57e3face536c8f" +dependencies = [ + "rand_core 0.6.4", +] + [[package]] name = "redox_syscall" version = "0.3.5" @@ -1755,11 +1887,11 @@ checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2" [[package]] name = "reqwest" -version = "0.11.18" +version = "0.11.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cde824a14b7c14f85caff81225f411faacc04a2013f41670f41443742b1c1c55" +checksum = "046cd98826c46c2ac8ddecae268eb5c2e58628688a5fc7a2643704a73faba95b" dependencies = [ - "base64 0.21.2", + "base64 0.21.4", "bytes", "encoding_rs", "futures-core", @@ -1781,6 +1913,7 @@ dependencies = [ "serde", "serde_json", "serde_urlencoded", + "system-configuration", "tokio", "tokio-native-tls", "tokio-util", @@ -1857,7 +1990,7 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2" dependencies = [ - "base64 0.21.2", + "base64 0.21.4", ] [[package]] @@ -1866,6 +1999,18 @@ version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" +[[package]] +name = "rusty-fork" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb3dcc6e454c328bb824492db107ab7c0ae8fcffe4ad210136ef014458c1bc4f" +dependencies = [ + "fnv", + "quick-error", + "tempfile", + "wait-timeout", +] + [[package]] name = "ryu" version = "1.0.15" @@ -1888,7 +2033,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f7b0ce13155372a76ee2e1c5ffba1fe61ede73fbea5630d61eee6fac4929c0c" dependencies = [ "dyn-clone", - "indexmap", + "indexmap 1.9.3", "schemars_derive", "serde", "serde_json", @@ -1946,6 +2091,12 @@ dependencies = [ "libc", ] +[[package]] +name = "semver" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" + [[package]] name = "serde" version = "1.0.188" @@ -1955,6 +2106,36 @@ dependencies = [ "serde_derive", ] +[[package]] +name = "serde-attributes" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6eb8ec7724e4e524b2492b510e66957fe1a2c76c26a6975ec80823f2439da685" +dependencies = [ + "darling_core 0.14.4", + "serde-rename-rule", + "syn 1.0.109", +] + +[[package]] +name = "serde-enum-str" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26416dc95fcd46b0e4b12a3758043a229a6914050aaec2e8191949753ed4e9aa" +dependencies = [ + "darling 0.14.4", + "proc-macro2", + "quote", + "serde-attributes", + "syn 1.0.109", +] + +[[package]] +name = "serde-rename-rule" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "794e44574226fc701e3be5c651feb7939038fc67fb73f6f4dd5c4ba90fd3be70" + [[package]] name = "serde_derive" version = "1.0.188" @@ -1983,6 +2164,7 @@ version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" dependencies = [ + "indexmap 2.0.2", "itoa", "ryu", "serde", @@ -2019,10 +2201,27 @@ dependencies = [ "base64 0.13.1", "chrono", "hex", - "indexmap", + "indexmap 1.9.3", + "serde", + "serde_json", + "serde_with_macros 2.3.3", + "time 0.3.25", +] + +[[package]] +name = "serde_with" +version = "3.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64cd236ccc1b7a29e7e2739f27c0b2dd199804abc4290e32f59f3b68d6405c23" +dependencies = [ + "base64 0.21.4", + "chrono", + "hex", + "indexmap 1.9.3", + "indexmap 2.0.2", "serde", "serde_json", - "serde_with_macros", + "serde_with_macros 3.4.0", "time 0.3.25", ] @@ -2032,7 +2231,19 @@ version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "881b6f881b17d13214e5d494c939ebab463d01264ce1811e9d4ac3a882e7695f" dependencies = [ - "darling", + "darling 0.20.3", + "proc-macro2", + "quote", + "syn 2.0.28", +] + +[[package]] +name = "serde_with_macros" +version = "3.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93634eb5f75a2323b16de4748022ac4297f9e76b6dced2be287a099f41b5e788" +dependencies = [ + "darling 0.20.3", "proc-macro2", "quote", "syn 2.0.28", @@ -2171,6 +2382,27 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" +[[package]] +name = "system-configuration" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" +dependencies = [ + "bitflags 1.3.2", + "core-foundation", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "tempfile" version = "3.7.1" @@ -2402,7 +2634,7 @@ checksum = "3082666a3a6433f7f511c7192923fa1fe07c69332d3c6a2e6bb040b569199d5a" dependencies = [ "async-trait", "axum", - "base64 0.21.2", + "base64 0.21.4", "bytes", "futures-core", "futures-util", @@ -2430,7 +2662,7 @@ checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" dependencies = [ "futures-core", "futures-util", - "indexmap", + "indexmap 1.9.3", "pin-project", "pin-project-lite", "rand 0.8.5", @@ -2455,6 +2687,7 @@ dependencies = [ "http", "http-body", "http-range-header", + "mime", "pin-project-lite", "tower-layer", "tower-service", @@ -2525,7 +2758,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc09e402904a5261e42cf27aea09ccb7d5318c6717a9eec3d8e2e65c56b18f19" dependencies = [ "once_cell", - "opentelemetry 0.20.0", + "opentelemetry", "tracing", "tracing-core", "tracing-log", @@ -2567,6 +2800,12 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" +[[package]] +name = "unarray" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94" + [[package]] name = "unicase" version = "2.6.0" @@ -2617,9 +2856,9 @@ checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" [[package]] name = "url" -version = "2.4.0" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50bff7831e19200a85b17131d085c25d7811bc4e186efdaf54bbd132994a88cb" +checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5" dependencies = [ "form_urlencoded", "idna", @@ -2643,9 +2882,6 @@ name = "uuid" version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "79daa5ed5740825c40b389c5e50312b9c86df53fccd33f281df655642b43869d" -dependencies = [ - "serde", -] [[package]] name = "valuable" @@ -2665,6 +2901,15 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +[[package]] +name = "wait-timeout" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f200f5b12eb75f8c1ed65abd4b2db8a6e1b138a20de009dacee265a2498f3f6" +dependencies = [ + "libc", +] + [[package]] name = "want" version = "0.3.1" @@ -2760,9 +3005,9 @@ checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" [[package]] name = "wasm-streams" -version = "0.2.3" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bbae3363c08332cadccd13b67db371814cd214c2524020932f0804b8cf7c078" +checksum = "b4609d447824375f43e1ffbc051b50ad8f4b3ae8219680c94452ea05eb240ac7" dependencies = [ "futures-util", "js-sys", @@ -2978,11 +3223,12 @@ checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" [[package]] name = "winreg" -version = "0.10.1" +version = "0.50.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" +checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" dependencies = [ - "winapi", + "cfg-if", + "windows-sys 0.48.0", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 41039419..ccac3f07 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,8 @@ -[workspace.package] -version = "0.1.0" - [workspace] +resolver = "2" +package.version = "0.1.0" +package.edition = "2021" + members = [ "crates/ndc-sqlserver", "crates/query-engine", diff --git a/crates/ndc-sqlserver/Cargo.toml b/crates/ndc-sqlserver/Cargo.toml index 2b4325c3..4dd7ac73 100644 --- a/crates/ndc-sqlserver/Cargo.toml +++ b/crates/ndc-sqlserver/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "ndc-sqlserver" -version = "0.1.0" -edition = "2021" +version.workspace = true +edition.workspace = true default-run = "ndc-sqlserver" @@ -14,7 +14,7 @@ name = "ndc-sqlserver" path = "bin/main.rs" [dependencies] -ndc-hub = { git = "https://github.com/hasura/ndc-hub.git", tag = "v0.1.0-rc.1", package = "ndc-sdk" } +ndc-sdk = { git = "https://github.com/hasura/ndc-hub.git", rev = "098b1c2", package = "ndc-sdk" } query-engine = { path = "../query-engine" } tokio-util = { version = "0.7.9", features = ["compat"] } diff --git a/crates/ndc-sqlserver/bin/main.rs b/crates/ndc-sqlserver/bin/main.rs index 329f47f8..2e893916 100644 --- a/crates/ndc-sqlserver/bin/main.rs +++ b/crates/ndc-sqlserver/bin/main.rs @@ -1,4 +1,4 @@ -use ndc_hub::default_main::default_main; +use ndc_sdk::default_main::default_main; use ndc_sqlserver::connector::SQLServer; #[tokio::main] diff --git a/crates/ndc-sqlserver/src/configuration.rs b/crates/ndc-sqlserver/src/configuration.rs index 3033c443..c8559f1d 100644 --- a/crates/ndc-sqlserver/src/configuration.rs +++ b/crates/ndc-sqlserver/src/configuration.rs @@ -1,7 +1,7 @@ //! Configuration and state for our connector. use super::metrics; -use ndc_hub::connector; +use ndc_sdk::connector; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use thiserror::Error; diff --git a/crates/ndc-sqlserver/src/connector.rs b/crates/ndc-sqlserver/src/connector.rs index 4def2938..28da64e8 100644 --- a/crates/ndc-sqlserver/src/connector.rs +++ b/crates/ndc-sqlserver/src/connector.rs @@ -8,8 +8,9 @@ use tiberius::Query; use async_trait::async_trait; -use ndc_hub::connector; -use ndc_hub::models; +use ndc_sdk::connector; +use ndc_sdk::json_response::JsonResponse; +use ndc_sdk::models; use query_engine::phases; @@ -33,17 +34,17 @@ impl connector::Connector for SQLServer { /// Configure a configuration maybe? async fn update_configuration( - args: &Self::RawConfiguration, + args: Self::RawConfiguration, ) -> Result { - configuration::configure(args).await + configuration::configure(&args).await } /// Validate the raw configuration provided by the user, /// returning a configuration error or a validated [`Connector::Configuration`]. async fn validate_raw_configuration( - configuration: &Self::RawConfiguration, + configuration: Self::RawConfiguration, ) -> Result { - configuration::validate_raw_configuration(configuration).await + configuration::validate_raw_configuration(&configuration).await } /// Initialize the connector's in-memory state. @@ -93,9 +94,9 @@ impl connector::Connector for SQLServer { /// /// This function implements the [capabilities endpoint](https://hasura.github.io/ndc-spec/specification/capabilities.html) /// from the NDC specification. - async fn get_capabilities() -> models::CapabilitiesResponse { + async fn get_capabilities() -> JsonResponse { let empty = serde_json::to_value(()).unwrap(); - models::CapabilitiesResponse { + JsonResponse::Value(models::CapabilitiesResponse { versions: "^0.0.0".into(), capabilities: models::Capabilities { explain: Some(empty.clone()), @@ -107,7 +108,7 @@ impl connector::Connector for SQLServer { relationships: Some(empty), mutations: None, }, - } + }) } /// Get the connector's schema. @@ -116,7 +117,7 @@ impl connector::Connector for SQLServer { /// from the NDC specification. async fn get_schema( _configuration: &Self::Configuration, - ) -> Result { + ) -> Result, connector::SchemaError> { todo!("get_schema") } @@ -128,7 +129,7 @@ impl connector::Connector for SQLServer { _configuration: &Self::Configuration, _state: &Self::State, _query_request: models::QueryRequest, - ) -> Result { + ) -> Result, connector::ExplainError> { todo!("explain!") } @@ -140,7 +141,7 @@ impl connector::Connector for SQLServer { _configuration: &Self::Configuration, _state: &Self::State, _request: models::MutationRequest, - ) -> Result { + ) -> Result, connector::MutationError> { todo!("mutations are currently not implemented") } @@ -152,7 +153,7 @@ impl connector::Connector for SQLServer { configuration: &Self::Configuration, state: &Self::State, query_request: models::QueryRequest, - ) -> Result { + ) -> Result, connector::QueryError> { tracing::info!("{}", serde_json::to_string(&query_request).unwrap()); tracing::info!("{:?}", query_request); @@ -184,7 +185,8 @@ impl connector::Connector for SQLServer { // assuming query succeeded, increment counter state.metrics.query_total.inc(); - Ok(result) + // TODO: return raw JSON + Ok(JsonResponse::Value(result)) } } diff --git a/crates/ndc-sqlserver/src/metrics.rs b/crates/ndc-sqlserver/src/metrics.rs index 51643614..d5807022 100644 --- a/crates/ndc-sqlserver/src/metrics.rs +++ b/crates/ndc-sqlserver/src/metrics.rs @@ -1,7 +1,7 @@ //! Metrics setup and update for our connector. use super::configuration::InitializationError; -use ndc_hub::connector; +use ndc_sdk::connector; use prometheus::core::{AtomicU64, GenericCounter}; #[derive(Debug, Clone)] diff --git a/crates/ndc-sqlserver/tests/common/mod.rs b/crates/ndc-sqlserver/tests/common/mod.rs index ef724887..98151923 100644 --- a/crates/ndc-sqlserver/tests/common/mod.rs +++ b/crates/ndc-sqlserver/tests/common/mod.rs @@ -35,7 +35,7 @@ pub async fn run_explain(testname: &str) -> ExactExplainResponse { } /// Run a query against the server, get the result, and compare against the snapshot. -pub async fn get_schema() -> ndc_hub::models::SchemaResponse { +pub async fn get_schema() -> ndc_sdk::models::SchemaResponse { make_request(|client| client.get("/schema")).await } @@ -71,13 +71,13 @@ async fn make_request serde::Deserialize<'a>>( let test_deployment_file = get_deployment_file(); // initialise server state with the static configuration. - let state = ndc_hub::default_main::init_server_state::( + let state = ndc_sdk::default_main::init_server_state::( test_deployment_file.display().to_string(), ) .await; // create a fresh client - let router = ndc_hub::default_main::create_router(state); + let router = ndc_sdk::default_main::create_router(state, None); let client = TestClient::new(router); // make the request diff --git a/crates/ndc-sqlserver/tests/snapshots/query_tests__aggregation__aggregate_count_albums.snap b/crates/ndc-sqlserver/tests/snapshots/query_tests__aggregation__aggregate_count_albums.snap index 9613ef50..6e2d7b39 100644 --- a/crates/ndc-sqlserver/tests/snapshots/query_tests__aggregation__aggregate_count_albums.snap +++ b/crates/ndc-sqlserver/tests/snapshots/query_tests__aggregation__aggregate_count_albums.snap @@ -5,12 +5,12 @@ expression: result [ { "aggregates": { - "avg_artist_id": 121, "how_many_albums": 347, "how_many_artist_ids": 347, "how_many_distinct_artist_ids": 204, + "min_artist_id": 1, "max_artist_id": 275, - "min_artist_id": 1 + "avg_artist_id": 121 } } ] diff --git a/crates/ndc-sqlserver/tests/snapshots/query_tests__aggregation__aggregate_count_albums_plus_field.snap b/crates/ndc-sqlserver/tests/snapshots/query_tests__aggregation__aggregate_count_albums_plus_field.snap index 823385f5..b22307e2 100644 --- a/crates/ndc-sqlserver/tests/snapshots/query_tests__aggregation__aggregate_count_albums_plus_field.snap +++ b/crates/ndc-sqlserver/tests/snapshots/query_tests__aggregation__aggregate_count_albums_plus_field.snap @@ -5,12 +5,12 @@ expression: result [ { "aggregates": { - "avg_artist_id": 121, "how_many_albums": 347, "how_many_artist_ids": 347, "how_many_distinct_artist_ids": 204, + "min_artist_id": 1, "max_artist_id": 275, - "min_artist_id": 1 + "avg_artist_id": 121 }, "rows": [ { diff --git a/crates/ndc-sqlserver/tests/snapshots/query_tests__aggregation__aggregate_count_artist_albums.snap b/crates/ndc-sqlserver/tests/snapshots/query_tests__aggregation__aggregate_count_artist_albums.snap index 1f5b9256..19766378 100644 --- a/crates/ndc-sqlserver/tests/snapshots/query_tests__aggregation__aggregate_count_artist_albums.snap +++ b/crates/ndc-sqlserver/tests/snapshots/query_tests__aggregation__aggregate_count_artist_albums.snap @@ -6,44 +6,44 @@ expression: result { "rows": [ { + "Name": "Accept", "Albums": { "aggregates": { "how_many_albums": 2 } - }, - "Name": "Accept" + } }, { + "Name": "Aerosmith", "Albums": { "aggregates": { "how_many_albums": 1 } - }, - "Name": "Aerosmith" + } }, { + "Name": "Alanis Morissette", "Albums": { "aggregates": { "how_many_albums": 1 } - }, - "Name": "Alanis Morissette" + } }, { + "Name": "Alice In Chains", "Albums": { "aggregates": { "how_many_albums": 1 } - }, - "Name": "Alice In Chains" + } }, { + "Name": "Antônio Carlos Jobim", "Albums": { "aggregates": { "how_many_albums": 2 } - }, - "Name": "Antônio Carlos Jobim" + } } ] } diff --git a/crates/ndc-sqlserver/tests/snapshots/query_tests__aggregation__aggregate_count_artist_albums_plus_field.snap b/crates/ndc-sqlserver/tests/snapshots/query_tests__aggregation__aggregate_count_artist_albums_plus_field.snap index fdd6caac..b484ff07 100644 --- a/crates/ndc-sqlserver/tests/snapshots/query_tests__aggregation__aggregate_count_artist_albums_plus_field.snap +++ b/crates/ndc-sqlserver/tests/snapshots/query_tests__aggregation__aggregate_count_artist_albums_plus_field.snap @@ -6,10 +6,8 @@ expression: result { "rows": [ { + "Name": "Accept", "Albums": { - "aggregates": { - "how_many_albums": 2 - }, "rows": [ { "Title": "Balls to the Wall" @@ -17,54 +15,54 @@ expression: result { "Title": "Restless and Wild" } - ] - }, - "Name": "Accept" + ], + "aggregates": { + "how_many_albums": 2 + } + } }, { + "Name": "Aerosmith", "Albums": { - "aggregates": { - "how_many_albums": 1 - }, "rows": [ { "Title": "Big Ones" } - ] - }, - "Name": "Aerosmith" + ], + "aggregates": { + "how_many_albums": 1 + } + } }, { + "Name": "Alanis Morissette", "Albums": { - "aggregates": { - "how_many_albums": 1 - }, "rows": [ { "Title": "Jagged Little Pill" } - ] - }, - "Name": "Alanis Morissette" + ], + "aggregates": { + "how_many_albums": 1 + } + } }, { + "Name": "Alice In Chains", "Albums": { - "aggregates": { - "how_many_albums": 1 - }, "rows": [ { "Title": "Facelift" } - ] - }, - "Name": "Alice In Chains" + ], + "aggregates": { + "how_many_albums": 1 + } + } }, { + "Name": "Antônio Carlos Jobim", "Albums": { - "aggregates": { - "how_many_albums": 2 - }, "rows": [ { "Title": "Warner 25 Anos" @@ -72,9 +70,11 @@ expression: result { "Title": "Chill: Brazil (Disc 2)" } - ] - }, - "Name": "Antônio Carlos Jobim" + ], + "aggregates": { + "how_many_albums": 2 + } + } } ] } diff --git a/crates/ndc-sqlserver/tests/snapshots/query_tests__relationships__nested_array_relationships.snap b/crates/ndc-sqlserver/tests/snapshots/query_tests__relationships__nested_array_relationships.snap index ca81531f..6dddb6b1 100644 --- a/crates/ndc-sqlserver/tests/snapshots/query_tests__relationships__nested_array_relationships.snap +++ b/crates/ndc-sqlserver/tests/snapshots/query_tests__relationships__nested_array_relationships.snap @@ -6,9 +6,11 @@ expression: result { "rows": [ { + "artist": "Queen", "Albums": { "rows": [ { + "album": "Greatest Hits II", "Tracks": { "rows": [ { @@ -24,10 +26,10 @@ expression: result "track": "I Want It All" } ] - }, - "album": "Greatest Hits II" + } }, { + "album": "Greatest Hits I", "Tracks": { "rows": [ { @@ -43,10 +45,10 @@ expression: result "track": "Fat Bottomed Girls" } ] - }, - "album": "Greatest Hits I" + } }, { + "album": "News Of The World", "Tracks": { "rows": [ { @@ -62,17 +64,17 @@ expression: result "track": "All Dead, All Dead" } ] - }, - "album": "News Of The World" + } } ] - }, - "artist": "Queen" + } }, { + "artist": "Kiss", "Albums": { "rows": [ { + "album": "Greatest Kiss", "Tracks": { "rows": [ { @@ -88,10 +90,10 @@ expression: result "track": "Sure Know Something" } ] - }, - "album": "Greatest Kiss" + } }, { + "album": "Unplugged [Live]", "Tracks": { "rows": [ { @@ -107,12 +109,10 @@ expression: result "track": "Do You Love Me" } ] - }, - "album": "Unplugged [Live]" + } } ] - }, - "artist": "Kiss" + } } ] } diff --git a/crates/ndc-sqlserver/tests/snapshots/query_tests__relationships__nested_object_relationships.snap b/crates/ndc-sqlserver/tests/snapshots/query_tests__relationships__nested_object_relationships.snap index cb7dcebd..6a57987e 100644 --- a/crates/ndc-sqlserver/tests/snapshots/query_tests__relationships__nested_object_relationships.snap +++ b/crates/ndc-sqlserver/tests/snapshots/query_tests__relationships__nested_object_relationships.snap @@ -6,89 +6,89 @@ expression: result { "rows": [ { + "track": "Grito De Alerta", "Album": { "rows": [ { + "album": "Meus Momentos", "Artist": { "rows": [ { "artist": "Gonzaguinha" } ] - }, - "album": "Meus Momentos" + } } ] - }, - "track": "Grito De Alerta" + } }, { + "track": "Não Dá Mais Pra Segurar (Explode Coração)", "Album": { "rows": [ { + "album": "Meus Momentos", "Artist": { "rows": [ { "artist": "Gonzaguinha" } ] - }, - "album": "Meus Momentos" + } } ] - }, - "track": "Não Dá Mais Pra Segurar (Explode Coração)" + } }, { + "track": "Começaria Tudo Outra Vez", "Album": { "rows": [ { + "album": "Meus Momentos", "Artist": { "rows": [ { "artist": "Gonzaguinha" } ] - }, - "album": "Meus Momentos" + } } ] - }, - "track": "Começaria Tudo Outra Vez" + } }, { + "track": "O Que É O Que É ?", "Album": { "rows": [ { + "album": "Meus Momentos", "Artist": { "rows": [ { "artist": "Gonzaguinha" } ] - }, - "album": "Meus Momentos" + } } ] - }, - "track": "O Que É O Que É ?" + } }, { + "track": "Sangrando", "Album": { "rows": [ { + "album": "Meus Momentos", "Artist": { "rows": [ { "artist": "Gonzaguinha" } ] - }, - "album": "Meus Momentos" + } } ] - }, - "track": "Sangrando" + } } ] } diff --git a/crates/ndc-sqlserver/tests/snapshots/query_tests__relationships__select_album_object_relationship_to_artist.snap b/crates/ndc-sqlserver/tests/snapshots/query_tests__relationships__select_album_object_relationship_to_artist.snap index 239a5682..b909bd9a 100644 --- a/crates/ndc-sqlserver/tests/snapshots/query_tests__relationships__select_album_object_relationship_to_artist.snap +++ b/crates/ndc-sqlserver/tests/snapshots/query_tests__relationships__select_album_object_relationship_to_artist.snap @@ -6,54 +6,54 @@ expression: result { "rows": [ { + "Title": "Let There Be Rock", "Artist": { "rows": [ { "Name": "AC/DC" } ] - }, - "Title": "Let There Be Rock" + } }, { + "Title": "Big Ones", "Artist": { "rows": [ { "Name": "Aerosmith" } ] - }, - "Title": "Big Ones" + } }, { + "Title": "Jagged Little Pill", "Artist": { "rows": [ { "Name": "Alanis Morissette" } ] - }, - "Title": "Jagged Little Pill" + } }, { + "Title": "Facelift", "Artist": { "rows": [ { "Name": "Alice In Chains" } ] - }, - "Title": "Facelift" + } }, { + "Title": "Warner 25 Anos", "Artist": { "rows": [ { "Name": "Antônio Carlos Jobim" } ] - }, - "Title": "Warner 25 Anos" + } } ] } diff --git a/crates/ndc-sqlserver/tests/snapshots/query_tests__relationships__select_artist_array_relationship_to_album.snap b/crates/ndc-sqlserver/tests/snapshots/query_tests__relationships__select_artist_array_relationship_to_album.snap index c80925ff..c2fd6a42 100644 --- a/crates/ndc-sqlserver/tests/snapshots/query_tests__relationships__select_artist_array_relationship_to_album.snap +++ b/crates/ndc-sqlserver/tests/snapshots/query_tests__relationships__select_artist_array_relationship_to_album.snap @@ -6,26 +6,27 @@ expression: result { "rows": [ { + "Name": "Alanis Morissette", "Albums": { "rows": [ { "Title": "Jagged Little Pill" } ] - }, - "Name": "Alanis Morissette" + } }, { + "Name": "Alice In Chains", "Albums": { "rows": [ { "Title": "Facelift" } ] - }, - "Name": "Alice In Chains" + } }, { + "Name": "Antônio Carlos Jobim", "Albums": { "rows": [ { @@ -35,20 +36,20 @@ expression: result "Title": "Chill: Brazil (Disc 2)" } ] - }, - "Name": "Antônio Carlos Jobim" + } }, { + "Name": "Apocalyptica", "Albums": { "rows": [ { "Title": "Plays Metallica By Four Cellos" } ] - }, - "Name": "Apocalyptica" + } }, { + "Name": "Audioslave", "Albums": { "rows": [ { @@ -61,8 +62,7 @@ expression: result "Title": "Revelations" } ] - }, - "Name": "Audioslave" + } } ] } diff --git a/crates/ndc-sqlserver/tests/snapshots/query_tests__sorting__select_order_by_artist_name_with_name.snap b/crates/ndc-sqlserver/tests/snapshots/query_tests__sorting__select_order_by_artist_name_with_name.snap index 801d86bf..257e875e 100644 --- a/crates/ndc-sqlserver/tests/snapshots/query_tests__sorting__select_order_by_artist_name_with_name.snap +++ b/crates/ndc-sqlserver/tests/snapshots/query_tests__sorting__select_order_by_artist_name_with_name.snap @@ -6,54 +6,54 @@ expression: result { "rows": [ { + "Name": "A Copland Celebration, Vol. I", "Artist": { "rows": [ { "Name": "Aaron Copland & London Symphony Orchestra" } ] - }, - "Name": "A Copland Celebration, Vol. I" + } }, { + "Name": "Worlds", "Artist": { "rows": [ { "Name": "Aaron Goldberg" } ] - }, - "Name": "Worlds" + } }, { + "Name": "For Those About To Rock We Salute You", "Artist": { "rows": [ { "Name": "AC/DC" } ] - }, - "Name": "For Those About To Rock We Salute You" + } }, { + "Name": "Let There Be Rock", "Artist": { "rows": [ { "Name": "AC/DC" } ] - }, - "Name": "Let There Be Rock" + } }, { + "Name": "The World of Classical Favourites", "Artist": { "rows": [ { "Name": "Academy of St. Martin in the Fields & Sir Neville Marriner" } ] - }, - "Name": "The World of Classical Favourites" + } } ] } diff --git a/crates/query-engine/Cargo.toml b/crates/query-engine/Cargo.toml index 175bea58..5f021a8f 100644 --- a/crates/query-engine/Cargo.toml +++ b/crates/query-engine/Cargo.toml @@ -1,15 +1,16 @@ [package] name = "query-engine" -version = "0.1.0" -edition = "2021" +version.workspace = true +edition.workspace = true [dependencies] -ndc-hub = { git = "https://github.com/hasura/ndc-hub.git", tag = "v0.1.0-rc.1", package = "ndc-sdk" } +ndc-sdk = { git = "https://github.com/hasura/ndc-hub.git", rev = "098b1c2", package = "ndc-sdk" } tiberius = { version = "0.12.2", default-features = false, features = ["rustls"] } bb8 = "0.8.1" bb8-tiberius = "0.15.0" +bytes = "1.5.0" # only included to sort deps conflict indexmap = "1" schemars = { version = "0.8.15", features = ["smol_str"] } serde = { version = "1.0.188", features = ["derive"] } diff --git a/crates/query-engine/src/phases/execution.rs b/crates/query-engine/src/phases/execution.rs index b23463b9..e38edf83 100644 --- a/crates/query-engine/src/phases/execution.rs +++ b/crates/query-engine/src/phases/execution.rs @@ -4,7 +4,7 @@ use std::collections::BTreeMap; use serde_json; -use ndc_hub::models; +use ndc_sdk::models; use super::translation::sql; diff --git a/crates/query-engine/src/phases/translation/query/aggregates.rs b/crates/query-engine/src/phases/translation/query/aggregates.rs index dc7e0cdb..9e7d95de 100644 --- a/crates/query-engine/src/phases/translation/query/aggregates.rs +++ b/crates/query-engine/src/phases/translation/query/aggregates.rs @@ -2,7 +2,7 @@ use indexmap::IndexMap; -use ndc_hub::models; +use ndc_sdk::models; use super::error::Error; use crate::phases::translation::sql; diff --git a/crates/query-engine/src/phases/translation/query/filtering.rs b/crates/query-engine/src/phases/translation/query/filtering.rs index 8165f599..08bea12b 100644 --- a/crates/query-engine/src/phases/translation/query/filtering.rs +++ b/crates/query-engine/src/phases/translation/query/filtering.rs @@ -2,7 +2,7 @@ use std::collections::BTreeMap; -use ndc_hub::models; +use ndc_sdk::models; use super::error::Error; use super::helpers::{RootAndCurrentTables, TableNameAndReference}; @@ -67,17 +67,17 @@ pub fn translate_expression( tables_info, relationships, root_and_current_tables, - *column, + column, )?; let right = translate_comparison_value( tables_info, relationships, root_and_current_tables, - *value, + value, )?; Ok(sql::ast::Expression::BinaryOperator { left: Box::new(left), - operator: match *operator { + operator: match operator { models::BinaryComparisonOperator::Equal => sql::ast::BinaryOperator::Equals, models::BinaryComparisonOperator::Other { name } => // the strings we're matching against here (ie 'like') are best guesses for now, will @@ -114,7 +114,7 @@ pub fn translate_expression( tables_info, relationships, root_and_current_tables, - *column, + column, )?; let right = values .iter() @@ -129,7 +129,7 @@ pub fn translate_expression( .collect::, Error>>()?; Ok(sql::ast::Expression::BinaryArrayOperator { left: Box::new(left), - operator: match *operator { + operator: match operator { models::BinaryArrayComparisonOperator::In => sql::ast::BinaryArrayOperator::In, }, right, @@ -144,17 +144,17 @@ pub fn translate_expression( tables_info, relationships, root_and_current_tables, - *in_collection, + in_collection, *predicate, ), // dummy - models::Expression::UnaryComparisonOperator { column, operator } => match *operator { + models::Expression::UnaryComparisonOperator { column, operator } => match operator { models::UnaryComparisonOperator::IsNull => { let value = translate_comparison_target( tables_info, relationships, root_and_current_tables, - *column, + column, )?; Ok(sql::ast::Expression::UnaryOperator { @@ -236,12 +236,9 @@ fn translate_comparison_value( value: models::ComparisonValue, ) -> Result { match value { - models::ComparisonValue::Column { column } => translate_comparison_target( - tables_info, - relationships, - root_and_current_tables, - *column, - ), + models::ComparisonValue::Column { column } => { + translate_comparison_target(tables_info, relationships, root_and_current_tables, column) + } models::ComparisonValue::Scalar { value: json_value } => Ok(sql::ast::Expression::Value( translate_json_value(&json_value), )), diff --git a/crates/query-engine/src/phases/translation/query/mod.rs b/crates/query-engine/src/phases/translation/query/mod.rs index 6835c3ae..7bb5dd8a 100644 --- a/crates/query-engine/src/phases/translation/query/mod.rs +++ b/crates/query-engine/src/phases/translation/query/mod.rs @@ -10,7 +10,7 @@ pub mod sorting; use std::collections::BTreeMap; -use ndc_hub::models; +use ndc_sdk::models; use crate::metadata; use crate::phases::translation::sql; diff --git a/crates/query-engine/src/phases/translation/query/relationships.rs b/crates/query-engine/src/phases/translation/query/relationships.rs index 904fe91f..4df4fda5 100644 --- a/crates/query-engine/src/phases/translation/query/relationships.rs +++ b/crates/query-engine/src/phases/translation/query/relationships.rs @@ -2,7 +2,7 @@ use std::collections::BTreeMap; -use ndc_hub::models; +use ndc_sdk::models; use super::error::Error; use super::helpers::{RootAndCurrentTables, TableNameAndReference}; diff --git a/crates/query-engine/src/phases/translation/query/root.rs b/crates/query-engine/src/phases/translation/query/root.rs index db529c05..2ef9d5d6 100644 --- a/crates/query-engine/src/phases/translation/query/root.rs +++ b/crates/query-engine/src/phases/translation/query/root.rs @@ -4,7 +4,7 @@ use std::collections::BTreeMap; use indexmap::IndexMap; -use ndc_hub::models; +use ndc_sdk::models; use super::aggregates; use super::error::Error; diff --git a/crates/query-engine/src/phases/translation/query/sorting.rs b/crates/query-engine/src/phases/translation/query/sorting.rs index 61a40497..6cd7d115 100644 --- a/crates/query-engine/src/phases/translation/query/sorting.rs +++ b/crates/query-engine/src/phases/translation/query/sorting.rs @@ -1,6 +1,6 @@ use std::collections::BTreeMap; -use ndc_hub::models; +use ndc_sdk::models; use super::error::Error; use super::helpers::{RootAndCurrentTables, TableNameAndReference};