diff --git a/Cargo.lock b/Cargo.lock index 6f131453f..fd620df6d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -580,9 +580,6 @@ dependencies = [ "insta", "ndc-postgres", "ndc-postgres-configuration", - "openapi-generator", - "schemars", - "serde_json", "test-each", "tests-common", "tokio", @@ -1236,6 +1233,7 @@ dependencies = [ "anyhow", "base64 0.21.7", "bytecount", + "clap", "fancy-regex", "fraction", "getrandom", @@ -1469,10 +1467,13 @@ name = "ndc-postgres-configuration" version = "0.6.0" dependencies = [ "anyhow", + "insta", + "jsonschema", "query-engine-metadata", "schemars", "serde", "serde_json", + "similar-asserts", "sqlx", "thiserror", "tokio", @@ -1687,7 +1688,6 @@ name = "openapi-generator" version = "0.6.0" dependencies = [ "ndc-postgres-configuration", - "schemars", "serde_json", ] @@ -2106,6 +2106,7 @@ dependencies = [ name = "query-engine-translation" version = "0.6.0" dependencies = [ + "anyhow", "indexmap 2.2.6", "insta", "multimap", @@ -2115,6 +2116,8 @@ dependencies = [ "query-engine-sql", "serde_json", "sqlformat", + "thiserror", + "tokio", ] [[package]] @@ -3049,16 +3052,13 @@ dependencies = [ "axum-test-helper", "env_logger", "hyper", - "jsonschema", "ndc-postgres", "ndc-postgres-configuration", "ndc-sdk", "ndc-test", "reqwest", - "schemars", "serde", "serde_json", - "similar-asserts", "sqlx", "tokio", "tokio-postgres", diff --git a/Cargo.toml b/Cargo.toml index dcfbb7acc..dcb44720e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,9 +2,7 @@ resolver = "2" package.version = "0.6.0" - package.edition = "2021" - package.license = "Apache-2.0" members = [ @@ -31,5 +29,6 @@ similar_names = "allow" too_many_lines = "allow" [workspace.dependencies] +ndc-models = { git = "https://github.com/hasura/ndc-spec.git", tag = "v0.1.2" } ndc-sdk = { git = "https://github.com/hasura/ndc-sdk-rs.git", rev = "6158b1adbcc4ac7d8acb721c1626f6f715424a27" } ndc-test = { git = "https://github.com/hasura/ndc-spec.git", tag = "v0.1.2" } diff --git a/crates/cli/tests/update_tests.rs b/crates/cli/tests/update_tests.rs index 1817fec89..da86c432e 100644 --- a/crates/cli/tests/update_tests.rs +++ b/crates/cli/tests/update_tests.rs @@ -13,28 +13,14 @@ const CONNECTION_URI: &str = "postgresql://postgres:password@localhost:64002"; async fn test_update_configuration() -> anyhow::Result<()> { let dir = tempfile::tempdir()?; - let connection_uri = configuration::ConnectionUri(configuration::Secret::FromEnvironment { - variable: "CONNECTION_URI".into(), - }); - - { - let connection_settings = - configuration::version3::connection_settings::DatabaseConnectionSettings { - connection_uri: connection_uri.clone(), - ..configuration::version3::connection_settings::DatabaseConnectionSettings::empty() - }; - let input = ParsedConfiguration::Version3(configuration::version3::RawConfiguration { - connection_settings, - ..configuration::version3::RawConfiguration::empty() - }); - configuration::write_parsed_configuration(input, &dir).await?; - } + configuration::write_parsed_configuration(configuration::ParsedConfiguration::initial(), &dir) + .await?; let environment = FixedEnvironment::from([("CONNECTION_URI".into(), CONNECTION_URI.to_string())]); let context = Context { context_path: dir.path().to_owned(), - environment, + environment: environment.clone(), release_version: None, }; run(Command::Update, context).await?; @@ -44,18 +30,10 @@ async fn test_update_configuration() -> anyhow::Result<()> { let contents = fs::read_to_string(configuration_file_path).await?; common::assert_ends_with_newline(&contents); let output: ParsedConfiguration = configuration::parse_configuration(&dir).await?; - match output { - ParsedConfiguration::Version3(configuration::version3::RawConfiguration { - connection_settings, - metadata, - .. - }) => { - assert_eq!(connection_settings.connection_uri, connection_uri); - let some_table_metadata = metadata.tables.0.get("Artist"); - assert!(some_table_metadata.is_some()); - } - ParsedConfiguration::Version4(_) => panic!("Expected version 3"), - } + let runtime_config = configuration::make_runtime_configuration(output, environment)?; + + let some_table_metadata = runtime_config.metadata.tables.0.get("Artist"); + assert!(some_table_metadata.is_some()); Ok(()) } diff --git a/crates/configuration/Cargo.toml b/crates/configuration/Cargo.toml index 780d9d2e7..9e8b7fdad 100644 --- a/crates/configuration/Cargo.toml +++ b/crates/configuration/Cargo.toml @@ -16,5 +16,10 @@ serde = "1.0.200" serde_json = { version = "1.0.116", features = ["raw_value"] } sqlx = { version = "0.7.4", features = ["json", "postgres", "runtime-tokio-rustls"] } thiserror = "1.0.59" -tokio = "1.37.0" +tokio = { version = "1.37.0", features = ["full"]} tracing = "0.1.40" + +[dev-dependencies] +insta = { version = "1.38.0", features = ["json"]} +jsonschema = "0.17.1" +similar-asserts = "1.5.0" diff --git a/crates/configuration/src/configuration.rs b/crates/configuration/src/configuration.rs index 4b20799cb..4f0f173fa 100644 --- a/crates/configuration/src/configuration.rs +++ b/crates/configuration/src/configuration.rs @@ -12,17 +12,28 @@ use crate::error::{ use crate::values::{IsolationLevel, PoolSettings}; use crate::version3; use crate::version4; +use schemars::{gen::SchemaSettings, schema::RootSchema}; -/// The parsed connector configuration. This data type is an enum with cases for each supported -/// version. +pub fn generate_latest_schema() -> RootSchema { + SchemaSettings::openapi3() + .into_generator() + .into_root_schema_for::() +} + +pub const DEFAULT_CONNECTION_URI_VARIABLE: &str = "CONNECTION_URI"; + +/// The 'ParsedConfiguration' type models the various concrete configuration formats that are +/// currently supported. +/// +/// Introducing a breaking configuration format change involves adding a new case to this type. /// -/// It supports various uses: +/// 'ParsedConfiguration' is used to support serialization and deserialization of an NDC +/// configuration. It retains all the salient information that constitues an instance of an NDC +/// deployment, such that 'c = parse_configuration(dir) => { write_parsed_configuration(c, dir2) ; +/// assert(c == parse_configuration(dir2))}'. /// -/// * It can be turned into a `Configuration`, to be used at runtime. -/// * It retains all information necessary to produce an equivalent serialized representation. -/// * It supports updates between versions which may require more detailed information than is -/// available in a `Configuration` (such as whether a native query was defined inline or in a -/// file) +/// Upgrades between different configuration format versions are version-specific functions on +/// 'ParsedConfiguration' as well. #[derive(Clone, PartialEq, Eq, Debug)] pub enum ParsedConfiguration { Version3(version3::RawConfiguration), @@ -35,11 +46,17 @@ impl ParsedConfiguration { } } -/// A configuration type, tailored to the needs of the query/mutation/explain methods (i.e., those -/// not to do with configuration management). +/// The 'Configuration' type collects all the information necessary to serve queries at runtime. +/// +/// 'ParsedConfiguration' deals with a multitude of different concrete version formats, and each +/// version is responsible for interpreting its serialized format into the current 'Configuration'. +/// Values of this type are produced from a 'ParsedConfiguration' using +/// 'make_runtime_configuration'. +/// +/// Separating 'ParsedConfiguration' and 'Configuration' simplifies the main query translation +/// logic by placing the responsibility of dealing with configuration format evolution in +/// 'ParsedConfiguration. /// -/// This separation also decouples the implementation from things like API versioning concerns -/// somewhat. #[derive(Debug)] pub struct Configuration { pub metadata: metadata::Metadata, @@ -78,6 +95,11 @@ pub async fn parse_configuration( } } +/// Turn a 'ParsedConfiguration' into a into a 'Configuration', such that it may be used in main +/// NDC business logic. +/// +/// Each concrete supported version implementation is responsible for interpretation its format +/// into the runtime configuration. pub fn make_runtime_configuration( parsed_config: ParsedConfiguration, environment: impl Environment, @@ -99,6 +121,10 @@ pub async fn write_parsed_configuration( } } +/// Produce an equivalent version of a parsed configuration in the latest supported version. +/// +/// This is part of the configuration crate API to enable users to upgrade their configurations +/// mechanically, using the ndc-postgres cli, when new versions are released.. pub fn upgrade_to_latest_version(parsed_config: ParsedConfiguration) -> ParsedConfiguration { match parsed_config { ParsedConfiguration::Version3(v) => { diff --git a/crates/configuration/src/error.rs b/crates/configuration/src/error.rs index 2c024a662..2a764eab3 100644 --- a/crates/configuration/src/error.rs +++ b/crates/configuration/src/error.rs @@ -38,6 +38,7 @@ pub struct MultiError(pub Vec>); impl Display for MultiError { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { for err in &self.0 { + "\n".fmt(f)?; " * ".fmt(f)?; err.fmt(f)?; "\n".fmt(f)?; diff --git a/crates/configuration/src/lib.rs b/crates/configuration/src/lib.rs index b2c89bc02..a5ee2a29e 100644 --- a/crates/configuration/src/lib.rs +++ b/crates/configuration/src/lib.rs @@ -3,12 +3,58 @@ mod values; pub mod environment; pub mod error; -// TODO: make these two private! -pub mod version3; -pub mod version4; +mod version3; +mod version4; pub use configuration::{ - introspect, make_runtime_configuration, parse_configuration, upgrade_to_latest_version, - write_parsed_configuration, Configuration, ParsedConfiguration, + generate_latest_schema, introspect, make_runtime_configuration, parse_configuration, + upgrade_to_latest_version, write_parsed_configuration, Configuration, ParsedConfiguration, + DEFAULT_CONNECTION_URI_VARIABLE, }; pub use values::{ConnectionUri, IsolationLevel, PoolSettings, Secret}; + +#[cfg(test)] +pub mod tests; + +#[cfg(test)] +pub mod common { + use std::path::{Path, PathBuf}; + + pub mod postgres { + + pub const CHINOOK_NDC_METADATA_PATH: &str = "static/postgres/v3-chinook-ndc-metadata"; + + pub const BROKEN_QUERIES_NDC_METADATA_PATH: &str = + "static/postgres/broken-queries-ndc-metadata"; + + pub const CONNECTION_URI: &str = "postgresql://postgres:password@localhost:64002"; + + pub const EMPTY_CONNECTION_URI: &str = + "postgresql://postgres:password@localhost:64002/empty"; + } + + pub mod citus { + pub const CHINOOK_NDC_METADATA_PATH: &str = "static/citus/v3-chinook-ndc-metadata"; + + pub const CONNECTION_URI: &str = + "postgresql://postgres:password@localhost:64004?sslmode=disable"; + } + + pub mod cockroach { + pub const CHINOOK_NDC_METADATA_PATH: &str = "static/cockroach/v3-chinook-ndc-metadata"; + + pub const CONNECTION_URI: &str = "postgresql://postgres:password@localhost:64003/defaultdb"; + } + + /// Find the project root via the crate root provided by `cargo test`, + /// and get our single static configuration file. + /// This depends on the convention that all our crates live in `/crates/` + /// and will break in the unlikely case that we change this + pub fn get_path_from_project_root(ndc_metadata_path: impl AsRef) -> PathBuf { + let mut d = PathBuf::from(env!("CARGO_MANIFEST_DIR")); + d.push("../../"); + d.push(ndc_metadata_path); + + d + } +} diff --git a/crates/configuration/src/tests.rs b/crates/configuration/src/tests.rs new file mode 100644 index 000000000..af58672e9 --- /dev/null +++ b/crates/configuration/src/tests.rs @@ -0,0 +1,96 @@ +//! Tests that configuration generation has not changed. +//! +//! If you have changed it intentionally, run `just generate-configuration`. +//! +//! The github CI setup runs these tests subject to the filtering logic in +//! '.github/test-configuration.json'. Naming a test with the prefix 'postgres_current_only` will +//! ensure they only run on the latest version of postgres being tested. This is necessary because +//! they rely on supporting data (the chinook NDC metadata configuration) which we maintain only for +//! the latest version. + +#![cfg(test)] + +use std::{collections::HashMap, path::Path}; + +use crate::common; +use similar_asserts::assert_eq; + +#[tokio::test] +async fn postgres_current_only_broken_metadata_is_up_to_date() { + introspection_is_idempotent( + common::postgres::EMPTY_CONNECTION_URI, + common::postgres::BROKEN_QUERIES_NDC_METADATA_PATH, + ) + .await + .unwrap(); +} + +#[tokio::test] +async fn postgres_current_only_configure_is_idempotent() { + introspection_is_idempotent( + common::postgres::CONNECTION_URI, + common::postgres::CHINOOK_NDC_METADATA_PATH, + ) + .await + .unwrap(); +} + +#[tokio::test] +async fn citus_current_only_configure_is_idempotent() { + introspection_is_idempotent( + common::citus::CONNECTION_URI, + common::citus::CHINOOK_NDC_METADATA_PATH, + ) + .await + .unwrap(); +} + +#[tokio::test] +async fn cockroach_current_only_configure_is_idempotent() { + introspection_is_idempotent( + common::cockroach::CONNECTION_URI, + common::cockroach::CHINOOK_NDC_METADATA_PATH, + ) + .await + .unwrap(); +} + +// Tests that configuration generation has not changed. +// +// This test does not use insta snapshots because it checks the NDC metadata file that is shared with +// other tests. +// +// If you have changed it intentionally, run `just generate-configuration`. +pub async fn introspection_is_idempotent( + connection_string: &str, + chinook_ndc_metadata_path: impl AsRef + Sync, +) -> anyhow::Result<()> { + let parsed_configuration = crate::parse_configuration(common::get_path_from_project_root( + &chinook_ndc_metadata_path, + )) + .await?; + let environment = HashMap::from([( + crate::DEFAULT_CONNECTION_URI_VARIABLE.into(), + connection_string.into(), + )]); + + let introspected_configuration = + crate::introspect(parsed_configuration.clone(), environment).await?; + + assert_eq!(parsed_configuration, introspected_configuration); + Ok(()) +} + +pub async fn configure_initial_configuration_is_unchanged( + connection_string: &str, +) -> crate::ParsedConfiguration { + let args = crate::ParsedConfiguration::initial(); + let environment = HashMap::from([( + crate::DEFAULT_CONNECTION_URI_VARIABLE.into(), + connection_string.into(), + )]); + + crate::introspect(args, environment) + .await + .expect("configuration::introspect") +} diff --git a/crates/configuration/src/version3/mod.rs b/crates/configuration/src/version3/mod.rs index c612c0ae0..b6a3fc6b4 100644 --- a/crates/configuration/src/version3/mod.rs +++ b/crates/configuration/src/version3/mod.rs @@ -7,7 +7,7 @@ pub(crate) mod options; use std::borrow::Cow; use std::collections::{BTreeMap, BTreeSet}; -use std::path::{Path, PathBuf}; +use std::path::Path; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -24,6 +24,9 @@ use crate::error::{ }; use crate::values::{ConnectionUri, Secret}; +#[cfg(test)] +mod tests; + const CONFIGURATION_FILENAME: &str = "configuration.json"; const CONFIGURATION_JSONSCHEMA_FILENAME: &str = "schema.json"; const CONFIGURATION_QUERY: &str = include_str!("version3.sql"); @@ -39,6 +42,7 @@ pub struct RawConfiguration { #[serde(default)] pub schema: Option, /// Database connection settings. + #[serde(default = "connection_settings::DatabaseConnectionSettings::empty")] pub connection_settings: connection_settings::DatabaseConnectionSettings, /// Connector metadata. #[serde(default)] @@ -72,21 +76,6 @@ impl RawConfiguration { } } -/// Validate the user configuration. -pub fn validate_raw_configuration( - file_path: PathBuf, - config: RawConfiguration, -) -> Result { - match &config.connection_settings.connection_uri { - ConnectionUri(Secret::Plain(uri)) if uri.is_empty() => { - Err(ParseConfigurationError::EmptyConnectionUri { file_path }) - } - _ => Ok(()), - }?; - - Ok(config) -} - /// Construct the NDC metadata configuration by introspecting the database. pub async fn introspect( args: RawConfiguration, diff --git a/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__configuration_tests__get_configuration_schema.snap b/crates/configuration/src/version3/snapshots/ndc_postgres_configuration__version3__tests__get_configuration_schema.snap similarity index 98% rename from crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__configuration_tests__get_configuration_schema.snap rename to crates/configuration/src/version3/snapshots/ndc_postgres_configuration__version3__tests__get_configuration_schema.snap index 4f0b82c75..32f52fec8 100644 --- a/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__configuration_tests__get_configuration_schema.snap +++ b/crates/configuration/src/version3/snapshots/ndc_postgres_configuration__version3__tests__get_configuration_schema.snap @@ -1,5 +1,5 @@ --- -source: crates/tests/databases-tests/src/postgres/configuration_tests.rs +source: crates/configuration/src/version3/tests.rs expression: schema --- { @@ -8,7 +8,6 @@ expression: schema "description": "Initial configuration, just enough to connect to a database and elaborate a full 'Configuration'.", "type": "object", "required": [ - "connectionSettings", "version" ], "properties": { @@ -25,6 +24,19 @@ expression: schema }, "connectionSettings": { "description": "Database connection settings.", + "default": { + "connectionUri": { + "variable": "CONNECTION_URI" + }, + "poolSettings": { + "maxConnections": 50, + "poolTimeout": 30, + "idleTimeout": 180, + "checkConnectionAfterIdle": 60, + "connectionLifetime": 600 + }, + "isolationLevel": "ReadCommitted" + }, "allOf": [ { "$ref": "#/definitions/DatabaseConnectionSettings" diff --git a/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__configuration_tests__postgres_current_only_configure_v3_initial_configuration_is_unchanged.snap b/crates/configuration/src/version3/snapshots/ndc_postgres_configuration__version3__tests__postgres_current_only_configure_initial_configuration_is_unchanged.snap similarity index 99% rename from crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__configuration_tests__postgres_current_only_configure_v3_initial_configuration_is_unchanged.snap rename to crates/configuration/src/version3/snapshots/ndc_postgres_configuration__version3__tests__postgres_current_only_configure_initial_configuration_is_unchanged.snap index 4dc58aceb..d8c964ace 100644 --- a/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__configuration_tests__postgres_current_only_configure_v3_initial_configuration_is_unchanged.snap +++ b/crates/configuration/src/version3/snapshots/ndc_postgres_configuration__version3__tests__postgres_current_only_configure_initial_configuration_is_unchanged.snap @@ -1,5 +1,5 @@ --- -source: crates/tests/databases-tests/src/postgres/configuration_tests.rs +source: crates/configuration/src/version3/tests.rs expression: default_configuration --- { @@ -7,7 +7,7 @@ expression: default_configuration "$schema": "schema.json", "connectionSettings": { "connectionUri": { - "variable": "MAGIC_URI" + "variable": "CONNECTION_URI" }, "poolSettings": { "maxConnections": 50, diff --git a/crates/configuration/src/version3/tests.rs b/crates/configuration/src/version3/tests.rs new file mode 100644 index 000000000..3da94c157 --- /dev/null +++ b/crates/configuration/src/version3/tests.rs @@ -0,0 +1,116 @@ +//! Tests that configuration generation has not changed. +//! +//! If you have changed it intentionally, run `just generate-configuration`. +//! +//! The github CI setup runs these tests subject to the filtering logic in +//! '.github/test-configuration.json'. Naming a test with the prefix 'postgres_current_only` will +//! ensure they only run on the latest version of postgres being tested. This is necessary because +//! they rely on supporting data (the chinook NDC metadata configuration) which we maintain only for +//! the latest version. + +#![cfg(test)] + +use crate::version3::{introspect, RawConfiguration}; +use std::collections::HashMap; +use std::fmt::Write; +use std::path::Path; + +use crate::common; + +#[tokio::test] +async fn get_configuration_schema() { + let schema = schemars::schema_for!(RawConfiguration); + insta::assert_json_snapshot!(schema); +} + +// version 3 tests + +#[tokio::test] +async fn postgres_configuration_v3_conforms_to_the_schema() { + configuration_conforms_to_the_schema(common::postgres::CHINOOK_NDC_METADATA_PATH) + .await + .unwrap(); +} + +#[tokio::test] +async fn citus_configuration_v3_conforms_to_the_schema() { + configuration_conforms_to_the_schema(common::citus::CHINOOK_NDC_METADATA_PATH) + .await + .unwrap(); +} + +#[tokio::test] +async fn cockroach_configuration_v3_conforms_to_the_schema() { + configuration_conforms_to_the_schema(common::cockroach::CHINOOK_NDC_METADATA_PATH) + .await + .unwrap(); +} + +#[tokio::test] +async fn postgres_current_only_configure_initial_configuration_is_unchanged() { + let args = RawConfiguration::empty(); + let connection_string = common::postgres::CONNECTION_URI; + let environment = HashMap::from([( + crate::DEFAULT_CONNECTION_URI_VARIABLE.into(), + connection_string.into(), + )]); + + let default_configuration = introspect(args, environment) + .await + .expect("configuration::introspect"); + + insta::assert_json_snapshot!(default_configuration); +} + +pub async fn configuration_conforms_to_the_schema( + chinook_ndc_metadata_path: impl AsRef, +) -> anyhow::Result<()> { + check_value_conforms_to_schema::( + &read_configuration(chinook_ndc_metadata_path).await?, + ); + Ok(()) +} + +async fn read_configuration( + chinook_ndc_metadata_path: impl AsRef, +) -> anyhow::Result { + let absolute_configuration_directory = + common::get_path_from_project_root(chinook_ndc_metadata_path); + + let contents = + tokio::fs::read_to_string(absolute_configuration_directory.join("configuration.json")) + .await?; + + Ok(serde_json::from_str(&contents)?) +} +/// Checks that a given value conforms to the schema generated by `schemars`. +/// +/// Panics with a human-readable error if the value does not conform, or if the +/// schema could not be compiled. +pub fn check_value_conforms_to_schema(value: &serde_json::Value) { + let schema_json = serde_json::to_value(schemars::schema_for!(T)) + .expect("the schema could not be converted to JSON"); + let schema = jsonschema::JSONSchema::options() + .with_draft(jsonschema::Draft::Draft7) + .compile(&schema_json) + .expect("the schema could not be compiled"); + + let result = schema.validate(value); + + match result { + Ok(()) => (), + Err(errors) => { + panic!( + "The configuration does not conform to the schema.\n{}", + errors.fold(String::new(), |mut str, error| { + let _ = write!( + str, + "{}\ninstance path: {}\nschema path: {}\n\n", + error, error.instance_path, error.schema_path + ); + str + }) + ) + } + } +} diff --git a/crates/configuration/src/version4/mod.rs b/crates/configuration/src/version4/mod.rs index cb9837547..354ab9b7f 100644 --- a/crates/configuration/src/version4/mod.rs +++ b/crates/configuration/src/version4/mod.rs @@ -9,7 +9,7 @@ mod upgrade_from_v3; use std::borrow::Cow; use std::collections::BTreeMap; -use std::path::{Path, PathBuf}; +use std::path::Path; pub use to_runtime_configuration::make_runtime_configuration; pub use upgrade_from_v3::upgrade_from_v3; @@ -74,21 +74,6 @@ impl ParsedConfiguration { } } -/// Validate the user configuration. -pub fn validate_raw_configuration( - file_path: PathBuf, - config: ParsedConfiguration, -) -> Result { - match &config.connection_settings.connection_uri { - ConnectionUri(Secret::Plain(uri)) if uri.is_empty() => { - Err(ParseConfigurationError::EmptyConnectionUri { file_path }) - } - _ => Ok(()), - }?; - - Ok(config) -} - /// Construct the NDC metadata configuration by introspecting the database. pub async fn introspect( args: ParsedConfiguration, diff --git a/crates/configuration/src/version4/to_runtime_configuration.rs b/crates/configuration/src/version4/to_runtime_configuration.rs index 1bc0c0b36..889b1e16a 100644 --- a/crates/configuration/src/version4/to_runtime_configuration.rs +++ b/crates/configuration/src/version4/to_runtime_configuration.rs @@ -1,5 +1,3 @@ -use query_engine_metadata; - use super::metadata; use super::ParsedConfiguration; use crate::environment::Environment; diff --git a/crates/documentation/openapi/Cargo.toml b/crates/documentation/openapi/Cargo.toml index e681f26b8..3308a1f2d 100644 --- a/crates/documentation/openapi/Cargo.toml +++ b/crates/documentation/openapi/Cargo.toml @@ -7,15 +7,10 @@ license.workspace = true [lints] workspace = true -[lib] -name = "openapi_generator" -path = "src/lib.rs" - [[bin]] name = "openapi-generator" path = "src/main.rs" [dependencies] ndc-postgres-configuration = { path = "../../configuration" } -schemars = { version = "0.8.17", features = ["smol_str", "preserve_order"] } serde_json = { version = "1.0.116", features = ["raw_value"] } diff --git a/crates/documentation/openapi/src/generator.rs b/crates/documentation/openapi/src/generator.rs deleted file mode 100644 index 645dd0bba..000000000 --- a/crates/documentation/openapi/src/generator.rs +++ /dev/null @@ -1,8 +0,0 @@ -use schemars::{gen::SchemaSettings, schema::RootSchema}; - -pub fn generate_schema() -> RootSchema { - SchemaSettings::openapi3() - .into_generator() - // TODO: Make this part of the public interface of the configuration crate? - .into_root_schema_for::() -} diff --git a/crates/documentation/openapi/src/lib.rs b/crates/documentation/openapi/src/lib.rs deleted file mode 100644 index 2a22e3d00..000000000 --- a/crates/documentation/openapi/src/lib.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod generator; diff --git a/crates/documentation/openapi/src/main.rs b/crates/documentation/openapi/src/main.rs index 392cd4f8b..c0692feab 100644 --- a/crates/documentation/openapi/src/main.rs +++ b/crates/documentation/openapi/src/main.rs @@ -1,9 +1,9 @@ -use openapi_generator::generator; +use ndc_postgres_configuration::generate_latest_schema; use std::io; fn main() -> io::Result<()> { - let schema = generator::generate_schema(); + let schema = generate_latest_schema(); serde_json::to_writer_pretty(io::stdout(), &schema)?; Ok(()) } diff --git a/crates/query-engine/translation/Cargo.toml b/crates/query-engine/translation/Cargo.toml index 79c31b1d5..e3d580d50 100644 --- a/crates/query-engine/translation/Cargo.toml +++ b/crates/query-engine/translation/Cargo.toml @@ -17,6 +17,9 @@ ndc-sdk = { workspace = true } indexmap = "2" multimap = "0.9.1" serde_json = "1.0.116" +anyhow = "1.0.82" +thiserror = "1.0.59" +tokio = "1.37.0" [dev-dependencies] insta = { version = "1.38.0", features = ["json"] } diff --git a/crates/query-engine/translation/src/translation/error.rs b/crates/query-engine/translation/src/translation/error.rs index 0fd7e3c3e..9e24e1b48 100644 --- a/crates/query-engine/translation/src/translation/error.rs +++ b/crates/query-engine/translation/src/translation/error.rs @@ -3,7 +3,7 @@ use query_engine_metadata::metadata::{database, Type}; /// A type for translation errors. -#[derive(Debug, Clone)] +#[derive(Debug, Clone, thiserror::Error)] pub enum Error { CollectionNotFound(String), ScalarTypeNotFound(String), diff --git a/crates/query-engine/translation/tests/common/mod.rs b/crates/query-engine/translation/tests/common/mod.rs index 3185f18a7..4e46feca1 100644 --- a/crates/query-engine/translation/tests/common/mod.rs +++ b/crates/query-engine/translation/tests/common/mod.rs @@ -1,21 +1,26 @@ use std::fs; use std::path::PathBuf; -use ndc_postgres_configuration::version3; use query_engine_sql::sql; use query_engine_translation::translation; -pub fn test_translation(testname: &str) -> Result { - test_query_translation(testname) +pub async fn test_translation(testname: &str) -> anyhow::Result { + test_query_translation(testname).await } /// Translate a query to SQL and compare against the snapshot. -pub fn test_query_translation(testname: &str) -> Result { +pub async fn test_query_translation(testname: &str) -> anyhow::Result { let directory = PathBuf::from("tests/goldenfiles").join(testname); - let metadata_versioned = - serde_json::from_str(&fs::read_to_string(directory.join("tables.json")).unwrap()).unwrap(); - let metadata = version3::convert_metadata(metadata_versioned); + let parsed_configuration = ndc_postgres_configuration::parse_configuration(&directory).await?; + let configuration = ndc_postgres_configuration::make_runtime_configuration( + parsed_configuration, + ndc_postgres_configuration::environment::FixedEnvironment::from([( + "CONNECTION_URI".into(), + "the translation tests do not rely on a database connection".into(), + )]), + )?; + let metadata = configuration.metadata; let request = serde_json::from_str(&fs::read_to_string(directory.join("request.json")).unwrap()).unwrap(); @@ -62,14 +67,21 @@ pub fn test_query_translation(testname: &str) -> Result Result { +) -> anyhow::Result { let directory = PathBuf::from("tests/goldenfiles/mutations").join(testname); - let metadata_versioned = - serde_json::from_str(&fs::read_to_string(directory.join("tables.json")).unwrap()).unwrap(); - let metadata = version3::convert_metadata(metadata_versioned); + + let parsed_configuration = ndc_postgres_configuration::parse_configuration(&directory).await?; + let configuration = ndc_postgres_configuration::make_runtime_configuration( + parsed_configuration, + ndc_postgres_configuration::environment::FixedEnvironment::from([( + "CONNECTION_URI".into(), + "the translation tests do not rely on a database connection".into(), + )]), + )?; + let metadata = configuration.metadata; let request: ndc_sdk::models::MutationRequest = serde_json::from_str(&fs::read_to_string(directory.join("request.json")).unwrap()).unwrap(); diff --git a/crates/query-engine/translation/tests/goldenfiles/aggregate_count_albums/configuration.json b/crates/query-engine/translation/tests/goldenfiles/aggregate_count_albums/configuration.json new file mode 100644 index 000000000..3d4963b51 --- /dev/null +++ b/crates/query-engine/translation/tests/goldenfiles/aggregate_count_albums/configuration.json @@ -0,0 +1,31 @@ +{ + "version": "3", + "metadata": { + "tables": { + "Album": { + "schemaName": "public", + "tableName": "Album", + "columns": { + "AlbumId": { + "name": "AlbumId", + "type": { + "scalarType": "int4" + } + }, + "Title": { + "name": "Title", + "type": { + "scalarType": "varchar" + } + }, + "ArtistId": { + "name": "ArtistId", + "type": { + "scalarType": "int4" + } + } + } + } + } + } +} diff --git a/crates/query-engine/translation/tests/goldenfiles/aggregate_count_albums/tables.json b/crates/query-engine/translation/tests/goldenfiles/aggregate_count_albums/tables.json deleted file mode 100644 index 0bceb228a..000000000 --- a/crates/query-engine/translation/tests/goldenfiles/aggregate_count_albums/tables.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "tables": { - "Album": { - "schemaName": "public", - "tableName": "Album", - "columns": { - "AlbumId": { - "name": "AlbumId", - "type": { - "scalarType": "int4" - } - }, - "Title": { - "name": "Title", - "type": { - "scalarType": "varchar" - } - }, - "ArtistId": { - "name": "ArtistId", - "type": { - "scalarType": "int4" - } - } - } - } - } -} diff --git a/crates/query-engine/translation/tests/goldenfiles/aggregate_distinct_albums/configuration.json b/crates/query-engine/translation/tests/goldenfiles/aggregate_distinct_albums/configuration.json new file mode 100644 index 000000000..3d4963b51 --- /dev/null +++ b/crates/query-engine/translation/tests/goldenfiles/aggregate_distinct_albums/configuration.json @@ -0,0 +1,31 @@ +{ + "version": "3", + "metadata": { + "tables": { + "Album": { + "schemaName": "public", + "tableName": "Album", + "columns": { + "AlbumId": { + "name": "AlbumId", + "type": { + "scalarType": "int4" + } + }, + "Title": { + "name": "Title", + "type": { + "scalarType": "varchar" + } + }, + "ArtistId": { + "name": "ArtistId", + "type": { + "scalarType": "int4" + } + } + } + } + } + } +} diff --git a/crates/query-engine/translation/tests/goldenfiles/aggregate_distinct_albums/tables.json b/crates/query-engine/translation/tests/goldenfiles/aggregate_distinct_albums/tables.json deleted file mode 100644 index 0bceb228a..000000000 --- a/crates/query-engine/translation/tests/goldenfiles/aggregate_distinct_albums/tables.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "tables": { - "Album": { - "schemaName": "public", - "tableName": "Album", - "columns": { - "AlbumId": { - "name": "AlbumId", - "type": { - "scalarType": "int4" - } - }, - "Title": { - "name": "Title", - "type": { - "scalarType": "varchar" - } - }, - "ArtistId": { - "name": "ArtistId", - "type": { - "scalarType": "int4" - } - } - } - } - } -} diff --git a/crates/query-engine/translation/tests/goldenfiles/aggregate_function_albums/configuration.json b/crates/query-engine/translation/tests/goldenfiles/aggregate_function_albums/configuration.json new file mode 100644 index 000000000..3d4963b51 --- /dev/null +++ b/crates/query-engine/translation/tests/goldenfiles/aggregate_function_albums/configuration.json @@ -0,0 +1,31 @@ +{ + "version": "3", + "metadata": { + "tables": { + "Album": { + "schemaName": "public", + "tableName": "Album", + "columns": { + "AlbumId": { + "name": "AlbumId", + "type": { + "scalarType": "int4" + } + }, + "Title": { + "name": "Title", + "type": { + "scalarType": "varchar" + } + }, + "ArtistId": { + "name": "ArtistId", + "type": { + "scalarType": "int4" + } + } + } + } + } + } +} diff --git a/crates/query-engine/translation/tests/goldenfiles/aggregate_function_albums/tables.json b/crates/query-engine/translation/tests/goldenfiles/aggregate_function_albums/tables.json deleted file mode 100644 index 0bceb228a..000000000 --- a/crates/query-engine/translation/tests/goldenfiles/aggregate_function_albums/tables.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "tables": { - "Album": { - "schemaName": "public", - "tableName": "Album", - "columns": { - "AlbumId": { - "name": "AlbumId", - "type": { - "scalarType": "int4" - } - }, - "Title": { - "name": "Title", - "type": { - "scalarType": "varchar" - } - }, - "ArtistId": { - "name": "ArtistId", - "type": { - "scalarType": "int4" - } - } - } - } - } -} diff --git a/crates/query-engine/translation/tests/goldenfiles/dup_array_relationship/configuration.json b/crates/query-engine/translation/tests/goldenfiles/dup_array_relationship/configuration.json new file mode 100644 index 000000000..668c8d63d --- /dev/null +++ b/crates/query-engine/translation/tests/goldenfiles/dup_array_relationship/configuration.json @@ -0,0 +1,49 @@ +{ + "version": "3", + "metadata": { + "tables": { + "Album": { + "schemaName": "public", + "tableName": "Album", + "columns": { + "AlbumId": { + "name": "AlbumId", + "type": { + "scalarType": "int4" + } + }, + "Title": { + "name": "Title", + "type": { + "scalarType": "varchar" + } + }, + "ArtistId": { + "name": "ArtistId", + "type": { + "scalarType": "int4" + } + } + } + }, + "Artist": { + "schemaName": "public", + "tableName": "Artist", + "columns": { + "ArtistId": { + "name": "ArtistId", + "type": { + "scalarType": "int4" + } + }, + "Name": { + "name": "Name", + "type": { + "scalarType": "varchar" + } + } + } + } + } + } +} diff --git a/crates/query-engine/translation/tests/goldenfiles/dup_array_relationship/tables.json b/crates/query-engine/translation/tests/goldenfiles/dup_array_relationship/tables.json deleted file mode 100644 index 1b79f596e..000000000 --- a/crates/query-engine/translation/tests/goldenfiles/dup_array_relationship/tables.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "tables": { - "Album": { - "schemaName": "public", - "tableName": "Album", - "columns": { - "AlbumId": { - "name": "AlbumId", - "type": { - "scalarType": "int4" - } - }, - "Title": { - "name": "Title", - "type": { - "scalarType": "varchar" - } - }, - "ArtistId": { - "name": "ArtistId", - "type": { - "scalarType": "int4" - } - } - } - }, - "Artist": { - "schemaName": "public", - "tableName": "Artist", - "columns": { - "ArtistId": { - "name": "ArtistId", - "type": { - "scalarType": "int4" - } - }, - "Name": { - "name": "Name", - "type": { - "scalarType": "varchar" - } - } - } - } - } -} diff --git a/crates/query-engine/translation/tests/goldenfiles/mutations/simple/configuration.json b/crates/query-engine/translation/tests/goldenfiles/mutations/simple/configuration.json new file mode 100644 index 000000000..a7adbbf20 --- /dev/null +++ b/crates/query-engine/translation/tests/goldenfiles/mutations/simple/configuration.json @@ -0,0 +1,32 @@ +{ + "version": "3", + "metadata": { + "nativeQueries": { + "delete_playlist_track": { + "sql": "DELETE FROM public.\"PlaylistTrack\" WHERE \"TrackId\" = {{track_id}} RETURNING *", + "columns": { + "PlaylistId": { + "name": "PlaylistId", + "type": { + "scalarType": "int4" + } + }, + "TrackId": { + "name": "TrackId", + "type": { + "scalarType": "int4" + } + } + }, + "arguments": { + "track_id": { + "name": "track_id", + "type": { + "scalarType": "int4" + } + } + } + } + } + } +} diff --git a/crates/query-engine/translation/tests/goldenfiles/mutations/simple/tables.json b/crates/query-engine/translation/tests/goldenfiles/mutations/simple/tables.json deleted file mode 100644 index 12cab1982..000000000 --- a/crates/query-engine/translation/tests/goldenfiles/mutations/simple/tables.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "nativeQueries": { - "delete_playlist_track": { - "sql": "DELETE FROM public.\"PlaylistTrack\" WHERE \"TrackId\" = {{track_id}} RETURNING *", - "columns": { - "PlaylistId": { - "name": "PlaylistId", - "type": { - "scalarType": "int4" - } - }, - "TrackId": { - "name": "TrackId", - "type": { - "scalarType": "int4" - } - } - }, - "arguments": { - "track_id": { - "name": "track_id", - "type": { - "scalarType": "int4" - } - } - } - } - } -} diff --git a/crates/query-engine/translation/tests/goldenfiles/mutations/v1_insert/configuration.json b/crates/query-engine/translation/tests/goldenfiles/mutations/v1_insert/configuration.json new file mode 100644 index 000000000..ff2ad5fb6 --- /dev/null +++ b/crates/query-engine/translation/tests/goldenfiles/mutations/v1_insert/configuration.json @@ -0,0 +1,25 @@ +{ + "version": "3", + "metadata": { + "tables": { + "Artist": { + "schemaName": "public", + "tableName": "Artist", + "columns": { + "id": { + "name": "ArtistId", + "type": { + "scalarType": "int4" + } + }, + "name": { + "name": "Name", + "type": { + "scalarType": "varchar" + } + } + } + } + } + } +} diff --git a/crates/query-engine/translation/tests/goldenfiles/mutations/v1_insert/tables.json b/crates/query-engine/translation/tests/goldenfiles/mutations/v1_insert/tables.json deleted file mode 100644 index 743abbac6..000000000 --- a/crates/query-engine/translation/tests/goldenfiles/mutations/v1_insert/tables.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "tables": { - "Artist": { - "schemaName": "public", - "tableName": "Artist", - "columns": { - "id": { - "name": "ArtistId", - "type": { - "scalarType": "int4" - } - }, - "name": { - "name": "Name", - "type": { - "scalarType": "varchar" - } - } - } - } - } -} diff --git a/crates/query-engine/translation/tests/goldenfiles/native_queries/select_artist/configuration.json b/crates/query-engine/translation/tests/goldenfiles/native_queries/select_artist/configuration.json new file mode 100644 index 000000000..5847e8a66 --- /dev/null +++ b/crates/query-engine/translation/tests/goldenfiles/native_queries/select_artist/configuration.json @@ -0,0 +1,24 @@ +{ + "version": "3", + "metadata": { + "nativeQueries": { + "artist": { + "sql": "SELECT * FROM public.\"Artist\"", + "columns": { + "ArtistId": { + "name": "ArtistId", + "type": { + "scalarType": "int4" + } + }, + "Name": { + "name": "Name", + "type": { + "scalarType": "varchar" + } + } + } + } + } + } +} diff --git a/crates/query-engine/translation/tests/goldenfiles/native_queries/select_artist/tables.json b/crates/query-engine/translation/tests/goldenfiles/native_queries/select_artist/tables.json deleted file mode 100644 index 91820870b..000000000 --- a/crates/query-engine/translation/tests/goldenfiles/native_queries/select_artist/tables.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "nativeQueries": { - "artist": { - "sql": "SELECT * FROM public.\"Artist\"", - "columns": { - "ArtistId": { - "name": "ArtistId", - "type": { - "scalarType": "int4" - } - }, - "Name": { - "name": "Name", - "type": { - "scalarType": "varchar" - } - } - } - } - } -} diff --git a/crates/query-engine/translation/tests/goldenfiles/native_queries/select_artist_by_id/configuration.json b/crates/query-engine/translation/tests/goldenfiles/native_queries/select_artist_by_id/configuration.json new file mode 100644 index 000000000..8123a4f76 --- /dev/null +++ b/crates/query-engine/translation/tests/goldenfiles/native_queries/select_artist_by_id/configuration.json @@ -0,0 +1,32 @@ +{ + "version": "3", + "metadata": { + "nativeQueries": { + "artist_by_id": { + "sql": "SELECT * FROM public.\"Artist\" WHERE \"ArtistId\" = {{id}}", + "columns": { + "ArtistId": { + "name": "ArtistId", + "type": { + "scalarType": "int4" + } + }, + "Name": { + "name": "Name", + "type": { + "scalarType": "varchar" + } + } + }, + "arguments": { + "id": { + "name": "id", + "type": { + "scalarType": "int4" + } + } + } + } + } + } +} diff --git a/crates/query-engine/translation/tests/goldenfiles/native_queries/select_artist_by_id/tables.json b/crates/query-engine/translation/tests/goldenfiles/native_queries/select_artist_by_id/tables.json deleted file mode 100644 index bef3b6e7b..000000000 --- a/crates/query-engine/translation/tests/goldenfiles/native_queries/select_artist_by_id/tables.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "nativeQueries": { - "artist_by_id": { - "sql": "SELECT * FROM public.\"Artist\" WHERE \"ArtistId\" = {{id}}", - "columns": { - "ArtistId": { - "name": "ArtistId", - "type": { - "scalarType": "int4" - } - }, - "Name": { - "name": "Name", - "type": { - "scalarType": "varchar" - } - } - }, - "arguments": { - "id": { - "name": "id", - "type": { - "scalarType": "int4" - } - } - } - } - } -} diff --git a/crates/query-engine/translation/tests/goldenfiles/native_queries/select_artist_by_name/configuration.json b/crates/query-engine/translation/tests/goldenfiles/native_queries/select_artist_by_name/configuration.json new file mode 100644 index 000000000..47c49aab8 --- /dev/null +++ b/crates/query-engine/translation/tests/goldenfiles/native_queries/select_artist_by_name/configuration.json @@ -0,0 +1,32 @@ +{ + "version": "3", + "metadata": { + "nativeQueries": { + "artist_by_name": { + "sql": "SELECT * FROM public.\"Artist\" WHERE \"Name\" = {{name}}", + "columns": { + "ArtistId": { + "name": "ArtistId", + "type": { + "scalarType": "int4" + } + }, + "Name": { + "name": "Name", + "type": { + "scalarType": "varchar" + } + } + }, + "arguments": { + "name": { + "name": "name", + "type": { + "scalarType": "varchar" + } + } + } + } + } + } +} diff --git a/crates/query-engine/translation/tests/goldenfiles/native_queries/select_artist_by_name/tables.json b/crates/query-engine/translation/tests/goldenfiles/native_queries/select_artist_by_name/tables.json deleted file mode 100644 index caac0aaf3..000000000 --- a/crates/query-engine/translation/tests/goldenfiles/native_queries/select_artist_by_name/tables.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "nativeQueries": { - "artist_by_name": { - "sql": "SELECT * FROM public.\"Artist\" WHERE \"Name\" = {{name}}", - "columns": { - "ArtistId": { - "name": "ArtistId", - "type": { - "scalarType": "int4" - } - }, - "Name": { - "name": "Name", - "type": { - "scalarType": "varchar" - } - } - }, - "arguments": { - "name": { - "name": "name", - "type": { - "scalarType": "varchar" - } - } - } - } - } -} diff --git a/crates/query-engine/translation/tests/goldenfiles/native_queries/select_artist_with_album_by_title/configuration.json b/crates/query-engine/translation/tests/goldenfiles/native_queries/select_artist_with_album_by_title/configuration.json new file mode 100644 index 000000000..35df0abce --- /dev/null +++ b/crates/query-engine/translation/tests/goldenfiles/native_queries/select_artist_with_album_by_title/configuration.json @@ -0,0 +1,56 @@ +{ + "version": "3", + "metadata": { + "nativeQueries": { + "artist": { + "sql": "SELECT * FROM public.\"Artist\"", + "columns": { + "ArtistId": { + "name": "ArtistId", + "type": { + "scalarType": "int4" + } + }, + "Name": { + "name": "Name", + "type": { + "scalarType": "varchar" + } + } + }, + "arguments": {} + }, + "album_by_title": { + "sql": "SELECT * FROM public.\"Album\" WHERE \"Title\" LIKE {{title}}", + "columns": { + "AlbumId": { + "name": "AlbumId", + "type": { + "scalarType": "int4" + } + }, + "Title": { + "name": "Title", + "type": { + "scalarType": "varchar" + } + }, + "ArtistId": { + "name": "ArtistId", + "type": { + "scalarType": "int4" + } + } + }, + "arguments": { + "title": { + "name": "title", + "type": { + "scalarType": "varchar" + } + } + } + } + } + } +} diff --git a/crates/query-engine/translation/tests/goldenfiles/native_queries/select_artist_with_album_by_title/tables.json b/crates/query-engine/translation/tests/goldenfiles/native_queries/select_artist_with_album_by_title/tables.json deleted file mode 100644 index 7e0f88b1b..000000000 --- a/crates/query-engine/translation/tests/goldenfiles/native_queries/select_artist_with_album_by_title/tables.json +++ /dev/null @@ -1,53 +0,0 @@ -{ - "nativeQueries": { - "artist": { - "sql": "SELECT * FROM public.\"Artist\"", - "columns": { - "ArtistId": { - "name": "ArtistId", - "type": { - "scalarType": "int4" - } - }, - "Name": { - "name": "Name", - "type": { - "scalarType": "varchar" - } - } - }, - "arguments": {} - }, - "album_by_title": { - "sql": "SELECT * FROM public.\"Album\" WHERE \"Title\" LIKE {{title}}", - "columns": { - "AlbumId": { - "name": "AlbumId", - "type": { - "scalarType": "int4" - } - }, - "Title": { - "name": "Title", - "type": { - "scalarType": "varchar" - } - }, - "ArtistId": { - "name": "ArtistId", - "type": { - "scalarType": "int4" - } - } - }, - "arguments": { - "title": { - "name": "title", - "type": { - "scalarType": "varchar" - } - } - } - } - } -} diff --git a/crates/query-engine/translation/tests/goldenfiles/native_queries/select_artist_with_album_by_title_relationship_arguments/configuration.json b/crates/query-engine/translation/tests/goldenfiles/native_queries/select_artist_with_album_by_title_relationship_arguments/configuration.json new file mode 100644 index 000000000..61e928292 --- /dev/null +++ b/crates/query-engine/translation/tests/goldenfiles/native_queries/select_artist_with_album_by_title_relationship_arguments/configuration.json @@ -0,0 +1,62 @@ +{ + "version": "3", + "metadata": { + "nativeQueries": { + "artist": { + "sql": "SELECT * FROM public.\"Artist\"", + "columns": { + "ArtistId": { + "name": "ArtistId", + "type": { + "scalarType": "int4" + } + }, + "Name": { + "name": "Name", + "type": { + "scalarType": "varchar" + } + } + }, + "arguments": {} + }, + "album_by_title": { + "sql": "SELECT * FROM public.\"Album\" WHERE \"Title\" LIKE {{title}} AND \"AlbumId\" < {{id}}", + "columns": { + "AlbumId": { + "name": "AlbumId", + "type": { + "scalarType": "int4" + } + }, + "Title": { + "name": "Title", + "type": { + "scalarType": "varchar" + } + }, + "ArtistId": { + "name": "ArtistId", + "type": { + "scalarType": "int4" + } + } + }, + "arguments": { + "id": { + "name": "id", + "type": { + "scalarType": "int4" + } + }, + "title": { + "name": "title", + "type": { + "scalarType": "varchar" + } + } + } + } + } + } +} diff --git a/crates/query-engine/translation/tests/goldenfiles/native_queries/select_artist_with_album_by_title_relationship_arguments/tables.json b/crates/query-engine/translation/tests/goldenfiles/native_queries/select_artist_with_album_by_title_relationship_arguments/tables.json deleted file mode 100644 index 9c5915d89..000000000 --- a/crates/query-engine/translation/tests/goldenfiles/native_queries/select_artist_with_album_by_title_relationship_arguments/tables.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "nativeQueries": { - "artist": { - "sql": "SELECT * FROM public.\"Artist\"", - "columns": { - "ArtistId": { - "name": "ArtistId", - "type": { - "scalarType": "int4" - } - }, - "Name": { - "name": "Name", - "type": { - "scalarType": "varchar" - } - } - }, - "arguments": {} - }, - "album_by_title": { - "sql": "SELECT * FROM public.\"Album\" WHERE \"Title\" LIKE {{title}} AND \"AlbumId\" < {{id}}", - "columns": { - "AlbumId": { - "name": "AlbumId", - "type": { - "scalarType": "int4" - } - }, - "Title": { - "name": "Title", - "type": { - "scalarType": "varchar" - } - }, - "ArtistId": { - "name": "ArtistId", - "type": { - "scalarType": "int4" - } - } - }, - "arguments": { - "id": { - "name": "id", - "type": { - "scalarType": "int4" - } - }, - "title": { - "name": "title", - "type": { - "scalarType": "varchar" - } - } - } - } - } -} diff --git a/crates/query-engine/translation/tests/goldenfiles/nested_aggregates/configuration.json b/crates/query-engine/translation/tests/goldenfiles/nested_aggregates/configuration.json new file mode 100644 index 000000000..3c20fa37d --- /dev/null +++ b/crates/query-engine/translation/tests/goldenfiles/nested_aggregates/configuration.json @@ -0,0 +1,73 @@ +{ + "version": "3", + "metadata": { + "tables": { + "Album": { + "schemaName": "public", + "tableName": "Album", + "columns": { + "AlbumId": { + "name": "AlbumId", + "type": { + "scalarType": "int4" + } + }, + "Title": { + "name": "Title", + "type": { + "scalarType": "varchar" + } + }, + "ArtistId": { + "name": "ArtistId", + "type": { + "scalarType": "int4" + } + } + } + }, + "Artist": { + "schemaName": "public", + "tableName": "Artist", + "columns": { + "ArtistId": { + "name": "ArtistId", + "type": { + "scalarType": "int4" + } + }, + "Name": { + "name": "Name", + "type": { + "scalarType": "varchar" + } + } + } + }, + "Track": { + "schemaName": "public", + "tableName": "Track", + "columns": { + "TrackId": { + "name": "TrackId", + "type": { + "scalarType": "int4" + } + }, + "Name": { + "name": "Name", + "type": { + "scalarType": "varchar" + } + }, + "AlbumId": { + "name": "AlbumId", + "type": { + "scalarType": "int4" + } + } + } + } + } + } +} diff --git a/crates/query-engine/translation/tests/goldenfiles/nested_aggregates/tables.json b/crates/query-engine/translation/tests/goldenfiles/nested_aggregates/tables.json deleted file mode 100644 index 17d9782e2..000000000 --- a/crates/query-engine/translation/tests/goldenfiles/nested_aggregates/tables.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "tables": { - "Album": { - "schemaName": "public", - "tableName": "Album", - "columns": { - "AlbumId": { - "name": "AlbumId", - "type": { - "scalarType": "int4" - } - }, - "Title": { - "name": "Title", - "type": { - "scalarType": "varchar" - } - }, - "ArtistId": { - "name": "ArtistId", - "type": { - "scalarType": "int4" - } - } - } - }, - "Artist": { - "schemaName": "public", - "tableName": "Artist", - "columns": { - "ArtistId": { - "name": "ArtistId", - "type": { - "scalarType": "int4" - } - }, - "Name": { - "name": "Name", - "type": { - "scalarType": "varchar" - } - } - } - }, - "Track": { - "schemaName": "public", - "tableName": "Track", - "columns": { - "TrackId": { - "name": "TrackId", - "type": { - "scalarType": "int4" - } - }, - "Name": { - "name": "Name", - "type": { - "scalarType": "varchar" - } - }, - "AlbumId": { - "name": "AlbumId", - "type": { - "scalarType": "int4" - } - } - } - } - } -} diff --git a/crates/query-engine/translation/tests/goldenfiles/nested_array_relationships/configuration.json b/crates/query-engine/translation/tests/goldenfiles/nested_array_relationships/configuration.json new file mode 100644 index 000000000..3c20fa37d --- /dev/null +++ b/crates/query-engine/translation/tests/goldenfiles/nested_array_relationships/configuration.json @@ -0,0 +1,73 @@ +{ + "version": "3", + "metadata": { + "tables": { + "Album": { + "schemaName": "public", + "tableName": "Album", + "columns": { + "AlbumId": { + "name": "AlbumId", + "type": { + "scalarType": "int4" + } + }, + "Title": { + "name": "Title", + "type": { + "scalarType": "varchar" + } + }, + "ArtistId": { + "name": "ArtistId", + "type": { + "scalarType": "int4" + } + } + } + }, + "Artist": { + "schemaName": "public", + "tableName": "Artist", + "columns": { + "ArtistId": { + "name": "ArtistId", + "type": { + "scalarType": "int4" + } + }, + "Name": { + "name": "Name", + "type": { + "scalarType": "varchar" + } + } + } + }, + "Track": { + "schemaName": "public", + "tableName": "Track", + "columns": { + "TrackId": { + "name": "TrackId", + "type": { + "scalarType": "int4" + } + }, + "Name": { + "name": "Name", + "type": { + "scalarType": "varchar" + } + }, + "AlbumId": { + "name": "AlbumId", + "type": { + "scalarType": "int4" + } + } + } + } + } + } +} diff --git a/crates/query-engine/translation/tests/goldenfiles/nested_array_relationships/tables.json b/crates/query-engine/translation/tests/goldenfiles/nested_array_relationships/tables.json deleted file mode 100644 index 17d9782e2..000000000 --- a/crates/query-engine/translation/tests/goldenfiles/nested_array_relationships/tables.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "tables": { - "Album": { - "schemaName": "public", - "tableName": "Album", - "columns": { - "AlbumId": { - "name": "AlbumId", - "type": { - "scalarType": "int4" - } - }, - "Title": { - "name": "Title", - "type": { - "scalarType": "varchar" - } - }, - "ArtistId": { - "name": "ArtistId", - "type": { - "scalarType": "int4" - } - } - } - }, - "Artist": { - "schemaName": "public", - "tableName": "Artist", - "columns": { - "ArtistId": { - "name": "ArtistId", - "type": { - "scalarType": "int4" - } - }, - "Name": { - "name": "Name", - "type": { - "scalarType": "varchar" - } - } - } - }, - "Track": { - "schemaName": "public", - "tableName": "Track", - "columns": { - "TrackId": { - "name": "TrackId", - "type": { - "scalarType": "int4" - } - }, - "Name": { - "name": "Name", - "type": { - "scalarType": "varchar" - } - }, - "AlbumId": { - "name": "AlbumId", - "type": { - "scalarType": "int4" - } - } - } - } - } -} diff --git a/crates/query-engine/translation/tests/goldenfiles/nested_recursive_relationship/configuration.json b/crates/query-engine/translation/tests/goldenfiles/nested_recursive_relationship/configuration.json new file mode 100644 index 000000000..668c8d63d --- /dev/null +++ b/crates/query-engine/translation/tests/goldenfiles/nested_recursive_relationship/configuration.json @@ -0,0 +1,49 @@ +{ + "version": "3", + "metadata": { + "tables": { + "Album": { + "schemaName": "public", + "tableName": "Album", + "columns": { + "AlbumId": { + "name": "AlbumId", + "type": { + "scalarType": "int4" + } + }, + "Title": { + "name": "Title", + "type": { + "scalarType": "varchar" + } + }, + "ArtistId": { + "name": "ArtistId", + "type": { + "scalarType": "int4" + } + } + } + }, + "Artist": { + "schemaName": "public", + "tableName": "Artist", + "columns": { + "ArtistId": { + "name": "ArtistId", + "type": { + "scalarType": "int4" + } + }, + "Name": { + "name": "Name", + "type": { + "scalarType": "varchar" + } + } + } + } + } + } +} diff --git a/crates/query-engine/translation/tests/goldenfiles/nested_recursive_relationship/tables.json b/crates/query-engine/translation/tests/goldenfiles/nested_recursive_relationship/tables.json deleted file mode 100644 index 1b79f596e..000000000 --- a/crates/query-engine/translation/tests/goldenfiles/nested_recursive_relationship/tables.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "tables": { - "Album": { - "schemaName": "public", - "tableName": "Album", - "columns": { - "AlbumId": { - "name": "AlbumId", - "type": { - "scalarType": "int4" - } - }, - "Title": { - "name": "Title", - "type": { - "scalarType": "varchar" - } - }, - "ArtistId": { - "name": "ArtistId", - "type": { - "scalarType": "int4" - } - } - } - }, - "Artist": { - "schemaName": "public", - "tableName": "Artist", - "columns": { - "ArtistId": { - "name": "ArtistId", - "type": { - "scalarType": "int4" - } - }, - "Name": { - "name": "Name", - "type": { - "scalarType": "varchar" - } - } - } - } - } -} diff --git a/crates/query-engine/translation/tests/goldenfiles/no_fields/configuration.json b/crates/query-engine/translation/tests/goldenfiles/no_fields/configuration.json new file mode 100644 index 000000000..95392d8d6 --- /dev/null +++ b/crates/query-engine/translation/tests/goldenfiles/no_fields/configuration.json @@ -0,0 +1,46 @@ +{ + "version": "3", + "metadata": { + "tables": { + "Album": { + "schemaName": "public", + "tableName": "Album", + "columns": { + "Id": { + "name": "AlbumId", + "type": { + "scalarType": "int4" + } + }, + "Title": { + "name": "Title", + "type": { + "scalarType": "varchar" + } + } + } + } + }, + "comparisonOperators": { + "varchar": { + "_eq": { + "operatorName": "=", + "argumentType": "varchar", + "operatorKind": "equal" + }, + "_in": { + "operatorName": "IN", + "argumentType": "varchar", + "operatorKind": "in" + } + }, + "int4": { + "_eq": { + "operatorName": "=", + "argumentType": "int4", + "operatorKind": "equal" + } + } + } + } +} diff --git a/crates/query-engine/translation/tests/goldenfiles/no_fields/tables.json b/crates/query-engine/translation/tests/goldenfiles/no_fields/tables.json deleted file mode 100644 index f9eeb8c9f..000000000 --- a/crates/query-engine/translation/tests/goldenfiles/no_fields/tables.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "tables": { - "Album": { - "schemaName": "public", - "tableName": "Album", - "columns": { - "Id": { - "name": "AlbumId", - "type": { - "scalarType": "int4" - } - }, - "Title": { - "name": "Title", - "type": { - "scalarType": "varchar" - } - } - } - } - }, - "comparisonOperators": { - "varchar": { - "_eq": { - "operatorName": "=", - "argumentType": "varchar", - "operatorKind": "equal" - }, - "_in": { - "operatorName": "IN", - "argumentType": "varchar", - "operatorKind": "in" - } - }, - "int4": { - "_eq": { - "operatorName": "=", - "argumentType": "int4", - "operatorKind": "equal" - } - } - } -} diff --git a/crates/query-engine/translation/tests/goldenfiles/select_array_column/configuration.json b/crates/query-engine/translation/tests/goldenfiles/select_array_column/configuration.json new file mode 100644 index 000000000..521a29057 --- /dev/null +++ b/crates/query-engine/translation/tests/goldenfiles/select_array_column/configuration.json @@ -0,0 +1,39 @@ +{ + "version": "3", + "metadata": { + "nativeQueries": { + "array_series": { + "sql": "SELECT array_agg(arr.series) AS series FROM (SELECT generate_series({{from}},{{to}}) AS series) AS arr", + "columns": { + "series": { + "name": "series", + "type": { + "arrayType": { + "scalarType": "int4" + } + }, + "nullable": "nullable", + "description": null + } + }, + "arguments": { + "from": { + "name": "from", + "type": { + "scalarType": "int4" + }, + "nullable": "nullable" + }, + "to": { + "name": "to", + "type": { + "scalarType": "int4" + }, + "nullable": "nullable" + } + }, + "description": "A native query used to test support for arrays" + } + } + } +} diff --git a/crates/query-engine/translation/tests/goldenfiles/select_array_column/tables.json b/crates/query-engine/translation/tests/goldenfiles/select_array_column/tables.json deleted file mode 100644 index 800e6586c..000000000 --- a/crates/query-engine/translation/tests/goldenfiles/select_array_column/tables.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "nativeQueries": { - "array_series": { - "sql": "SELECT array_agg(arr.series) AS series FROM (SELECT generate_series({{from}},{{to}}) AS series) AS arr", - "columns": { - "series": { - "name": "series", - "type": { - "arrayType": { "scalarType": "int4" } - }, - "nullable": "nullable", - "description": null - } - }, - "arguments": { - "from": { - "name": "from", - "type": { - "scalarType": "int4" - }, - "nullable": "nullable" - }, - "to": { - "name": "to", - "type": { - "scalarType": "int4" - }, - "nullable": "nullable" - } - }, - "description": "A native query used to test support for arrays" - } - } -} diff --git a/crates/query-engine/translation/tests/goldenfiles/select_array_column_nested_types/configuration.json b/crates/query-engine/translation/tests/goldenfiles/select_array_column_nested_types/configuration.json new file mode 100644 index 000000000..e4dbc3afb --- /dev/null +++ b/crates/query-engine/translation/tests/goldenfiles/select_array_column_nested_types/configuration.json @@ -0,0 +1,89 @@ +{ + "version": "3", + "metadata": { + "nativeQueries": { + "summarize_organizations": { + "sql": "SELECT 'The organization ' || org.name || ' has ' || no_committees::text || ' committees, ' || 'the largest of which has ' || max_members || ' members.' AS result FROM (SELECT orgs.* FROM unnest({{organizations}}) as orgs) AS org JOIN LATERAL ( SELECT count(committee.*) AS no_committees, max(members_agg.no_members) AS max_members FROM unnest(org.committees) AS committee JOIN LATERAL ( SELECT count(*) as no_members FROM unnest(committee.members) AS members) AS members_agg ON true) AS coms ON true", + "columns": { + "result": { + "name": "result", + "type": { + "scalarType": "text" + }, + "nullable": "nullable", + "description": null + } + }, + "arguments": { + "organizations": { + "name": "organizations", + "type": { + "arrayType": { + "compositeType": "organization" + } + }, + "nullable": "nullable" + } + }, + "description": "A native query used to test support array-valued variables" + } + }, + "compositeTypes": { + "person_name": { + "name": "person_name", + "fields": { + "first_name": { + "name": "first_name", + "type": { + "scalarType": "text" + } + }, + "last_name": { + "name": "last_name", + "type": { + "scalarType": "text" + } + } + } + }, + "committee": { + "name": "committee", + "fields": { + "name": { + "name": "name", + "type": { + "scalarType": "text" + } + }, + "members": { + "name": "members", + "type": { + "arrayType": { + "scalarType": "text" + } + } + } + } + }, + "organization": { + "name": "organization", + "fields": { + "name": { + "name": "name", + "type": { + "scalarType": "text" + } + }, + "members": { + "name": "committees", + "type": { + "arrayType": { + "compositeType": "committee" + } + } + } + } + } + } + } +} diff --git a/crates/query-engine/translation/tests/goldenfiles/select_array_column_nested_types/tables.json b/crates/query-engine/translation/tests/goldenfiles/select_array_column_nested_types/tables.json deleted file mode 100644 index c79e8ba2e..000000000 --- a/crates/query-engine/translation/tests/goldenfiles/select_array_column_nested_types/tables.json +++ /dev/null @@ -1,86 +0,0 @@ -{ - "compositeTypes": { - "person_name": { - "name": "person_name", - "fields": { - "first_name": { - "name": "first_name", - "type": { - "scalarType": "text" - } - }, - "last_name": { - "name": "last_name", - "type": { - "scalarType": "text" - } - } - } - }, - "committee": { - "name": "committee", - "fields": { - "name": { - "name": "name", - "type": { - "scalarType": "text" - } - }, - "members": { - "name": "members", - "type": { - "arrayType": { - "scalarType": "text" - } - } - } - } - }, - "organization": { - "name": "organization", - "fields": { - "name": { - "name": "name", - "type": { - "scalarType": "text" - } - }, - "members": { - "name": "committees", - "type": { - "arrayType": { - "compositeType": "committee" - } - } - } - } - } - }, - "nativeQueries": { - "summarize_organizations": { - "sql": "SELECT 'The organization ' || org.name || ' has ' || no_committees::text || ' committees, ' || 'the largest of which has ' || max_members || ' members.' AS result FROM (SELECT orgs.* FROM unnest({{organizations}}) as orgs) AS org JOIN LATERAL ( SELECT count(committee.*) AS no_committees, max(members_agg.no_members) AS max_members FROM unnest(org.committees) AS committee JOIN LATERAL ( SELECT count(*) as no_members FROM unnest(committee.members) AS members) AS members_agg ON true) AS coms ON true", - "columns": { - "result": { - "name": "result", - "type": { - "scalarType": "text" - }, - "nullable": "nullable", - "description": null - } - }, - "arguments": { - "organizations": { - "name": "organizations", - "type": { - "arrayType": { - "compositeType": "organization" - } - }, - "nullable": "nullable" - } - }, - "description": "A native query used to test support array-valued variables" - } - } -} diff --git a/crates/query-engine/translation/tests/goldenfiles/select_array_column_reverse/configuration.json b/crates/query-engine/translation/tests/goldenfiles/select_array_column_reverse/configuration.json new file mode 100644 index 000000000..d48120d41 --- /dev/null +++ b/crates/query-engine/translation/tests/goldenfiles/select_array_column_reverse/configuration.json @@ -0,0 +1,35 @@ +{ + "version": "3", + "metadata": { + "nativeQueries": { + "array_reverse": { + "sql": "SELECT array_agg(x) as reversed FROM (SELECT x FROM unnest({{array}}) WITH ORDINALITY AS t(x,ix) ORDER BY t.ix DESC)", + "columns": { + "reversed": { + "name": "reversed", + "type": { + "arrayType": { + "scalarType": "varchar" + } + }, + "nullable": "nullable", + "description": "The reversed array" + } + }, + "arguments": { + "array": { + "name": "array", + "type": { + "arrayType": { + "scalarType": "varchar" + } + }, + "nullable": "nonNullable", + "description": "The array to reverse. This is necessarily of a monomorphic type." + } + }, + "description": "A native query used to test support for arrays as inputs" + } + } + } +} diff --git a/crates/query-engine/translation/tests/goldenfiles/select_array_column_reverse/tables.json b/crates/query-engine/translation/tests/goldenfiles/select_array_column_reverse/tables.json deleted file mode 100644 index e38cfa791..000000000 --- a/crates/query-engine/translation/tests/goldenfiles/select_array_column_reverse/tables.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "nativeQueries": { - "array_reverse": { - "sql": "SELECT array_agg(x) as reversed FROM (SELECT x FROM unnest({{array}}) WITH ORDINALITY AS t(x,ix) ORDER BY t.ix DESC)", - "columns": { - "reversed": { - "name": "reversed", - "type": { - "arrayType": { - "scalarType": "varchar" - } - }, - "nullable": "nullable", - "description": "The reversed array" - } - }, - "arguments": { - "array": { - "name": "array", - "type": { - "arrayType": { - "scalarType": "varchar" - } - }, - "nullable": "nonNullable", - "description": "The array to reverse. This is necessarily of a monomorphic type." - } - }, - "description": "A native query used to test support for arrays as inputs" - } - } -} diff --git a/crates/query-engine/translation/tests/goldenfiles/select_array_variable/configuration.json b/crates/query-engine/translation/tests/goldenfiles/select_array_variable/configuration.json new file mode 100644 index 000000000..060ecaa7e --- /dev/null +++ b/crates/query-engine/translation/tests/goldenfiles/select_array_variable/configuration.json @@ -0,0 +1,32 @@ +{ + "version": "3", + "metadata": { + "nativeQueries": { + "count_elements": { + "sql": "SELECT array_length({{array_argument}}, 1) as result", + "columns": { + "result": { + "name": "result", + "type": { + "scalarType": "int4" + }, + "nullable": "nullable", + "description": null + } + }, + "arguments": { + "array_argument": { + "name": "array_argument", + "type": { + "arrayType": { + "scalarType": "text" + } + }, + "nullable": "nullable" + } + }, + "description": "A native query used to test support array-valued variables" + } + } + } +} diff --git a/crates/query-engine/translation/tests/goldenfiles/select_array_variable/tables.json b/crates/query-engine/translation/tests/goldenfiles/select_array_variable/tables.json deleted file mode 100644 index be18f3610..000000000 --- a/crates/query-engine/translation/tests/goldenfiles/select_array_variable/tables.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "nativeQueries": { - "count_elements": { - "sql": "SELECT array_length({{array_argument}}, 1) as result", - "columns": { - "result": { - "name": "result", - "type": { - "scalarType": "int4" - }, - "nullable": "nullable", - "description": null - } - }, - "arguments": { - "array_argument": { - "name": "array_argument", - "type": { - "arrayType": { "scalarType": "text" } - }, - "nullable": "nullable" - } - }, - "description": "A native query used to test support array-valued variables" - } - } -} diff --git a/crates/query-engine/translation/tests/goldenfiles/select_array_variable_nested_types/configuration.json b/crates/query-engine/translation/tests/goldenfiles/select_array_variable_nested_types/configuration.json new file mode 100644 index 000000000..66ff22a60 --- /dev/null +++ b/crates/query-engine/translation/tests/goldenfiles/select_array_variable_nested_types/configuration.json @@ -0,0 +1,89 @@ +{ + "version": "3", + "metadata": { + "nativeQueries": { + "summarize_organizations": { + "sql": "SELECT 'The organization ' || org.name || ' has ' || no_committees::text || ' committees, ' || 'the largest of which has ' || max_members || ' members.' AS result FROM (SELECT orgs.* FROM unnest({{organizations}}) AS orgs) AS org JOIN LATERAL ( SELECT count(committee.*) AS no_committees, max(members_agg.no_members) AS max_members FROM unnest(org.committees) AS committee JOIN LATERAL ( SELECT count(*) as no_members FROM unnest(committee.members) AS members) AS members_agg ON true) AS coms ON true", + "columns": { + "result": { + "name": "result", + "type": { + "scalarType": "text" + }, + "nullable": "nullable", + "description": null + } + }, + "arguments": { + "organizations": { + "name": "organizations", + "type": { + "arrayType": { + "compositeType": "organization" + } + }, + "nullable": "nullable" + } + }, + "description": "A native query used to test support array-valued variables" + } + }, + "compositeTypes": { + "person_name": { + "name": "person_name", + "fields": { + "first_name": { + "name": "first_name", + "type": { + "scalarType": "text" + } + }, + "last_name": { + "name": "last_name", + "type": { + "scalarType": "text" + } + } + } + }, + "committee": { + "name": "committee", + "fields": { + "name": { + "name": "name", + "type": { + "scalarType": "text" + } + }, + "members": { + "name": "members", + "type": { + "arrayType": { + "scalarType": "text" + } + } + } + } + }, + "organization": { + "name": "organization", + "fields": { + "name": { + "name": "name", + "type": { + "scalarType": "text" + } + }, + "members": { + "name": "committees", + "type": { + "arrayType": { + "compositeType": "committee" + } + } + } + } + } + } + } +} diff --git a/crates/query-engine/translation/tests/goldenfiles/select_array_variable_nested_types/tables.json b/crates/query-engine/translation/tests/goldenfiles/select_array_variable_nested_types/tables.json deleted file mode 100644 index 98a3479d8..000000000 --- a/crates/query-engine/translation/tests/goldenfiles/select_array_variable_nested_types/tables.json +++ /dev/null @@ -1,86 +0,0 @@ -{ - "compositeTypes": { - "person_name": { - "name": "person_name", - "fields": { - "first_name": { - "name": "first_name", - "type": { - "scalarType": "text" - } - }, - "last_name": { - "name": "last_name", - "type": { - "scalarType": "text" - } - } - } - }, - "committee": { - "name": "committee", - "fields": { - "name": { - "name": "name", - "type": { - "scalarType": "text" - } - }, - "members": { - "name": "members", - "type": { - "arrayType": { - "scalarType": "text" - } - } - } - } - }, - "organization": { - "name": "organization", - "fields": { - "name": { - "name": "name", - "type": { - "scalarType": "text" - } - }, - "members": { - "name": "committees", - "type": { - "arrayType": { - "compositeType": "committee" - } - } - } - } - } - }, - "nativeQueries": { - "summarize_organizations": { - "sql": "SELECT 'The organization ' || org.name || ' has ' || no_committees::text || ' committees, ' || 'the largest of which has ' || max_members || ' members.' AS result FROM (SELECT orgs.* FROM unnest({{organizations}}) AS orgs) AS org JOIN LATERAL ( SELECT count(committee.*) AS no_committees, max(members_agg.no_members) AS max_members FROM unnest(org.committees) AS committee JOIN LATERAL ( SELECT count(*) as no_members FROM unnest(committee.members) AS members) AS members_agg ON true) AS coms ON true", - "columns": { - "result": { - "name": "result", - "type": { - "scalarType": "text" - }, - "nullable": "nullable", - "description": null - } - }, - "arguments": { - "organizations": { - "name": "organizations", - "type": { - "arrayType": { - "compositeType": "organization" - } - }, - "nullable": "nullable" - } - }, - "description": "A native query used to test support array-valued variables" - } - } -} diff --git a/crates/query-engine/translation/tests/goldenfiles/select_composite_column_complex/configuration.json b/crates/query-engine/translation/tests/goldenfiles/select_composite_column_complex/configuration.json new file mode 100644 index 000000000..26a6b1ebc --- /dev/null +++ b/crates/query-engine/translation/tests/goldenfiles/select_composite_column_complex/configuration.json @@ -0,0 +1,90 @@ +{ + "version": "3", + "metadata": { + "nativeQueries": { + "make_person": { + "sql": "SELECT ROW({{name}}, {{address}})::person as result", + "columns": { + "result": { + "name": "result", + "type": { + "compositeType": "person" + }, + "nullable": "nullable", + "description": null + } + }, + "arguments": { + "name": { + "name": "name", + "type": { + "compositeType": "person_name" + }, + "nullable": "nullable" + }, + "address": { + "name": "address", + "type": { + "compositeType": "person_address" + }, + "nullable": "nullable" + } + }, + "description": "A native query used to test support for composite types" + } + }, + "compositeTypes": { + "person": { + "name": "person", + "fields": { + "name": { + "name": "name", + "type": { + "compositeType": "person_name" + } + }, + "address": { + "name": "address", + "type": { + "compositeType": "person_address" + } + } + } + }, + "person_name": { + "name": "person_name", + "fields": { + "first_name": { + "name": "first_name", + "type": { + "scalarType": "text" + } + }, + "last_name": { + "name": "last_name", + "type": { + "scalarType": "text" + } + } + } + }, + "person_address": { + "name": "person_address", + "fields": { + "address_line_1": { + "name": "address_line_1", + "type": { + "scalarType": "text" + } + }, + "address_line_2": { + "name": "address_line_2", + "type": { + "scalarType": "text" + } + } + } + } + } + } +} diff --git a/crates/query-engine/translation/tests/goldenfiles/select_composite_column_complex/tables.json b/crates/query-engine/translation/tests/goldenfiles/select_composite_column_complex/tables.json deleted file mode 100644 index f850bd854..000000000 --- a/crates/query-engine/translation/tests/goldenfiles/select_composite_column_complex/tables.json +++ /dev/null @@ -1,87 +0,0 @@ -{ - "compositeTypes": { - "person": { - "name": "person", - "fields": { - "name": { - "name": "name", - "type": { - "compositeType": "person_name" - } - }, - "address": { - "name": "address", - "type": { - "compositeType": "person_address" - } - } - } - }, - "person_name": { - "name": "person_name", - "fields": { - "first_name": { - "name": "first_name", - "type": { - "scalarType": "text" - } - }, - "last_name": { - "name": "last_name", - "type": { - "scalarType": "text" - } - } - } - }, - "person_address": { - "name": "person_address", - "fields": { - "address_line_1": { - "name": "address_line_1", - "type": { - "scalarType": "text" - } - }, - "address_line_2": { - "name": "address_line_2", - "type": { - "scalarType": "text" - } - } - } - } - }, - "nativeQueries": { - "make_person": { - "sql": "SELECT ROW({{name}}, {{address}})::person as result", - "columns": { - "result": { - "name": "result", - "type": { - "compositeType": "person" - }, - "nullable": "nullable", - "description": null - } - }, - "arguments": { - "name": { - "name": "name", - "type": { - "compositeType": "person_name" - }, - "nullable": "nullable" - }, - "address": { - "name": "address", - "type": { - "compositeType": "person_address" - }, - "nullable": "nullable" - } - }, - "description": "A native query used to test support for composite types" - } - } -} diff --git a/crates/query-engine/translation/tests/goldenfiles/select_composite_column_simple/configuration.json b/crates/query-engine/translation/tests/goldenfiles/select_composite_column_simple/configuration.json new file mode 100644 index 000000000..d4dc7dfdf --- /dev/null +++ b/crates/query-engine/translation/tests/goldenfiles/select_composite_column_simple/configuration.json @@ -0,0 +1,50 @@ +{ + "version": "3", + "metadata": { + "nativeQueries": { + "address_identity_function": { + "sql": "SELECT {{address}} as result", + "columns": { + "result": { + "name": "result", + "type": { + "compositeType": "person_address" + }, + "nullable": "nullable", + "description": null + } + }, + "arguments": { + "address": { + "name": "address", + "type": { + "compositeType": "person_address" + }, + "nullable": "nullable", + "description": null + } + }, + "description": "A native query used to test support for composite types" + } + }, + "compositeTypes": { + "person_address": { + "name": "person_address", + "fields": { + "address_line_1": { + "name": "address_line_1", + "type": { + "scalarType": "text" + } + }, + "address_line_2": { + "name": "address_line_2", + "type": { + "scalarType": "text" + } + } + } + } + } + } +} diff --git a/crates/query-engine/translation/tests/goldenfiles/select_composite_column_simple/tables.json b/crates/query-engine/translation/tests/goldenfiles/select_composite_column_simple/tables.json deleted file mode 100644 index 75969cc11..000000000 --- a/crates/query-engine/translation/tests/goldenfiles/select_composite_column_simple/tables.json +++ /dev/null @@ -1,47 +0,0 @@ -{ - "compositeTypes": { - "person_address": { - "name": "person_address", - "fields": { - "address_line_1": { - "name": "address_line_1", - "type": { - "scalarType": "text" - } - }, - "address_line_2": { - "name": "address_line_2", - "type": { - "scalarType": "text" - } - } - } - } - }, - "nativeQueries": { - "address_identity_function": { - "sql": "SELECT {{address}} as result", - "columns": { - "result": { - "name": "result", - "type": { - "compositeType": "person_address" - }, - "nullable": "nullable", - "description": null - } - }, - "arguments": { - "address": { - "name": "address", - "type": { - "compositeType": "person_address" - }, - "nullable": "nullable", - "description": null - } - }, - "description": "A native query used to test support for composite types" - } - } -} diff --git a/crates/query-engine/translation/tests/goldenfiles/select_composite_variable_complex/configuration.json b/crates/query-engine/translation/tests/goldenfiles/select_composite_variable_complex/configuration.json new file mode 100644 index 000000000..26a6b1ebc --- /dev/null +++ b/crates/query-engine/translation/tests/goldenfiles/select_composite_variable_complex/configuration.json @@ -0,0 +1,90 @@ +{ + "version": "3", + "metadata": { + "nativeQueries": { + "make_person": { + "sql": "SELECT ROW({{name}}, {{address}})::person as result", + "columns": { + "result": { + "name": "result", + "type": { + "compositeType": "person" + }, + "nullable": "nullable", + "description": null + } + }, + "arguments": { + "name": { + "name": "name", + "type": { + "compositeType": "person_name" + }, + "nullable": "nullable" + }, + "address": { + "name": "address", + "type": { + "compositeType": "person_address" + }, + "nullable": "nullable" + } + }, + "description": "A native query used to test support for composite types" + } + }, + "compositeTypes": { + "person": { + "name": "person", + "fields": { + "name": { + "name": "name", + "type": { + "compositeType": "person_name" + } + }, + "address": { + "name": "address", + "type": { + "compositeType": "person_address" + } + } + } + }, + "person_name": { + "name": "person_name", + "fields": { + "first_name": { + "name": "first_name", + "type": { + "scalarType": "text" + } + }, + "last_name": { + "name": "last_name", + "type": { + "scalarType": "text" + } + } + } + }, + "person_address": { + "name": "person_address", + "fields": { + "address_line_1": { + "name": "address_line_1", + "type": { + "scalarType": "text" + } + }, + "address_line_2": { + "name": "address_line_2", + "type": { + "scalarType": "text" + } + } + } + } + } + } +} diff --git a/crates/query-engine/translation/tests/goldenfiles/select_composite_variable_complex/tables.json b/crates/query-engine/translation/tests/goldenfiles/select_composite_variable_complex/tables.json deleted file mode 100644 index f850bd854..000000000 --- a/crates/query-engine/translation/tests/goldenfiles/select_composite_variable_complex/tables.json +++ /dev/null @@ -1,87 +0,0 @@ -{ - "compositeTypes": { - "person": { - "name": "person", - "fields": { - "name": { - "name": "name", - "type": { - "compositeType": "person_name" - } - }, - "address": { - "name": "address", - "type": { - "compositeType": "person_address" - } - } - } - }, - "person_name": { - "name": "person_name", - "fields": { - "first_name": { - "name": "first_name", - "type": { - "scalarType": "text" - } - }, - "last_name": { - "name": "last_name", - "type": { - "scalarType": "text" - } - } - } - }, - "person_address": { - "name": "person_address", - "fields": { - "address_line_1": { - "name": "address_line_1", - "type": { - "scalarType": "text" - } - }, - "address_line_2": { - "name": "address_line_2", - "type": { - "scalarType": "text" - } - } - } - } - }, - "nativeQueries": { - "make_person": { - "sql": "SELECT ROW({{name}}, {{address}})::person as result", - "columns": { - "result": { - "name": "result", - "type": { - "compositeType": "person" - }, - "nullable": "nullable", - "description": null - } - }, - "arguments": { - "name": { - "name": "name", - "type": { - "compositeType": "person_name" - }, - "nullable": "nullable" - }, - "address": { - "name": "address", - "type": { - "compositeType": "person_address" - }, - "nullable": "nullable" - } - }, - "description": "A native query used to test support for composite types" - } - } -} diff --git a/crates/query-engine/translation/tests/goldenfiles/select_composite_variable_simple/configuration.json b/crates/query-engine/translation/tests/goldenfiles/select_composite_variable_simple/configuration.json new file mode 100644 index 000000000..d4dc7dfdf --- /dev/null +++ b/crates/query-engine/translation/tests/goldenfiles/select_composite_variable_simple/configuration.json @@ -0,0 +1,50 @@ +{ + "version": "3", + "metadata": { + "nativeQueries": { + "address_identity_function": { + "sql": "SELECT {{address}} as result", + "columns": { + "result": { + "name": "result", + "type": { + "compositeType": "person_address" + }, + "nullable": "nullable", + "description": null + } + }, + "arguments": { + "address": { + "name": "address", + "type": { + "compositeType": "person_address" + }, + "nullable": "nullable", + "description": null + } + }, + "description": "A native query used to test support for composite types" + } + }, + "compositeTypes": { + "person_address": { + "name": "person_address", + "fields": { + "address_line_1": { + "name": "address_line_1", + "type": { + "scalarType": "text" + } + }, + "address_line_2": { + "name": "address_line_2", + "type": { + "scalarType": "text" + } + } + } + } + } + } +} diff --git a/crates/query-engine/translation/tests/goldenfiles/select_composite_variable_simple/tables.json b/crates/query-engine/translation/tests/goldenfiles/select_composite_variable_simple/tables.json deleted file mode 100644 index 75969cc11..000000000 --- a/crates/query-engine/translation/tests/goldenfiles/select_composite_variable_simple/tables.json +++ /dev/null @@ -1,47 +0,0 @@ -{ - "compositeTypes": { - "person_address": { - "name": "person_address", - "fields": { - "address_line_1": { - "name": "address_line_1", - "type": { - "scalarType": "text" - } - }, - "address_line_2": { - "name": "address_line_2", - "type": { - "scalarType": "text" - } - } - } - } - }, - "nativeQueries": { - "address_identity_function": { - "sql": "SELECT {{address}} as result", - "columns": { - "result": { - "name": "result", - "type": { - "compositeType": "person_address" - }, - "nullable": "nullable", - "description": null - } - }, - "arguments": { - "address": { - "name": "address", - "type": { - "compositeType": "person_address" - }, - "nullable": "nullable", - "description": null - } - }, - "description": "A native query used to test support for composite types" - } - } -} diff --git a/crates/query-engine/translation/tests/goldenfiles/select_nested_column_complex/configuration.json b/crates/query-engine/translation/tests/goldenfiles/select_nested_column_complex/configuration.json new file mode 100644 index 000000000..a4bf7a669 --- /dev/null +++ b/crates/query-engine/translation/tests/goldenfiles/select_nested_column_complex/configuration.json @@ -0,0 +1,99 @@ +{ + "version": "3", + "metadata": { + "nativeQueries": { + "organization_identity_function": { + "sql": { + "inline": "SELECT {{organization}} as result_the_column" + }, + "columns": { + "result_the_field": { + "name": "result_the_column", + "type": { + "compositeType": "organization" + }, + "nullable": "nullable", + "description": null + } + }, + "arguments": { + "organization": { + "name": "organization", + "type": { + "compositeType": "organization" + }, + "nullable": "nullable", + "description": null + } + }, + "description": "A native query used to test support for composite types" + } + }, + "compositeTypes": { + "committee": { + "name": "committee", + "fields": { + "members": { + "name": "members", + "type": { + "arrayType": { + "compositeType": "person_name" + } + }, + "description": null + }, + "name": { + "name": "name", + "type": { + "scalarType": "text" + }, + "description": null + } + }, + "description": null + }, + "organization": { + "name": "organization", + "fields": { + "committees": { + "name": "committees", + "type": { + "arrayType": { + "compositeType": "committee" + } + }, + "description": null + }, + "name": { + "name": "name", + "type": { + "scalarType": "text" + }, + "description": null + } + }, + "description": null + }, + "person_name": { + "name": "person_name", + "fields": { + "first_name": { + "name": "first_name", + "type": { + "scalarType": "text" + }, + "description": "The first name of a person" + }, + "last_name": { + "name": "last_name", + "type": { + "scalarType": "text" + }, + "description": "The last name of a person" + } + }, + "description": "The name of a person, obviously" + } + } + } +} diff --git a/crates/query-engine/translation/tests/goldenfiles/select_nested_column_complex/tables.json b/crates/query-engine/translation/tests/goldenfiles/select_nested_column_complex/tables.json deleted file mode 100644 index 8f95888f8..000000000 --- a/crates/query-engine/translation/tests/goldenfiles/select_nested_column_complex/tables.json +++ /dev/null @@ -1,96 +0,0 @@ -{ - "compositeTypes": { - "committee": { - "name": "committee", - "fields": { - "members": { - "name": "members", - "type": { - "arrayType": { - "compositeType": "person_name" - } - }, - "description": null - }, - "name": { - "name": "name", - "type": { - "scalarType": "text" - }, - "description": null - } - }, - "description": null - }, - "organization": { - "name": "organization", - "fields": { - "committees": { - "name": "committees", - "type": { - "arrayType": { - "compositeType": "committee" - } - }, - "description": null - }, - "name": { - "name": "name", - "type": { - "scalarType": "text" - }, - "description": null - } - }, - "description": null - }, - "person_name": { - "name": "person_name", - "fields": { - "first_name": { - "name": "first_name", - "type": { - "scalarType": "text" - }, - "description": "The first name of a person" - }, - "last_name": { - "name": "last_name", - "type": { - "scalarType": "text" - }, - "description": "The last name of a person" - } - }, - "description": "The name of a person, obviously" - } - }, - "nativeQueries": { - "organization_identity_function": { - "sql": { - "inline": "SELECT {{organization}} as result_the_column" - }, - "columns": { - "result_the_field": { - "name": "result_the_column", - "type": { - "compositeType": "organization" - }, - "nullable": "nullable", - "description": null - } - }, - "arguments": { - "organization": { - "name": "organization", - "type": { - "compositeType": "organization" - }, - "nullable": "nullable", - "description": null - } - }, - "description": "A native query used to test support for composite types" - } - } -} diff --git a/crates/query-engine/translation/tests/goldenfiles/select_nested_column_simple/configuration.json b/crates/query-engine/translation/tests/goldenfiles/select_nested_column_simple/configuration.json new file mode 100644 index 000000000..d4dc7dfdf --- /dev/null +++ b/crates/query-engine/translation/tests/goldenfiles/select_nested_column_simple/configuration.json @@ -0,0 +1,50 @@ +{ + "version": "3", + "metadata": { + "nativeQueries": { + "address_identity_function": { + "sql": "SELECT {{address}} as result", + "columns": { + "result": { + "name": "result", + "type": { + "compositeType": "person_address" + }, + "nullable": "nullable", + "description": null + } + }, + "arguments": { + "address": { + "name": "address", + "type": { + "compositeType": "person_address" + }, + "nullable": "nullable", + "description": null + } + }, + "description": "A native query used to test support for composite types" + } + }, + "compositeTypes": { + "person_address": { + "name": "person_address", + "fields": { + "address_line_1": { + "name": "address_line_1", + "type": { + "scalarType": "text" + } + }, + "address_line_2": { + "name": "address_line_2", + "type": { + "scalarType": "text" + } + } + } + } + } + } +} diff --git a/crates/query-engine/translation/tests/goldenfiles/select_nested_column_simple/tables.json b/crates/query-engine/translation/tests/goldenfiles/select_nested_column_simple/tables.json deleted file mode 100644 index 75969cc11..000000000 --- a/crates/query-engine/translation/tests/goldenfiles/select_nested_column_simple/tables.json +++ /dev/null @@ -1,47 +0,0 @@ -{ - "compositeTypes": { - "person_address": { - "name": "person_address", - "fields": { - "address_line_1": { - "name": "address_line_1", - "type": { - "scalarType": "text" - } - }, - "address_line_2": { - "name": "address_line_2", - "type": { - "scalarType": "text" - } - } - } - } - }, - "nativeQueries": { - "address_identity_function": { - "sql": "SELECT {{address}} as result", - "columns": { - "result": { - "name": "result", - "type": { - "compositeType": "person_address" - }, - "nullable": "nullable", - "description": null - } - }, - "arguments": { - "address": { - "name": "address", - "type": { - "compositeType": "person_address" - }, - "nullable": "nullable", - "description": null - } - }, - "description": "A native query used to test support for composite types" - } - } -} diff --git a/crates/query-engine/translation/tests/goldenfiles/select_track_order_by_artist_id_and_album_title/configuration.json b/crates/query-engine/translation/tests/goldenfiles/select_track_order_by_artist_id_and_album_title/configuration.json new file mode 100644 index 000000000..3c20fa37d --- /dev/null +++ b/crates/query-engine/translation/tests/goldenfiles/select_track_order_by_artist_id_and_album_title/configuration.json @@ -0,0 +1,73 @@ +{ + "version": "3", + "metadata": { + "tables": { + "Album": { + "schemaName": "public", + "tableName": "Album", + "columns": { + "AlbumId": { + "name": "AlbumId", + "type": { + "scalarType": "int4" + } + }, + "Title": { + "name": "Title", + "type": { + "scalarType": "varchar" + } + }, + "ArtistId": { + "name": "ArtistId", + "type": { + "scalarType": "int4" + } + } + } + }, + "Artist": { + "schemaName": "public", + "tableName": "Artist", + "columns": { + "ArtistId": { + "name": "ArtistId", + "type": { + "scalarType": "int4" + } + }, + "Name": { + "name": "Name", + "type": { + "scalarType": "varchar" + } + } + } + }, + "Track": { + "schemaName": "public", + "tableName": "Track", + "columns": { + "TrackId": { + "name": "TrackId", + "type": { + "scalarType": "int4" + } + }, + "Name": { + "name": "Name", + "type": { + "scalarType": "varchar" + } + }, + "AlbumId": { + "name": "AlbumId", + "type": { + "scalarType": "int4" + } + } + } + } + } + } +} diff --git a/crates/query-engine/translation/tests/goldenfiles/select_track_order_by_artist_id_and_album_title/tables.json b/crates/query-engine/translation/tests/goldenfiles/select_track_order_by_artist_id_and_album_title/tables.json deleted file mode 100644 index 17d9782e2..000000000 --- a/crates/query-engine/translation/tests/goldenfiles/select_track_order_by_artist_id_and_album_title/tables.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "tables": { - "Album": { - "schemaName": "public", - "tableName": "Album", - "columns": { - "AlbumId": { - "name": "AlbumId", - "type": { - "scalarType": "int4" - } - }, - "Title": { - "name": "Title", - "type": { - "scalarType": "varchar" - } - }, - "ArtistId": { - "name": "ArtistId", - "type": { - "scalarType": "int4" - } - } - } - }, - "Artist": { - "schemaName": "public", - "tableName": "Artist", - "columns": { - "ArtistId": { - "name": "ArtistId", - "type": { - "scalarType": "int4" - } - }, - "Name": { - "name": "Name", - "type": { - "scalarType": "varchar" - } - } - } - }, - "Track": { - "schemaName": "public", - "tableName": "Track", - "columns": { - "TrackId": { - "name": "TrackId", - "type": { - "scalarType": "int4" - } - }, - "Name": { - "name": "Name", - "type": { - "scalarType": "varchar" - } - }, - "AlbumId": { - "name": "AlbumId", - "type": { - "scalarType": "int4" - } - } - } - } - } -} diff --git a/crates/query-engine/translation/tests/goldenfiles/select_where_album_id_equals_self_nested_object_relationship/configuration.json b/crates/query-engine/translation/tests/goldenfiles/select_where_album_id_equals_self_nested_object_relationship/configuration.json new file mode 100644 index 000000000..5595c73ac --- /dev/null +++ b/crates/query-engine/translation/tests/goldenfiles/select_where_album_id_equals_self_nested_object_relationship/configuration.json @@ -0,0 +1,151 @@ +{ + "version": "3", + "metadata": { + "tables": { + "Album": { + "schemaName": "public", + "tableName": "Album", + "columns": { + "AlbumId": { + "name": "AlbumId", + "type": { + "scalarType": "int4" + } + }, + "ArtistId": { + "name": "ArtistId", + "type": { + "scalarType": "int4" + } + }, + "Title": { + "name": "Title", + "type": { + "scalarType": "varchar" + } + } + }, + "uniquenessConstraints": { + "PK_Album": ["AlbumId"] + }, + "foreignRelations": { + "FK_AlbumArtistId": { + "foreignTable": "Album", + "columnMapping": { + "ArtistId": "ArtistId" + } + } + } + }, + "Artist": { + "schemaName": "public", + "tableName": "Artist", + "columns": { + "ArtistId": { + "name": "ArtistId", + "type": { + "scalarType": "int4" + } + }, + "Name": { + "name": "Name", + "type": { + "scalarType": "varchar" + } + } + }, + "uniquenessConstraints": { + "PK_Artist": ["ArtistId"] + }, + "foreignRelations": {} + }, + "Track": { + "schemaName": "public", + "tableName": "Track", + "columns": { + "AlbumId": { + "name": "AlbumId", + "type": { + "scalarType": "varchar" + } + }, + "Bytes": { + "name": "Bytes", + "type": { + "scalarType": "varchar" + } + }, + "Composer": { + "name": "Composer", + "type": { + "scalarType": "varchar" + } + }, + "GenreId": { + "name": "GenreId", + "type": { + "scalarType": "int4" + } + }, + "MediaTypeId": { + "name": "MediaTypeId", + "type": { + "scalarType": "int4" + } + }, + "Milliseconds": { + "name": "Milliseconds", + "type": { + "scalarType": "int4" + } + }, + "Name": { + "name": "Name", + "type": { + "scalarType": "varchar" + } + }, + "TrackId": { + "name": "TrackId", + "type": { + "scalarType": "int4" + } + }, + "UnitPrice": { + "name": "UnitPrice", + "type": { + "scalarType": "float4" + } + } + }, + "uniquenessConstraints": { + "PK_Track": ["TrackId"] + }, + "foreignRelations": { + "FK_TrackAlbumId": { + "foreignTable": "Track", + "columnMapping": { + "AlbumId": "AlbumId" + } + } + } + } + }, + "comparisonOperators": { + "int4": { + "_gt": { + "operatorName": ">", + "argumentType": "int4", + "operatorKind": "custom" + } + }, + "varchar": { + "_eq": { + "operatorName": "=", + "argumentType": "varchar", + "operatorKind": "equal" + } + } + } + } +} diff --git a/crates/query-engine/translation/tests/goldenfiles/select_where_album_id_equals_self_nested_object_relationship/tables.json b/crates/query-engine/translation/tests/goldenfiles/select_where_album_id_equals_self_nested_object_relationship/tables.json deleted file mode 100644 index 315bfe4a2..000000000 --- a/crates/query-engine/translation/tests/goldenfiles/select_where_album_id_equals_self_nested_object_relationship/tables.json +++ /dev/null @@ -1,148 +0,0 @@ -{ - "tables": { - "Album": { - "schemaName": "public", - "tableName": "Album", - "columns": { - "AlbumId": { - "name": "AlbumId", - "type": { - "scalarType": "int4" - } - }, - "ArtistId": { - "name": "ArtistId", - "type": { - "scalarType": "int4" - } - }, - "Title": { - "name": "Title", - "type": { - "scalarType": "varchar" - } - } - }, - "uniquenessConstraints": { - "PK_Album": ["AlbumId"] - }, - "foreignRelations": { - "FK_AlbumArtistId": { - "foreignTable": "Album", - "columnMapping": { - "ArtistId": "ArtistId" - } - } - } - }, - "Artist": { - "schemaName": "public", - "tableName": "Artist", - "columns": { - "ArtistId": { - "name": "ArtistId", - "type": { - "scalarType": "int4" - } - }, - "Name": { - "name": "Name", - "type": { - "scalarType": "varchar" - } - } - }, - "uniquenessConstraints": { - "PK_Artist": ["ArtistId"] - }, - "foreignRelations": {} - }, - "Track": { - "schemaName": "public", - "tableName": "Track", - "columns": { - "AlbumId": { - "name": "AlbumId", - "type": { - "scalarType": "varchar" - } - }, - "Bytes": { - "name": "Bytes", - "type": { - "scalarType": "varchar" - } - }, - "Composer": { - "name": "Composer", - "type": { - "scalarType": "varchar" - } - }, - "GenreId": { - "name": "GenreId", - "type": { - "scalarType": "int4" - } - }, - "MediaTypeId": { - "name": "MediaTypeId", - "type": { - "scalarType": "int4" - } - }, - "Milliseconds": { - "name": "Milliseconds", - "type": { - "scalarType": "int4" - } - }, - "Name": { - "name": "Name", - "type": { - "scalarType": "varchar" - } - }, - "TrackId": { - "name": "TrackId", - "type": { - "scalarType": "int4" - } - }, - "UnitPrice": { - "name": "UnitPrice", - "type": { - "scalarType": "float4" - } - } - }, - "uniquenessConstraints": { - "PK_Track": ["TrackId"] - }, - "foreignRelations": { - "FK_TrackAlbumId": { - "foreignTable": "Track", - "columnMapping": { - "AlbumId": "AlbumId" - } - } - } - } - }, - "comparisonOperators": { - "int4": { - "_gt": { - "operatorName": ">", - "argumentType": "int4", - "operatorKind": "custom" - } - }, - "varchar": { - "_eq": { - "operatorName": "=", - "argumentType": "varchar", - "operatorKind": "equal" - } - } - } -} diff --git a/crates/query-engine/translation/tests/goldenfiles/select_where_array_relationship/configuration.json b/crates/query-engine/translation/tests/goldenfiles/select_where_array_relationship/configuration.json new file mode 100644 index 000000000..4926ff84d --- /dev/null +++ b/crates/query-engine/translation/tests/goldenfiles/select_where_array_relationship/configuration.json @@ -0,0 +1,58 @@ +{ + "version": "3", + "metadata": { + "tables": { + "Album": { + "schemaName": "public", + "tableName": "Album", + "columns": { + "AlbumId": { + "name": "AlbumId", + "type": { + "scalarType": "int4" + } + }, + "ArtistId": { + "name": "ArtistId", + "type": { + "scalarType": "int4" + } + }, + "Title": { + "name": "Title", + "type": { + "scalarType": "varchar" + } + } + } + }, + "Artist": { + "schemaName": "public", + "tableName": "Artist", + "columns": { + "ArtistId": { + "name": "ArtistId", + "type": { + "scalarType": "int4" + } + }, + "Name": { + "name": "Name", + "type": { + "scalarType": "varchar" + } + } + } + } + }, + "comparisonOperators": { + "varchar": { + "_like": { + "operatorName": "LIKE", + "argumentType": "varchar", + "operatorKind": "custom" + } + } + } + } +} diff --git a/crates/query-engine/translation/tests/goldenfiles/select_where_array_relationship/tables.json b/crates/query-engine/translation/tests/goldenfiles/select_where_array_relationship/tables.json deleted file mode 100644 index 6bdfd7b15..000000000 --- a/crates/query-engine/translation/tests/goldenfiles/select_where_array_relationship/tables.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "tables": { - "Album": { - "schemaName": "public", - "tableName": "Album", - "columns": { - "AlbumId": { - "name": "AlbumId", - "type": { - "scalarType": "int4" - } - }, - "ArtistId": { - "name": "ArtistId", - "type": { - "scalarType": "int4" - } - }, - "Title": { - "name": "Title", - "type": { - "scalarType": "varchar" - } - } - } - }, - "Artist": { - "schemaName": "public", - "tableName": "Artist", - "columns": { - "ArtistId": { - "name": "ArtistId", - "type": { - "scalarType": "int4" - } - }, - "Name": { - "name": "Name", - "type": { - "scalarType": "varchar" - } - } - } - } - }, - "comparisonOperators": { - "varchar": { - "_like": { - "operatorName": "LIKE", - "argumentType": "varchar", - "operatorKind": "custom" - } - } - } -} diff --git a/crates/query-engine/translation/tests/goldenfiles/select_where_in_variable/configuration.json b/crates/query-engine/translation/tests/goldenfiles/select_where_in_variable/configuration.json new file mode 100644 index 000000000..444df2d11 --- /dev/null +++ b/crates/query-engine/translation/tests/goldenfiles/select_where_in_variable/configuration.json @@ -0,0 +1,58 @@ +{ + "version": "3", + "metadata": { + "nativeQueries": { + "array_series": { + "sql": "SELECT 3 as three, array_agg(arr.series) AS series FROM (SELECT generate_series({{from}},{{to}}) AS series) AS arr", + "columns": { + "three": { + "name": "three", + "type": { + "scalarType": "int4" + }, + "nullable": "nullable", + "description": null + }, + "series": { + "name": "series", + "type": { + "arrayType": { + "scalarType": "int4" + } + }, + "nullable": "nullable", + "description": null + } + }, + "arguments": { + "from": { + "name": "from", + "type": { + "scalarType": "int4" + }, + "nullable": "nullable", + "description": null + }, + "to": { + "name": "to", + "type": { + "scalarType": "int4" + }, + "nullable": "nullable", + "description": null + } + }, + "description": "A native query used to test support for arrays" + } + }, + "comparisonOperators": { + "int4": { + "_in": { + "operatorName": "IN", + "argumentType": "int4", + "operatorKind": "in" + } + } + } + } +} diff --git a/crates/query-engine/translation/tests/goldenfiles/select_where_in_variable/tables.json b/crates/query-engine/translation/tests/goldenfiles/select_where_in_variable/tables.json deleted file mode 100644 index a8faba64a..000000000 --- a/crates/query-engine/translation/tests/goldenfiles/select_where_in_variable/tables.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "nativeQueries": { - "array_series": { - "sql": "SELECT 3 as three, array_agg(arr.series) AS series FROM (SELECT generate_series({{from}},{{to}}) AS series) AS arr", - "columns": { - "three": { - "name": "three", - "type": { - "scalarType": "int4" - }, - "nullable": "nullable", - "description": null - }, - "series": { - "name": "series", - "type": { - "arrayType": { - "scalarType": "int4" - } - }, - "nullable": "nullable", - "description": null - } - }, - "arguments": { - "from": { - "name": "from", - "type": { - "scalarType": "int4" - }, - "nullable": "nullable", - "description": null - }, - "to": { - "name": "to", - "type": { - "scalarType": "int4" - }, - "nullable": "nullable", - "description": null - } - }, - "description": "A native query used to test support for arrays" - } - }, - "comparisonOperators": { - "int4": { - "_in": { - "operatorName": "IN", - "argumentType": "int4", - "operatorKind": "in" - } - } - } -} diff --git a/crates/query-engine/translation/tests/goldenfiles/select_where_not_null/configuration.json b/crates/query-engine/translation/tests/goldenfiles/select_where_not_null/configuration.json new file mode 100644 index 000000000..dc9f39a50 --- /dev/null +++ b/crates/query-engine/translation/tests/goldenfiles/select_where_not_null/configuration.json @@ -0,0 +1,25 @@ +{ + "version": "3", + "metadata": { + "tables": { + "Album": { + "schemaName": "public", + "tableName": "Album", + "columns": { + "Id": { + "name": "AlbumId", + "type": { + "scalarType": "int4" + } + }, + "Title": { + "name": "Title", + "type": { + "scalarType": "varchar" + } + } + } + } + } + } +} diff --git a/crates/query-engine/translation/tests/goldenfiles/select_where_not_null/tables.json b/crates/query-engine/translation/tests/goldenfiles/select_where_not_null/tables.json deleted file mode 100644 index 1ea8d5a64..000000000 --- a/crates/query-engine/translation/tests/goldenfiles/select_where_not_null/tables.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "tables": { - "Album": { - "schemaName": "public", - "tableName": "Album", - "columns": { - "Id": { - "name": "AlbumId", - "type": { - "scalarType": "int4" - } - }, - "Title": { - "name": "Title", - "type": { - "scalarType": "varchar" - } - } - } - } - } -} diff --git a/crates/query-engine/translation/tests/goldenfiles/select_where_prefix_function/configuration.json b/crates/query-engine/translation/tests/goldenfiles/select_where_prefix_function/configuration.json new file mode 100644 index 000000000..eae268052 --- /dev/null +++ b/crates/query-engine/translation/tests/goldenfiles/select_where_prefix_function/configuration.json @@ -0,0 +1,51 @@ +{ + "version": "3", + "metadata": { + "tables": { + "Album": { + "schemaName": "public", + "tableName": "Album", + "columns": { + "Id": { + "name": "AlbumId", + "type": { + "scalarType": "int4" + } + } + } + } + }, + "comparisonOperators": { + "varchar": { + "_eq": { + "operatorName": "=", + "argumentType": "varchar", + "operatorKind": "equal" + }, + "_in": { + "operatorName": "in", + "argumentType": "varchar", + "operatorKind": "in" + } + }, + "int4": { + "_eq": { + "operatorName": "=", + "argumentType": "int4", + "operatorKind": "equal" + }, + "_in": { + "operatorName": "in", + "argumentType": "int4", + "operatorKind": "in" + }, + "some_prefix_function": { + "operatorName": "some_prefix_function", + "argumentType": "int4", + "operatorKind": "custom", + "isInfix": false + } + } + } + } +} diff --git a/crates/query-engine/translation/tests/goldenfiles/select_where_prefix_function/tables.json b/crates/query-engine/translation/tests/goldenfiles/select_where_prefix_function/tables.json deleted file mode 100644 index 8365283d5..000000000 --- a/crates/query-engine/translation/tests/goldenfiles/select_where_prefix_function/tables.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - "tables": { - "Album": { - "schemaName": "public", - "tableName": "Album", - "columns": { - "Id": { - "name": "AlbumId", - "type": { - "scalarType": "int4" - } - } - } - } - }, - "comparisonOperators": { - "varchar": { - "_eq": { - "operatorName": "=", - "argumentType": "varchar", - "operatorKind": "equal" - }, - "_in": { - "operatorName": "in", - "argumentType": "varchar", - "operatorKind": "in" - } - }, - "int4": { - "_eq": { - "operatorName": "=", - "argumentType": "int4", - "operatorKind": "equal" - }, - "_in": { - "operatorName": "in", - "argumentType": "int4", - "operatorKind": "in" - }, - "some_prefix_function": { - "operatorName": "some_prefix_function", - "argumentType": "int4", - "operatorKind": "custom", - "isInfix": false - } - } - } -} diff --git a/crates/query-engine/translation/tests/goldenfiles/select_where_related_exists/configuration.json b/crates/query-engine/translation/tests/goldenfiles/select_where_related_exists/configuration.json new file mode 100644 index 000000000..0c214137e --- /dev/null +++ b/crates/query-engine/translation/tests/goldenfiles/select_where_related_exists/configuration.json @@ -0,0 +1,58 @@ +{ + "version": "3", + "metadata": { + "tables": { + "album": { + "schemaName": "public", + "tableName": "Album", + "columns": { + "id": { + "name": "AlbumId", + "type": { + "scalarType": "int4" + } + }, + "title": { + "name": "Title", + "type": { + "scalarType": "varchar" + } + }, + "artist_id": { + "name": "ArtistId", + "type": { + "scalarType": "int4" + } + } + } + }, + "artist": { + "schemaName": "public", + "tableName": "Artist", + "columns": { + "id": { + "name": "ArtistId", + "type": { + "scalarType": "int4" + } + }, + "name": { + "name": "Name", + "type": { + "scalarType": "varchar" + } + } + } + } + }, + "comparisonOperators": { + "varchar": { + "_like": { + "operatorName": "LIKE", + "argumentType": "varchar", + "operatorKind": "custom" + } + } + } + } +} diff --git a/crates/query-engine/translation/tests/goldenfiles/select_where_related_exists/tables.json b/crates/query-engine/translation/tests/goldenfiles/select_where_related_exists/tables.json deleted file mode 100644 index 3bacca490..000000000 --- a/crates/query-engine/translation/tests/goldenfiles/select_where_related_exists/tables.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "tables": { - "album": { - "schemaName": "public", - "tableName": "Album", - "columns": { - "id": { - "name": "AlbumId", - "type": { - "scalarType": "int4" - } - }, - "title": { - "name": "Title", - "type": { - "scalarType": "varchar" - } - }, - "artist_id": { - "name": "ArtistId", - "type": { - "scalarType": "int4" - } - } - } - }, - "artist": { - "schemaName": "public", - "tableName": "Artist", - "columns": { - "id": { - "name": "ArtistId", - "type": { - "scalarType": "int4" - } - }, - "name": { - "name": "Name", - "type": { - "scalarType": "varchar" - } - } - } - } - }, - "comparisonOperators": { - "varchar": { - "_like": { - "operatorName": "LIKE", - "argumentType": "varchar", - "operatorKind": "custom" - } - } - } -} diff --git a/crates/query-engine/translation/tests/goldenfiles/select_where_string/configuration.json b/crates/query-engine/translation/tests/goldenfiles/select_where_string/configuration.json new file mode 100644 index 000000000..b3ad96c0e --- /dev/null +++ b/crates/query-engine/translation/tests/goldenfiles/select_where_string/configuration.json @@ -0,0 +1,34 @@ +{ + "version": "3", + "metadata": { + "tables": { + "Album": { + "schemaName": "public", + "tableName": "Album", + "columns": { + "Id": { + "name": "AlbumId", + "type": { + "scalarType": "int4" + } + }, + "Title": { + "name": "Title", + "type": { + "scalarType": "varchar" + } + } + } + } + }, + "comparisonOperators": { + "varchar": { + "_in": { + "operatorName": "IN", + "argumentType": "varchar", + "operatorKind": "in" + } + } + } + } +} diff --git a/crates/query-engine/translation/tests/goldenfiles/select_where_string/tables.json b/crates/query-engine/translation/tests/goldenfiles/select_where_string/tables.json deleted file mode 100644 index d43939850..000000000 --- a/crates/query-engine/translation/tests/goldenfiles/select_where_string/tables.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "tables": { - "Album": { - "schemaName": "public", - "tableName": "Album", - "columns": { - "Id": { - "name": "AlbumId", - "type": { - "scalarType": "int4" - } - }, - "Title": { - "name": "Title", - "type": { - "scalarType": "varchar" - } - } - } - } - }, - "comparisonOperators": { - "varchar": { - "_in": { - "operatorName": "IN", - "argumentType": "varchar", - "operatorKind": "in" - } - } - } -} diff --git a/crates/query-engine/translation/tests/goldenfiles/select_where_unrelated_exists/configuration.json b/crates/query-engine/translation/tests/goldenfiles/select_where_unrelated_exists/configuration.json new file mode 100644 index 000000000..c71ce5eb2 --- /dev/null +++ b/crates/query-engine/translation/tests/goldenfiles/select_where_unrelated_exists/configuration.json @@ -0,0 +1,65 @@ +{ + "version": "3", + "metadata": { + "tables": { + "album": { + "schemaName": "public", + "tableName": "Album", + "columns": { + "id": { + "name": "AlbumId", + "type": { + "scalarType": "int4" + } + }, + "title": { + "name": "Title", + "type": { + "scalarType": "varchar" + } + }, + "artist_id": { + "name": "ArtistId", + "type": { + "scalarType": "int4" + } + } + } + }, + "artist": { + "schemaName": "public", + "tableName": "Artist", + "columns": { + "id": { + "name": "ArtistId", + "type": { + "scalarType": "int4" + } + }, + "name": { + "name": "Name", + "type": { + "scalarType": "varchar" + } + } + } + } + }, + "comparisonOperators": { + "varchar": { + "_eq": { + "operatorName": "=", + "argumentType": "varchar", + "operatorKind": "equal" + } + }, + "int4": { + "_eq": { + "operatorName": "=", + "argumentType": "int4", + "operatorKind": "equal" + } + } + } + } +} diff --git a/crates/query-engine/translation/tests/goldenfiles/select_where_unrelated_exists/tables.json b/crates/query-engine/translation/tests/goldenfiles/select_where_unrelated_exists/tables.json deleted file mode 100644 index 7488c9437..000000000 --- a/crates/query-engine/translation/tests/goldenfiles/select_where_unrelated_exists/tables.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "tables": { - "album": { - "schemaName": "public", - "tableName": "Album", - "columns": { - "id": { - "name": "AlbumId", - "type": { - "scalarType": "int4" - } - }, - "title": { - "name": "Title", - "type": { - "scalarType": "varchar" - } - }, - "artist_id": { - "name": "ArtistId", - "type": { - "scalarType": "int4" - } - } - } - }, - "artist": { - "schemaName": "public", - "tableName": "Artist", - "columns": { - "id": { - "name": "ArtistId", - "type": { - "scalarType": "int4" - } - }, - "name": { - "name": "Name", - "type": { - "scalarType": "varchar" - } - } - } - } - }, - "comparisonOperators": { - "varchar": { - "_eq": { - "operatorName": "=", - "argumentType": "varchar", - "operatorKind": "equal" - } - }, - "int4": { - "_eq": { - "operatorName": "=", - "argumentType": "int4", - "operatorKind": "equal" - } - } - } -} diff --git a/crates/query-engine/translation/tests/goldenfiles/select_with_limit/configuration.json b/crates/query-engine/translation/tests/goldenfiles/select_with_limit/configuration.json new file mode 100644 index 000000000..e7f298935 --- /dev/null +++ b/crates/query-engine/translation/tests/goldenfiles/select_with_limit/configuration.json @@ -0,0 +1,19 @@ +{ + "version": "3", + "metadata": { + "tables": { + "Album": { + "schemaName": "public", + "tableName": "Album", + "columns": { + "Title": { + "name": "Title", + "type": { + "scalarType": "varchar" + } + } + } + } + } + } +} diff --git a/crates/query-engine/translation/tests/goldenfiles/select_with_limit/tables.json b/crates/query-engine/translation/tests/goldenfiles/select_with_limit/tables.json deleted file mode 100644 index a1a57a93c..000000000 --- a/crates/query-engine/translation/tests/goldenfiles/select_with_limit/tables.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "tables": { - "Album": { - "schemaName": "public", - "tableName": "Album", - "columns": { - "Title": { - "name": "Title", - "type": { - "scalarType": "varchar" - } - } - } - } - } -} diff --git a/crates/query-engine/translation/tests/goldenfiles/simple_array_relationship/configuration.json b/crates/query-engine/translation/tests/goldenfiles/simple_array_relationship/configuration.json new file mode 100644 index 000000000..668c8d63d --- /dev/null +++ b/crates/query-engine/translation/tests/goldenfiles/simple_array_relationship/configuration.json @@ -0,0 +1,49 @@ +{ + "version": "3", + "metadata": { + "tables": { + "Album": { + "schemaName": "public", + "tableName": "Album", + "columns": { + "AlbumId": { + "name": "AlbumId", + "type": { + "scalarType": "int4" + } + }, + "Title": { + "name": "Title", + "type": { + "scalarType": "varchar" + } + }, + "ArtistId": { + "name": "ArtistId", + "type": { + "scalarType": "int4" + } + } + } + }, + "Artist": { + "schemaName": "public", + "tableName": "Artist", + "columns": { + "ArtistId": { + "name": "ArtistId", + "type": { + "scalarType": "int4" + } + }, + "Name": { + "name": "Name", + "type": { + "scalarType": "varchar" + } + } + } + } + } + } +} diff --git a/crates/query-engine/translation/tests/goldenfiles/simple_array_relationship/tables.json b/crates/query-engine/translation/tests/goldenfiles/simple_array_relationship/tables.json deleted file mode 100644 index 1b79f596e..000000000 --- a/crates/query-engine/translation/tests/goldenfiles/simple_array_relationship/tables.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "tables": { - "Album": { - "schemaName": "public", - "tableName": "Album", - "columns": { - "AlbumId": { - "name": "AlbumId", - "type": { - "scalarType": "int4" - } - }, - "Title": { - "name": "Title", - "type": { - "scalarType": "varchar" - } - }, - "ArtistId": { - "name": "ArtistId", - "type": { - "scalarType": "int4" - } - } - } - }, - "Artist": { - "schemaName": "public", - "tableName": "Artist", - "columns": { - "ArtistId": { - "name": "ArtistId", - "type": { - "scalarType": "int4" - } - }, - "Name": { - "name": "Name", - "type": { - "scalarType": "varchar" - } - } - } - } - } -} diff --git a/crates/query-engine/translation/tests/goldenfiles/simple_object_relationship/configuration.json b/crates/query-engine/translation/tests/goldenfiles/simple_object_relationship/configuration.json new file mode 100644 index 000000000..668c8d63d --- /dev/null +++ b/crates/query-engine/translation/tests/goldenfiles/simple_object_relationship/configuration.json @@ -0,0 +1,49 @@ +{ + "version": "3", + "metadata": { + "tables": { + "Album": { + "schemaName": "public", + "tableName": "Album", + "columns": { + "AlbumId": { + "name": "AlbumId", + "type": { + "scalarType": "int4" + } + }, + "Title": { + "name": "Title", + "type": { + "scalarType": "varchar" + } + }, + "ArtistId": { + "name": "ArtistId", + "type": { + "scalarType": "int4" + } + } + } + }, + "Artist": { + "schemaName": "public", + "tableName": "Artist", + "columns": { + "ArtistId": { + "name": "ArtistId", + "type": { + "scalarType": "int4" + } + }, + "Name": { + "name": "Name", + "type": { + "scalarType": "varchar" + } + } + } + } + } + } +} diff --git a/crates/query-engine/translation/tests/goldenfiles/simple_object_relationship/tables.json b/crates/query-engine/translation/tests/goldenfiles/simple_object_relationship/tables.json deleted file mode 100644 index 1b79f596e..000000000 --- a/crates/query-engine/translation/tests/goldenfiles/simple_object_relationship/tables.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "tables": { - "Album": { - "schemaName": "public", - "tableName": "Album", - "columns": { - "AlbumId": { - "name": "AlbumId", - "type": { - "scalarType": "int4" - } - }, - "Title": { - "name": "Title", - "type": { - "scalarType": "varchar" - } - }, - "ArtistId": { - "name": "ArtistId", - "type": { - "scalarType": "int4" - } - } - } - }, - "Artist": { - "schemaName": "public", - "tableName": "Artist", - "columns": { - "ArtistId": { - "name": "ArtistId", - "type": { - "scalarType": "int4" - } - }, - "Name": { - "name": "Name", - "type": { - "scalarType": "varchar" - } - } - } - } - } -} diff --git a/crates/query-engine/translation/tests/goldenfiles/sorting_by_nested_relationship_column/configuration.json b/crates/query-engine/translation/tests/goldenfiles/sorting_by_nested_relationship_column/configuration.json new file mode 100644 index 000000000..b7211bda1 --- /dev/null +++ b/crates/query-engine/translation/tests/goldenfiles/sorting_by_nested_relationship_column/configuration.json @@ -0,0 +1,73 @@ +{ + "version": "3", + "metadata": { + "tables": { + "album": { + "schemaName": "public", + "tableName": "Album", + "columns": { + "album_id": { + "name": "AlbumId", + "type": { + "scalarType": "int4" + } + }, + "title": { + "name": "Title", + "type": { + "scalarType": "varchar" + } + }, + "artist_id": { + "name": "ArtistId", + "type": { + "scalarType": "int4" + } + } + } + }, + "artist": { + "schemaName": "public", + "tableName": "Artist", + "columns": { + "artist_id": { + "name": "ArtistId", + "type": { + "scalarType": "int4" + } + }, + "name": { + "name": "Name", + "type": { + "scalarType": "varchar" + } + } + } + }, + "track": { + "schemaName": "public", + "tableName": "Track", + "columns": { + "track_id": { + "name": "TrackId", + "type": { + "scalarType": "int4" + } + }, + "name": { + "name": "Name", + "type": { + "scalarType": "varchar" + } + }, + "album_id": { + "name": "AlbumId", + "type": { + "scalarType": "int4" + } + } + } + } + } + } +} diff --git a/crates/query-engine/translation/tests/goldenfiles/sorting_by_nested_relationship_column/tables.json b/crates/query-engine/translation/tests/goldenfiles/sorting_by_nested_relationship_column/tables.json deleted file mode 100644 index ff978405d..000000000 --- a/crates/query-engine/translation/tests/goldenfiles/sorting_by_nested_relationship_column/tables.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "tables": { - "album": { - "schemaName": "public", - "tableName": "Album", - "columns": { - "album_id": { - "name": "AlbumId", - "type": { - "scalarType": "int4" - } - }, - "title": { - "name": "Title", - "type": { - "scalarType": "varchar" - } - }, - "artist_id": { - "name": "ArtistId", - "type": { - "scalarType": "int4" - } - } - } - }, - "artist": { - "schemaName": "public", - "tableName": "Artist", - "columns": { - "artist_id": { - "name": "ArtistId", - "type": { - "scalarType": "int4" - } - }, - "name": { - "name": "Name", - "type": { - "scalarType": "varchar" - } - } - } - }, - "track": { - "schemaName": "public", - "tableName": "Track", - "columns": { - "track_id": { - "name": "TrackId", - "type": { - "scalarType": "int4" - } - }, - "name": { - "name": "Name", - "type": { - "scalarType": "varchar" - } - }, - "album_id": { - "name": "AlbumId", - "type": { - "scalarType": "int4" - } - } - } - } - } -} diff --git a/crates/query-engine/translation/tests/goldenfiles/sorting_by_nested_relationship_column_with_predicate/configuration.json b/crates/query-engine/translation/tests/goldenfiles/sorting_by_nested_relationship_column_with_predicate/configuration.json new file mode 100644 index 000000000..47275bbc2 --- /dev/null +++ b/crates/query-engine/translation/tests/goldenfiles/sorting_by_nested_relationship_column_with_predicate/configuration.json @@ -0,0 +1,99 @@ +{ + "version": "3", + "metadata": { + "tables": { + "album": { + "schemaName": "public", + "tableName": "Album", + "columns": { + "album_id": { + "name": "AlbumId", + "type": { + "scalarType": "int4" + } + }, + "title": { + "name": "Title", + "type": { + "scalarType": "varchar" + } + }, + "artist_id": { + "name": "ArtistId", + "type": { + "scalarType": "int4" + } + } + } + }, + "artist": { + "schemaName": "public", + "tableName": "Artist", + "columns": { + "artist_id": { + "name": "ArtistId", + "type": { + "scalarType": "int4" + } + }, + "name": { + "name": "Name", + "type": { + "scalarType": "varchar" + } + } + } + }, + "track": { + "schemaName": "public", + "tableName": "Track", + "columns": { + "track_id": { + "name": "TrackId", + "type": { + "scalarType": "int4" + } + }, + "name": { + "name": "Name", + "type": { + "scalarType": "varchar" + } + }, + "album_id": { + "name": "AlbumId", + "type": { + "scalarType": "int4" + } + } + } + } + }, + "comparisonOperators": { + "varchar": { + "_eq": { + "operatorName": "=", + "argumentType": "varchar", + "operatorKind": "equal" + }, + "_in": { + "operatorName": "in", + "argumentType": "varchar", + "operatorKind": "in" + } + }, + "int4": { + "_eq": { + "operatorName": "=", + "argumentType": "int4", + "operatorKind": "equal" + }, + "_in": { + "operatorName": "in", + "argumentType": "int4", + "operatorKind": "in" + } + } + } + } +} diff --git a/crates/query-engine/translation/tests/goldenfiles/sorting_by_nested_relationship_column_with_predicate/tables.json b/crates/query-engine/translation/tests/goldenfiles/sorting_by_nested_relationship_column_with_predicate/tables.json deleted file mode 100644 index 9b6737d31..000000000 --- a/crates/query-engine/translation/tests/goldenfiles/sorting_by_nested_relationship_column_with_predicate/tables.json +++ /dev/null @@ -1,96 +0,0 @@ -{ - "tables": { - "album": { - "schemaName": "public", - "tableName": "Album", - "columns": { - "album_id": { - "name": "AlbumId", - "type": { - "scalarType": "int4" - } - }, - "title": { - "name": "Title", - "type": { - "scalarType": "varchar" - } - }, - "artist_id": { - "name": "ArtistId", - "type": { - "scalarType": "int4" - } - } - } - }, - "artist": { - "schemaName": "public", - "tableName": "Artist", - "columns": { - "artist_id": { - "name": "ArtistId", - "type": { - "scalarType": "int4" - } - }, - "name": { - "name": "Name", - "type": { - "scalarType": "varchar" - } - } - } - }, - "track": { - "schemaName": "public", - "tableName": "Track", - "columns": { - "track_id": { - "name": "TrackId", - "type": { - "scalarType": "int4" - } - }, - "name": { - "name": "Name", - "type": { - "scalarType": "varchar" - } - }, - "album_id": { - "name": "AlbumId", - "type": { - "scalarType": "int4" - } - } - } - } - }, - "comparisonOperators": { - "varchar": { - "_eq": { - "operatorName": "=", - "argumentType": "varchar", - "operatorKind": "equal" - }, - "_in": { - "operatorName": "in", - "argumentType": "varchar", - "operatorKind": "in" - } - }, - "int4": { - "_eq": { - "operatorName": "=", - "argumentType": "int4", - "operatorKind": "equal" - }, - "_in": { - "operatorName": "in", - "argumentType": "int4", - "operatorKind": "in" - } - } - } -} diff --git a/crates/query-engine/translation/tests/goldenfiles/sorting_by_nested_relationship_count/configuration.json b/crates/query-engine/translation/tests/goldenfiles/sorting_by_nested_relationship_count/configuration.json new file mode 100644 index 000000000..3c20fa37d --- /dev/null +++ b/crates/query-engine/translation/tests/goldenfiles/sorting_by_nested_relationship_count/configuration.json @@ -0,0 +1,73 @@ +{ + "version": "3", + "metadata": { + "tables": { + "Album": { + "schemaName": "public", + "tableName": "Album", + "columns": { + "AlbumId": { + "name": "AlbumId", + "type": { + "scalarType": "int4" + } + }, + "Title": { + "name": "Title", + "type": { + "scalarType": "varchar" + } + }, + "ArtistId": { + "name": "ArtistId", + "type": { + "scalarType": "int4" + } + } + } + }, + "Artist": { + "schemaName": "public", + "tableName": "Artist", + "columns": { + "ArtistId": { + "name": "ArtistId", + "type": { + "scalarType": "int4" + } + }, + "Name": { + "name": "Name", + "type": { + "scalarType": "varchar" + } + } + } + }, + "Track": { + "schemaName": "public", + "tableName": "Track", + "columns": { + "TrackId": { + "name": "TrackId", + "type": { + "scalarType": "int4" + } + }, + "Name": { + "name": "Name", + "type": { + "scalarType": "varchar" + } + }, + "AlbumId": { + "name": "AlbumId", + "type": { + "scalarType": "int4" + } + } + } + } + } + } +} diff --git a/crates/query-engine/translation/tests/goldenfiles/sorting_by_nested_relationship_count/tables.json b/crates/query-engine/translation/tests/goldenfiles/sorting_by_nested_relationship_count/tables.json deleted file mode 100644 index 17d9782e2..000000000 --- a/crates/query-engine/translation/tests/goldenfiles/sorting_by_nested_relationship_count/tables.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "tables": { - "Album": { - "schemaName": "public", - "tableName": "Album", - "columns": { - "AlbumId": { - "name": "AlbumId", - "type": { - "scalarType": "int4" - } - }, - "Title": { - "name": "Title", - "type": { - "scalarType": "varchar" - } - }, - "ArtistId": { - "name": "ArtistId", - "type": { - "scalarType": "int4" - } - } - } - }, - "Artist": { - "schemaName": "public", - "tableName": "Artist", - "columns": { - "ArtistId": { - "name": "ArtistId", - "type": { - "scalarType": "int4" - } - }, - "Name": { - "name": "Name", - "type": { - "scalarType": "varchar" - } - } - } - }, - "Track": { - "schemaName": "public", - "tableName": "Track", - "columns": { - "TrackId": { - "name": "TrackId", - "type": { - "scalarType": "int4" - } - }, - "Name": { - "name": "Name", - "type": { - "scalarType": "varchar" - } - }, - "AlbumId": { - "name": "AlbumId", - "type": { - "scalarType": "int4" - } - } - } - } - } -} diff --git a/crates/query-engine/translation/tests/goldenfiles/sorting_by_no_relationship_aggregate/configuration.json b/crates/query-engine/translation/tests/goldenfiles/sorting_by_no_relationship_aggregate/configuration.json new file mode 100644 index 000000000..b90043914 --- /dev/null +++ b/crates/query-engine/translation/tests/goldenfiles/sorting_by_no_relationship_aggregate/configuration.json @@ -0,0 +1,32 @@ +{ + "version": "3", + "metadata": { + "tables": { + "Album": { + "schemaName": "public", + "tableName": "Album", + "columns": { + "AlbumId": { + "name": "AlbumId", + "type": { + "scalarType": "int4" + } + }, + "Title": { + "name": "Title", + "type": { + "scalarType": "varchar" + } + }, + "TopRadioChartPlacement": { + "name": "TopRadioChartPlacement", + "type": { + "scalarType": "int4" + }, + "nullable": "nullable" + } + } + } + } + } +} diff --git a/crates/query-engine/translation/tests/goldenfiles/sorting_by_no_relationship_aggregate/tables.json b/crates/query-engine/translation/tests/goldenfiles/sorting_by_no_relationship_aggregate/tables.json deleted file mode 100644 index c6bcd5912..000000000 --- a/crates/query-engine/translation/tests/goldenfiles/sorting_by_no_relationship_aggregate/tables.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "tables": { - "Album": { - "schemaName": "public", - "tableName": "Album", - "columns": { - "AlbumId": { - "name": "AlbumId", - "type": { - "scalarType": "int4" - } - }, - "Title": { - "name": "Title", - "type": { - "scalarType": "varchar" - } - }, - "TopRadioChartPlacement": { - "name": "TopRadioChartPlacement", - "type": { - "scalarType": "int4" - }, - "nullable": "nullable" - } - } - } - } -} diff --git a/crates/query-engine/translation/tests/goldenfiles/sorting_by_recursive_relationship_column/configuration.json b/crates/query-engine/translation/tests/goldenfiles/sorting_by_recursive_relationship_column/configuration.json new file mode 100644 index 000000000..5bdf75433 --- /dev/null +++ b/crates/query-engine/translation/tests/goldenfiles/sorting_by_recursive_relationship_column/configuration.json @@ -0,0 +1,55 @@ +{ + "version": "3", + "metadata": { + "tables": { + "Company": { + "schemaName": "public", + "tableName": "Company", + "columns": { + "CompanyId": { + "name": "CompanyId", + "type": { + "scalarType": "int4" + } + }, + "Name": { + "name": "Name", + "type": { + "scalarType": "varchar" + } + }, + "CEOId": { + "name": "CEOId", + "type": { + "scalarType": "int4" + } + } + } + }, + "Person": { + "schemaName": "public", + "tableName": "Person", + "columns": { + "PersonId": { + "name": "PersonId", + "type": { + "scalarType": "int4" + } + }, + "Name": { + "name": "Name", + "type": { + "scalarType": "varchar" + } + }, + "ParentId": { + "name": "ParentId", + "type": { + "scalarType": "int4" + } + } + } + } + } + } +} diff --git a/crates/query-engine/translation/tests/goldenfiles/sorting_by_recursive_relationship_column/tables.json b/crates/query-engine/translation/tests/goldenfiles/sorting_by_recursive_relationship_column/tables.json deleted file mode 100644 index d9b0f2df5..000000000 --- a/crates/query-engine/translation/tests/goldenfiles/sorting_by_recursive_relationship_column/tables.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "tables": { - "Company": { - "schemaName": "public", - "tableName": "Company", - "columns": { - "CompanyId": { - "name": "CompanyId", - "type": { - "scalarType": "int4" - } - }, - "Name": { - "name": "Name", - "type": { - "scalarType": "varchar" - } - }, - "CEOId": { - "name": "CEOId", - "type": { - "scalarType": "int4" - } - } - } - }, - "Person": { - "schemaName": "public", - "tableName": "Person", - "columns": { - "PersonId": { - "name": "PersonId", - "type": { - "scalarType": "int4" - } - }, - "Name": { - "name": "Name", - "type": { - "scalarType": "varchar" - } - }, - "ParentId": { - "name": "ParentId", - "type": { - "scalarType": "int4" - } - } - } - } - } -} diff --git a/crates/query-engine/translation/tests/goldenfiles/sorting_by_relationship_column/configuration.json b/crates/query-engine/translation/tests/goldenfiles/sorting_by_relationship_column/configuration.json new file mode 100644 index 000000000..668c8d63d --- /dev/null +++ b/crates/query-engine/translation/tests/goldenfiles/sorting_by_relationship_column/configuration.json @@ -0,0 +1,49 @@ +{ + "version": "3", + "metadata": { + "tables": { + "Album": { + "schemaName": "public", + "tableName": "Album", + "columns": { + "AlbumId": { + "name": "AlbumId", + "type": { + "scalarType": "int4" + } + }, + "Title": { + "name": "Title", + "type": { + "scalarType": "varchar" + } + }, + "ArtistId": { + "name": "ArtistId", + "type": { + "scalarType": "int4" + } + } + } + }, + "Artist": { + "schemaName": "public", + "tableName": "Artist", + "columns": { + "ArtistId": { + "name": "ArtistId", + "type": { + "scalarType": "int4" + } + }, + "Name": { + "name": "Name", + "type": { + "scalarType": "varchar" + } + } + } + } + } + } +} diff --git a/crates/query-engine/translation/tests/goldenfiles/sorting_by_relationship_column/tables.json b/crates/query-engine/translation/tests/goldenfiles/sorting_by_relationship_column/tables.json deleted file mode 100644 index 1b79f596e..000000000 --- a/crates/query-engine/translation/tests/goldenfiles/sorting_by_relationship_column/tables.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "tables": { - "Album": { - "schemaName": "public", - "tableName": "Album", - "columns": { - "AlbumId": { - "name": "AlbumId", - "type": { - "scalarType": "int4" - } - }, - "Title": { - "name": "Title", - "type": { - "scalarType": "varchar" - } - }, - "ArtistId": { - "name": "ArtistId", - "type": { - "scalarType": "int4" - } - } - } - }, - "Artist": { - "schemaName": "public", - "tableName": "Artist", - "columns": { - "ArtistId": { - "name": "ArtistId", - "type": { - "scalarType": "int4" - } - }, - "Name": { - "name": "Name", - "type": { - "scalarType": "varchar" - } - } - } - } - } -} diff --git a/crates/query-engine/translation/tests/goldenfiles/sorting_by_relationship_count/configuration.json b/crates/query-engine/translation/tests/goldenfiles/sorting_by_relationship_count/configuration.json new file mode 100644 index 000000000..668c8d63d --- /dev/null +++ b/crates/query-engine/translation/tests/goldenfiles/sorting_by_relationship_count/configuration.json @@ -0,0 +1,49 @@ +{ + "version": "3", + "metadata": { + "tables": { + "Album": { + "schemaName": "public", + "tableName": "Album", + "columns": { + "AlbumId": { + "name": "AlbumId", + "type": { + "scalarType": "int4" + } + }, + "Title": { + "name": "Title", + "type": { + "scalarType": "varchar" + } + }, + "ArtistId": { + "name": "ArtistId", + "type": { + "scalarType": "int4" + } + } + } + }, + "Artist": { + "schemaName": "public", + "tableName": "Artist", + "columns": { + "ArtistId": { + "name": "ArtistId", + "type": { + "scalarType": "int4" + } + }, + "Name": { + "name": "Name", + "type": { + "scalarType": "varchar" + } + } + } + } + } + } +} diff --git a/crates/query-engine/translation/tests/goldenfiles/sorting_by_relationship_count/tables.json b/crates/query-engine/translation/tests/goldenfiles/sorting_by_relationship_count/tables.json deleted file mode 100644 index 1b79f596e..000000000 --- a/crates/query-engine/translation/tests/goldenfiles/sorting_by_relationship_count/tables.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "tables": { - "Album": { - "schemaName": "public", - "tableName": "Album", - "columns": { - "AlbumId": { - "name": "AlbumId", - "type": { - "scalarType": "int4" - } - }, - "Title": { - "name": "Title", - "type": { - "scalarType": "varchar" - } - }, - "ArtistId": { - "name": "ArtistId", - "type": { - "scalarType": "int4" - } - } - } - }, - "Artist": { - "schemaName": "public", - "tableName": "Artist", - "columns": { - "ArtistId": { - "name": "ArtistId", - "type": { - "scalarType": "int4" - } - }, - "Name": { - "name": "Name", - "type": { - "scalarType": "varchar" - } - } - } - } - } -} diff --git a/crates/query-engine/translation/tests/goldenfiles/sorting_by_relationship_count_with_predicate/configuration.json b/crates/query-engine/translation/tests/goldenfiles/sorting_by_relationship_count_with_predicate/configuration.json new file mode 100644 index 000000000..db9fbfb21 --- /dev/null +++ b/crates/query-engine/translation/tests/goldenfiles/sorting_by_relationship_count_with_predicate/configuration.json @@ -0,0 +1,82 @@ +{ + "version": "3", + "metadata": { + "tables": { + "Album": { + "schemaName": "public", + "tableName": "Album", + "columns": { + "AlbumId": { + "name": "AlbumId", + "type": { + "scalarType": "int4" + } + }, + "Title": { + "name": "Title", + "type": { + "scalarType": "varchar" + } + }, + "ArtistId": { + "name": "ArtistId", + "type": { + "scalarType": "int4" + } + } + } + }, + "Artist": { + "schemaName": "public", + "tableName": "Artist", + "columns": { + "ArtistId": { + "name": "ArtistId", + "type": { + "scalarType": "int4" + } + }, + "Name": { + "name": "Name", + "type": { + "scalarType": "varchar" + } + } + } + }, + "track": { + "schemaName": "public", + "tableName": "Track", + "columns": { + "track_id": { + "name": "TrackId", + "type": { + "scalarType": "int4" + } + }, + "name": { + "name": "Name", + "type": { + "scalarType": "varchar" + } + }, + "album_id": { + "name": "AlbumId", + "type": { + "scalarType": "int4" + } + } + } + } + }, + "comparisonOperators": { + "varchar": { + "_like": { + "operatorName": "LIKE", + "argumentType": "varchar", + "operatorKind": "custom" + } + } + } + } +} diff --git a/crates/query-engine/translation/tests/goldenfiles/sorting_by_relationship_count_with_predicate/tables.json b/crates/query-engine/translation/tests/goldenfiles/sorting_by_relationship_count_with_predicate/tables.json deleted file mode 100644 index 758695d1f..000000000 --- a/crates/query-engine/translation/tests/goldenfiles/sorting_by_relationship_count_with_predicate/tables.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "tables": { - "Album": { - "schemaName": "public", - "tableName": "Album", - "columns": { - "AlbumId": { - "name": "AlbumId", - "type": { - "scalarType": "int4" - } - }, - "Title": { - "name": "Title", - "type": { - "scalarType": "varchar" - } - }, - "ArtistId": { - "name": "ArtistId", - "type": { - "scalarType": "int4" - } - } - } - }, - "Artist": { - "schemaName": "public", - "tableName": "Artist", - "columns": { - "ArtistId": { - "name": "ArtistId", - "type": { - "scalarType": "int4" - } - }, - "Name": { - "name": "Name", - "type": { - "scalarType": "varchar" - } - } - } - }, - "track": { - "schemaName": "public", - "tableName": "Track", - "columns": { - "track_id": { - "name": "TrackId", - "type": { - "scalarType": "int4" - } - }, - "name": { - "name": "Name", - "type": { - "scalarType": "varchar" - } - }, - "album_id": { - "name": "AlbumId", - "type": { - "scalarType": "int4" - } - } - } - } - }, - "comparisonOperators": { - "varchar": { - "_like": { - "operatorName": "LIKE", - "argumentType": "varchar", - "operatorKind": "custom" - } - } - } -} diff --git a/crates/query-engine/translation/tests/goldenfiles/values/select_types_on_comparisons/configuration.json b/crates/query-engine/translation/tests/goldenfiles/values/select_types_on_comparisons/configuration.json new file mode 100644 index 000000000..4d5e74704 --- /dev/null +++ b/crates/query-engine/translation/tests/goldenfiles/values/select_types_on_comparisons/configuration.json @@ -0,0 +1,83 @@ +{ + "version": "3", + "metadata": { + "tables": { + "types": { + "schemaName": "public", + "tableName": "types", + "columns": { + "date": { + "name": "date", + "type": { + "scalarType": "date" + } + }, + "time": { + "name": "time", + "type": { + "scalarType": "time" + } + }, + "timetz": { + "name": "timetz", + "type": { + "scalarType": "timetz" + } + }, + "timestamp": { + "name": "timestamp", + "type": { + "scalarType": "timestamp" + } + }, + "timestamptz": { + "name": "timestamptz", + "type": { + "scalarType": "timestamptz" + } + } + }, + "uniquenessConstraints": {}, + "foreignRelations": {} + } + }, + "nativeQueries": {}, + "comparisonOperators": { + "date": { + "_eq": { + "operatorName": "=", + "operatorKind": "equal", + "argumentType": "date" + } + }, + "time": { + "_eq": { + "operatorName": "=", + "operatorKind": "equal", + "argumentType": "time" + } + }, + "timetz": { + "_eq": { + "operatorName": "=", + "operatorKind": "equal", + "argumentType": "timetz" + } + }, + "timestamp": { + "_eq": { + "operatorName": "=", + "operatorKind": "equal", + "argumentType": "timestamp" + } + }, + "timestamptz": { + "_eq": { + "operatorName": "=", + "operatorKind": "equal", + "argumentType": "timestamptz" + } + } + } + } +} diff --git a/crates/query-engine/translation/tests/goldenfiles/values/select_types_on_comparisons/tables.json b/crates/query-engine/translation/tests/goldenfiles/values/select_types_on_comparisons/tables.json deleted file mode 100644 index 2b5f21815..000000000 --- a/crates/query-engine/translation/tests/goldenfiles/values/select_types_on_comparisons/tables.json +++ /dev/null @@ -1,80 +0,0 @@ -{ - "tables": { - "types": { - "schemaName": "public", - "tableName": "types", - "columns": { - "date": { - "name": "date", - "type": { - "scalarType": "date" - } - }, - "time": { - "name": "time", - "type": { - "scalarType": "time" - } - }, - "timetz": { - "name": "timetz", - "type": { - "scalarType": "timetz" - } - }, - "timestamp": { - "name": "timestamp", - "type": { - "scalarType": "timestamp" - } - }, - "timestamptz": { - "name": "timestamptz", - "type": { - "scalarType": "timestamptz" - } - } - }, - "uniquenessConstraints": {}, - "foreignRelations": {} - } - }, - "nativeQueries": {}, - "comparisonOperators": { - "date": { - "_eq": { - "operatorName": "=", - "operatorKind": "equal", - "argumentType": "date" - } - }, - "time": { - "_eq": { - "operatorName": "=", - "operatorKind": "equal", - "argumentType": "time" - } - }, - "timetz": { - "_eq": { - "operatorName": "=", - "operatorKind": "equal", - "argumentType": "timetz" - } - }, - "timestamp": { - "_eq": { - "operatorName": "=", - "operatorKind": "equal", - "argumentType": "timestamp" - } - }, - "timestamptz": { - "_eq": { - "operatorName": "=", - "operatorKind": "equal", - "argumentType": "timestamptz" - } - } - } -} diff --git a/crates/query-engine/translation/tests/goldenfiles/values/select_types_on_native_queries/configuration.json b/crates/query-engine/translation/tests/goldenfiles/values/select_types_on_native_queries/configuration.json new file mode 100644 index 000000000..c801ee41b --- /dev/null +++ b/crates/query-engine/translation/tests/goldenfiles/values/select_types_on_native_queries/configuration.json @@ -0,0 +1,74 @@ +{ + "version": "3", + "metadata": { + "nativeQueries": { + "types": { + "sql": "SELECT {{date}} as date, {{time}} as time, {{timetz}} as timetz, {{timestamp}} as timestamp, {{timestamptz}} as timestamptz", + "columns": { + "date": { + "name": "date", + "type": { + "scalarType": "date" + } + }, + "time": { + "name": "time", + "type": { + "scalarType": "time" + } + }, + "timetz": { + "name": "timetz", + "type": { + "scalarType": "timetz" + } + }, + "timestamp": { + "name": "timestamp", + "type": { + "scalarType": "timestamp" + } + }, + "timestamptz": { + "name": "timestamptz", + "type": { + "scalarType": "timestamptz" + } + } + }, + "arguments": { + "date": { + "name": "date", + "type": { + "scalarType": "date" + } + }, + "time": { + "name": "time", + "type": { + "scalarType": "time" + } + }, + "timetz": { + "name": "timetz", + "type": { + "scalarType": "timetz" + } + }, + "timestamp": { + "name": "timestamp", + "type": { + "scalarType": "timestamp" + } + }, + "timestamptz": { + "name": "timestamptz", + "type": { + "scalarType": "timestamptz" + } + } + } + } + } + } +} diff --git a/crates/query-engine/translation/tests/goldenfiles/values/select_types_on_native_queries/tables.json b/crates/query-engine/translation/tests/goldenfiles/values/select_types_on_native_queries/tables.json deleted file mode 100644 index 615db6b1c..000000000 --- a/crates/query-engine/translation/tests/goldenfiles/values/select_types_on_native_queries/tables.json +++ /dev/null @@ -1,71 +0,0 @@ -{ - "nativeQueries": { - "types": { - "sql": "SELECT {{date}} as date, {{time}} as time, {{timetz}} as timetz, {{timestamp}} as timestamp, {{timestamptz}} as timestamptz", - "columns": { - "date": { - "name": "date", - "type": { - "scalarType": "date" - } - }, - "time": { - "name": "time", - "type": { - "scalarType": "time" - } - }, - "timetz": { - "name": "timetz", - "type": { - "scalarType": "timetz" - } - }, - "timestamp": { - "name": "timestamp", - "type": { - "scalarType": "timestamp" - } - }, - "timestamptz": { - "name": "timestamptz", - "type": { - "scalarType": "timestamptz" - } - } - }, - "arguments": { - "date": { - "name": "date", - "type": { - "scalarType": "date" - } - }, - "time": { - "name": "time", - "type": { - "scalarType": "time" - } - }, - "timetz": { - "name": "timetz", - "type": { - "scalarType": "timetz" - } - }, - "timestamp": { - "name": "timestamp", - "type": { - "scalarType": "timestamp" - } - }, - "timestamptz": { - "name": "timestamptz", - "type": { - "scalarType": "timestamptz" - } - } - } - } - } -} diff --git a/crates/query-engine/translation/tests/goldenfiles/very_nested_recursive_relationship/configuration.json b/crates/query-engine/translation/tests/goldenfiles/very_nested_recursive_relationship/configuration.json new file mode 100644 index 000000000..668c8d63d --- /dev/null +++ b/crates/query-engine/translation/tests/goldenfiles/very_nested_recursive_relationship/configuration.json @@ -0,0 +1,49 @@ +{ + "version": "3", + "metadata": { + "tables": { + "Album": { + "schemaName": "public", + "tableName": "Album", + "columns": { + "AlbumId": { + "name": "AlbumId", + "type": { + "scalarType": "int4" + } + }, + "Title": { + "name": "Title", + "type": { + "scalarType": "varchar" + } + }, + "ArtistId": { + "name": "ArtistId", + "type": { + "scalarType": "int4" + } + } + } + }, + "Artist": { + "schemaName": "public", + "tableName": "Artist", + "columns": { + "ArtistId": { + "name": "ArtistId", + "type": { + "scalarType": "int4" + } + }, + "Name": { + "name": "Name", + "type": { + "scalarType": "varchar" + } + } + } + } + } + } +} diff --git a/crates/query-engine/translation/tests/goldenfiles/very_nested_recursive_relationship/tables.json b/crates/query-engine/translation/tests/goldenfiles/very_nested_recursive_relationship/tables.json deleted file mode 100644 index 1b79f596e..000000000 --- a/crates/query-engine/translation/tests/goldenfiles/very_nested_recursive_relationship/tables.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "tables": { - "Album": { - "schemaName": "public", - "tableName": "Album", - "columns": { - "AlbumId": { - "name": "AlbumId", - "type": { - "scalarType": "int4" - } - }, - "Title": { - "name": "Title", - "type": { - "scalarType": "varchar" - } - }, - "ArtistId": { - "name": "ArtistId", - "type": { - "scalarType": "int4" - } - } - } - }, - "Artist": { - "schemaName": "public", - "tableName": "Artist", - "columns": { - "ArtistId": { - "name": "ArtistId", - "type": { - "scalarType": "int4" - } - }, - "Name": { - "name": "Name", - "type": { - "scalarType": "varchar" - } - } - } - } - } -} diff --git a/crates/query-engine/translation/tests/snapshots/query_engine_translation__translation__mutation__v1__delete__tests__delete_to_sql.snap b/crates/query-engine/translation/tests/snapshots/query_engine_translation__translation__mutation__v1__delete__tests__delete_to_sql.snap index 26a217e71..b3753fda9 100644 --- a/crates/query-engine/translation/tests/snapshots/query_engine_translation__translation__mutation__v1__delete__tests__delete_to_sql.snap +++ b/crates/query-engine/translation/tests/snapshots/query_engine_translation__translation__mutation__v1__delete__tests__delete_to_sql.snap @@ -1,5 +1,5 @@ --- -source: crates/query-engine/translation/src/translation/mutation/delete.rs +source: crates/query-engine/translation/src/translation/mutation/v1/delete.rs expression: pretty --- DELETE FROM diff --git a/crates/query-engine/translation/tests/tests.rs b/crates/query-engine/translation/tests/tests.rs index 9912b40c6..3f25cf708 100644 --- a/crates/query-engine/translation/tests/tests.rs +++ b/crates/query-engine/translation/tests/tests.rs @@ -1,249 +1,319 @@ mod common; -#[test] -fn no_fields() { - let result = common::test_translation("no_fields").unwrap(); +#[tokio::test] +async fn no_fields() { + let result = common::test_translation("no_fields").await.unwrap(); insta::assert_snapshot!(result); } -#[test] -fn select_array_column() { - let result = common::test_translation("select_array_column").unwrap(); +#[tokio::test] +async fn select_array_column() { + let result = common::test_translation("select_array_column") + .await + .unwrap(); insta::assert_snapshot!(result); } -#[test] -fn select_array_column_nested_types() { - let result = common::test_translation("select_array_column_nested_types").unwrap(); +#[tokio::test] +async fn select_array_column_nested_types() { + let result = common::test_translation("select_array_column_nested_types") + .await + .unwrap(); insta::assert_snapshot!(result); } -#[test] -fn select_array_variable() { - let result = common::test_translation("select_array_variable").unwrap(); +#[tokio::test] +async fn select_array_variable() { + let result = common::test_translation("select_array_variable") + .await + .unwrap(); insta::assert_snapshot!(result); } -#[test] -fn select_array_variable_nested_types() { - let result = common::test_translation("select_array_variable_nested_types").unwrap(); +#[tokio::test] +async fn select_array_variable_nested_types() { + let result = common::test_translation("select_array_variable_nested_types") + .await + .unwrap(); insta::assert_snapshot!(result); } -#[test] -fn select_composite_column_simple() { - let result = common::test_translation("select_composite_column_simple").unwrap(); +#[tokio::test] +async fn select_composite_column_simple() { + let result = common::test_translation("select_composite_column_simple") + .await + .unwrap(); insta::assert_snapshot!(result); } -#[test] -fn select_composite_column_complex() { - let result = common::test_translation("select_composite_column_complex").unwrap(); +#[tokio::test] +async fn select_composite_column_complex() { + let result = common::test_translation("select_composite_column_complex") + .await + .unwrap(); insta::assert_snapshot!(result); } -#[test] -fn select_composite_variable_simple() { - let result = common::test_translation("select_composite_variable_simple").unwrap(); +#[tokio::test] +async fn select_composite_variable_simple() { + let result = common::test_translation("select_composite_variable_simple") + .await + .unwrap(); insta::assert_snapshot!(result); } -#[test] -fn select_composite_variable_complex() { - let result = common::test_translation("select_composite_variable_complex").unwrap(); +#[tokio::test] +async fn select_composite_variable_complex() { + let result = common::test_translation("select_composite_variable_complex") + .await + .unwrap(); insta::assert_snapshot!(result); } -#[test] -fn select_nested_column_simple() { - let result = common::test_translation("select_nested_column_simple").unwrap(); +#[tokio::test] +async fn select_nested_column_simple() { + let result = common::test_translation("select_nested_column_simple") + .await + .unwrap(); insta::assert_snapshot!(result); } -#[test] -fn select_nested_column_complex() { - let result = common::test_translation("select_nested_column_complex").unwrap(); +#[tokio::test] +async fn select_nested_column_complex() { + let result = common::test_translation("select_nested_column_complex") + .await + .unwrap(); insta::assert_snapshot!(result); } -#[test] -fn select_array_column_reverse() { - let result = common::test_translation("select_array_column_reverse").unwrap(); +#[tokio::test] +async fn select_array_column_reverse() { + let result = common::test_translation("select_array_column_reverse") + .await + .unwrap(); insta::assert_snapshot!(result); } -#[test] -fn select_where_album_id_equals_self_nested_object_relationship() { +#[tokio::test] +async fn select_where_album_id_equals_self_nested_object_relationship() { let result = common::test_translation("select_where_album_id_equals_self_nested_object_relationship") + .await .unwrap(); insta::assert_snapshot!(result); } -#[test] -fn it_converts_select_with_limit() { - let result = common::test_translation("select_with_limit").unwrap(); +#[tokio::test] +async fn it_converts_select_with_limit() { + let result = common::test_translation("select_with_limit").await.unwrap(); insta::assert_snapshot!(result); } -#[test] -fn it_select_where_string() { - let result = common::test_translation("select_where_string").unwrap(); +#[tokio::test] +async fn it_select_where_string() { + let result = common::test_translation("select_where_string") + .await + .unwrap(); insta::assert_snapshot!(result); } -#[test] -fn it_select_where_not_null() { - let result = common::test_translation("select_where_not_null").unwrap(); +#[tokio::test] +async fn it_select_where_not_null() { + let result = common::test_translation("select_where_not_null") + .await + .unwrap(); insta::assert_snapshot!(result); } -#[test] -fn it_select_where_prefix_function() { - let result = common::test_translation("select_where_prefix_function").unwrap(); +#[tokio::test] +async fn it_select_where_prefix_function() { + let result = common::test_translation("select_where_prefix_function") + .await + .unwrap(); insta::assert_snapshot!(result); } -#[test] -fn it_select_where_in_variable() { - let result = common::test_translation("select_where_in_variable").unwrap(); +#[tokio::test] +async fn it_select_where_in_variable() { + let result = common::test_translation("select_where_in_variable") + .await + .unwrap(); insta::assert_snapshot!(result); } -#[test] -fn it_select_where_unrelated_exists() { - let result = common::test_translation("select_where_unrelated_exists").unwrap(); +#[tokio::test] +async fn it_select_where_unrelated_exists() { + let result = common::test_translation("select_where_unrelated_exists") + .await + .unwrap(); insta::assert_snapshot!(result); } -#[test] -fn it_select_where_related_exists() { - let result = common::test_translation("select_where_related_exists").unwrap(); +#[tokio::test] +async fn it_select_where_related_exists() { + let result = common::test_translation("select_where_related_exists") + .await + .unwrap(); insta::assert_snapshot!(result); } -#[test] -fn select_where_array_relationship() { - let result = common::test_translation("select_where_array_relationship").unwrap(); +#[tokio::test] +async fn select_where_array_relationship() { + let result = common::test_translation("select_where_array_relationship") + .await + .unwrap(); insta::assert_snapshot!(result); } -#[test] -fn it_aggregate_count_albums() { - let result = common::test_translation("aggregate_count_albums").unwrap(); +#[tokio::test] +async fn it_aggregate_count_albums() { + let result = common::test_translation("aggregate_count_albums") + .await + .unwrap(); insta::assert_snapshot!(result); } -#[test] -fn it_aggregate_distinct_albums() { - let result = common::test_translation("aggregate_distinct_albums").unwrap(); +#[tokio::test] +async fn it_aggregate_distinct_albums() { + let result = common::test_translation("aggregate_distinct_albums") + .await + .unwrap(); insta::assert_snapshot!(result); } -#[test] -fn it_aggregate_function_albums() { - let result = common::test_translation("aggregate_function_albums").unwrap(); +#[tokio::test] +async fn it_aggregate_function_albums() { + let result = common::test_translation("aggregate_function_albums") + .await + .unwrap(); insta::assert_snapshot!(result); } -#[test] -fn it_simple_array_relationship() { - let result = common::test_translation("simple_array_relationship").unwrap(); +#[tokio::test] +async fn it_simple_array_relationship() { + let result = common::test_translation("simple_array_relationship") + .await + .unwrap(); insta::assert_snapshot!(result); } -#[test] -fn it_simple_object_relationship() { - let result = common::test_translation("simple_object_relationship").unwrap(); +#[tokio::test] +async fn it_simple_object_relationship() { + let result = common::test_translation("simple_object_relationship") + .await + .unwrap(); insta::assert_snapshot!(result); } -#[test] -fn nested_array_relationships() { - let result = common::test_translation("nested_array_relationships").unwrap(); +#[tokio::test] +async fn nested_array_relationships() { + let result = common::test_translation("nested_array_relationships") + .await + .unwrap(); insta::assert_snapshot!(result); } -#[test] -fn nested_aggregates() { - let result = common::test_translation("nested_aggregates").unwrap(); +#[tokio::test] +async fn nested_aggregates() { + let result = common::test_translation("nested_aggregates").await.unwrap(); insta::assert_snapshot!(result); } -#[test] -fn dup_array_relationship() { - let result = common::test_translation("dup_array_relationship").unwrap(); +#[tokio::test] +async fn dup_array_relationship() { + let result = common::test_translation("dup_array_relationship") + .await + .unwrap(); insta::assert_snapshot!(result); } -#[test] -fn nested_recursive_relationship() { - let result = common::test_translation("nested_recursive_relationship").unwrap(); +#[tokio::test] +async fn nested_recursive_relationship() { + let result = common::test_translation("nested_recursive_relationship") + .await + .unwrap(); insta::assert_snapshot!(result); } -#[test] -fn very_nested_recursive_relationship() { - let result = common::test_translation("very_nested_recursive_relationship").unwrap(); +#[tokio::test] +async fn very_nested_recursive_relationship() { + let result = common::test_translation("very_nested_recursive_relationship") + .await + .unwrap(); insta::assert_snapshot!(result); } -#[test] -fn sorting_by_relationship_column() { - let result = common::test_translation("sorting_by_relationship_column").unwrap(); +#[tokio::test] +async fn sorting_by_relationship_column() { + let result = common::test_translation("sorting_by_relationship_column") + .await + .unwrap(); insta::assert_snapshot!(result); } -#[test] -fn sorting_by_nested_relationship_column() { - let result = common::test_translation("sorting_by_nested_relationship_column").unwrap(); +#[tokio::test] +async fn sorting_by_nested_relationship_column() { + let result = common::test_translation("sorting_by_nested_relationship_column") + .await + .unwrap(); insta::assert_snapshot!(result); } -#[test] -fn sorting_by_nested_relationship_column_with_predicate() { - let result = - common::test_translation("sorting_by_nested_relationship_column_with_predicate").unwrap(); +#[tokio::test] +async fn sorting_by_nested_relationship_column_with_predicate() { + let result = common::test_translation("sorting_by_nested_relationship_column_with_predicate") + .await + .unwrap(); insta::assert_snapshot!(result); } -#[test] -fn sorting_by_recursive_relationship_column() { - let result = common::test_translation("sorting_by_recursive_relationship_column").unwrap(); +#[tokio::test] +async fn sorting_by_recursive_relationship_column() { + let result = common::test_translation("sorting_by_recursive_relationship_column") + .await + .unwrap(); insta::assert_snapshot!(result); } -#[test] -fn sorting_by_relationship_count() { - let result = common::test_translation("sorting_by_relationship_count").unwrap(); +#[tokio::test] +async fn sorting_by_relationship_count() { + let result = common::test_translation("sorting_by_relationship_count") + .await + .unwrap(); insta::assert_snapshot!(result); } -#[test] -fn sorting_by_nested_relationship_count() { - let result = common::test_translation("sorting_by_nested_relationship_count").unwrap(); +#[tokio::test] +async fn sorting_by_nested_relationship_count() { + let result = common::test_translation("sorting_by_nested_relationship_count") + .await + .unwrap(); insta::assert_snapshot!(result); } -#[test] -fn sorting_by_relationship_count_with_predicate() { - let result = common::test_translation("sorting_by_relationship_count_with_predicate").unwrap(); +#[tokio::test] +async fn sorting_by_relationship_count_with_predicate() { + let result = common::test_translation("sorting_by_relationship_count_with_predicate") + .await + .unwrap(); insta::assert_snapshot!(result); } -#[test] -fn select_track_order_by_artist_id_and_album_title() { - let result = - common::test_translation("select_track_order_by_artist_id_and_album_title").unwrap(); +#[tokio::test] +async fn select_track_order_by_artist_id_and_album_title() { + let result = common::test_translation("select_track_order_by_artist_id_and_album_title") + .await + .unwrap(); insta::assert_snapshot!(result); } mod negative_tests { use crate::common; - #[test] - fn sorting_by_no_relationship_aggregate() { + #[tokio::test] + async fn sorting_by_no_relationship_aggregate() { let result = common::test_translation("sorting_by_no_relationship_aggregate") + .await .expect_err("Expected error"); insta::assert_snapshot!(result.to_string()); } @@ -252,36 +322,44 @@ mod negative_tests { mod native_queries { use crate::common; - #[test] - fn select_artist() { - let result = common::test_translation("native_queries/select_artist").unwrap(); + #[tokio::test] + async fn select_artist() { + let result = common::test_translation("native_queries/select_artist") + .await + .unwrap(); insta::assert_snapshot!(result); } - #[test] - fn select_artist_by_id() { - let result = common::test_translation("native_queries/select_artist_by_id").unwrap(); + #[tokio::test] + async fn select_artist_by_id() { + let result = common::test_translation("native_queries/select_artist_by_id") + .await + .unwrap(); insta::assert_snapshot!(result); } - #[test] - fn select_artist_by_name() { - let result = common::test_translation("native_queries/select_artist_by_name").unwrap(); + #[tokio::test] + async fn select_artist_by_name() { + let result = common::test_translation("native_queries/select_artist_by_name") + .await + .unwrap(); insta::assert_snapshot!(result); } - #[test] - fn select_artist_with_album_by_title() { - let result = - common::test_translation("native_queries/select_artist_with_album_by_title").unwrap(); + #[tokio::test] + async fn select_artist_with_album_by_title() { + let result = common::test_translation("native_queries/select_artist_with_album_by_title") + .await + .unwrap(); insta::assert_snapshot!(result); } - #[test] - fn select_artist_with_album_by_title_relationship_arguments() { + #[tokio::test] + async fn select_artist_with_album_by_title_relationship_arguments() { let result = common::test_translation( "native_queries/select_artist_with_album_by_title_relationship_arguments", ) + .await .unwrap(); insta::assert_snapshot!(result); } @@ -290,15 +368,19 @@ mod native_queries { mod types { use crate::common; - #[test] - fn select_types_on_comparisons() { - let result = common::test_translation("values/select_types_on_comparisons").unwrap(); + #[tokio::test] + async fn select_types_on_comparisons() { + let result = common::test_translation("values/select_types_on_comparisons") + .await + .unwrap(); insta::assert_snapshot!(result); } - #[test] - fn select_types_on_native_queries() { - let result = common::test_translation("values/select_types_on_native_queries").unwrap(); + #[tokio::test] + async fn select_types_on_native_queries() { + let result = common::test_translation("values/select_types_on_native_queries") + .await + .unwrap(); insta::assert_snapshot!(result); } } @@ -308,17 +390,19 @@ mod mutations { use crate::common; - #[test] - fn simple() { - let result = - common::test_mutation_translation(IsolationLevel::default(), "simple").unwrap(); + #[tokio::test] + async fn simple() { + let result = common::test_mutation_translation(IsolationLevel::default(), "simple") + .await + .unwrap(); insta::assert_snapshot!(result); } - #[test] - fn v1_insert() { - let result = - common::test_mutation_translation(IsolationLevel::default(), "v1_insert").unwrap(); + #[tokio::test] + async fn v1_insert() { + let result = common::test_mutation_translation(IsolationLevel::default(), "v1_insert") + .await + .unwrap(); insta::assert_snapshot!(result); } } diff --git a/crates/tests/databases-tests/Cargo.toml b/crates/tests/databases-tests/Cargo.toml index bfe6f1b8d..1fc7cc944 100644 --- a/crates/tests/databases-tests/Cargo.toml +++ b/crates/tests/databases-tests/Cargo.toml @@ -23,14 +23,11 @@ citus = [] postgres = [] [dependencies] -openapi-generator = { path = "../../documentation/openapi" } ndc-postgres = { path = "../../connectors/ndc-postgres" } ndc-postgres-configuration = { path = "../../configuration" } tests-common = { path = "../tests-common" } axum = "0.6.20" insta = { version = "1.38.0", features = ["json"] } -schemars = { version = "0.8.17", features = ["smol_str", "preserve_order"] } -serde_json = "1.0.116" test-each = "0.2.1" tokio = { version = "1.37.0", features = ["full"] } diff --git a/crates/tests/databases-tests/src/citus/configuration_tests.rs b/crates/tests/databases-tests/src/citus/configuration_tests.rs deleted file mode 100644 index 2d4454a70..000000000 --- a/crates/tests/databases-tests/src/citus/configuration_tests.rs +++ /dev/null @@ -1,27 +0,0 @@ -//! Tests that configuration generation has not changed. -//! -//! If you have changed it intentionally, run `just generate-configuration`. - -#![cfg(test)] - -use super::common; -use tests_common::common_tests; - -#[tokio::test] -async fn test_configure_is_idempotent() { - common_tests::configuration_v3_tests::configure_is_idempotent( - common::CONNECTION_URI, - common::CHINOOK_NDC_METADATA_PATH, - ) - .await - .unwrap(); -} - -#[tokio::test] -async fn configuration_conforms_to_the_schema() { - common_tests::configuration_v3_tests::configuration_conforms_to_the_schema( - common::CHINOOK_NDC_METADATA_PATH, - ) - .await - .unwrap(); -} diff --git a/crates/tests/databases-tests/src/citus/mod.rs b/crates/tests/databases-tests/src/citus/mod.rs index 7d7112057..d036e156e 100644 --- a/crates/tests/databases-tests/src/citus/mod.rs +++ b/crates/tests/databases-tests/src/citus/mod.rs @@ -1,5 +1,4 @@ pub mod common; -pub mod configuration_tests; pub mod explain_tests; pub mod ndc_tests; pub mod query_tests; diff --git a/crates/tests/databases-tests/src/cockroach/configuration_tests.rs b/crates/tests/databases-tests/src/cockroach/configuration_tests.rs deleted file mode 100644 index 2d4454a70..000000000 --- a/crates/tests/databases-tests/src/cockroach/configuration_tests.rs +++ /dev/null @@ -1,27 +0,0 @@ -//! Tests that configuration generation has not changed. -//! -//! If you have changed it intentionally, run `just generate-configuration`. - -#![cfg(test)] - -use super::common; -use tests_common::common_tests; - -#[tokio::test] -async fn test_configure_is_idempotent() { - common_tests::configuration_v3_tests::configure_is_idempotent( - common::CONNECTION_URI, - common::CHINOOK_NDC_METADATA_PATH, - ) - .await - .unwrap(); -} - -#[tokio::test] -async fn configuration_conforms_to_the_schema() { - common_tests::configuration_v3_tests::configuration_conforms_to_the_schema( - common::CHINOOK_NDC_METADATA_PATH, - ) - .await - .unwrap(); -} diff --git a/crates/tests/databases-tests/src/cockroach/mod.rs b/crates/tests/databases-tests/src/cockroach/mod.rs index 7d7112057..d036e156e 100644 --- a/crates/tests/databases-tests/src/cockroach/mod.rs +++ b/crates/tests/databases-tests/src/cockroach/mod.rs @@ -1,5 +1,4 @@ pub mod common; -pub mod configuration_tests; pub mod explain_tests; pub mod ndc_tests; pub mod query_tests; diff --git a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__basic__select_composite_column_simple.snap b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__basic__select_composite_column_simple.snap deleted file mode 100644 index 9d6a1f661..000000000 --- a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__basic__select_composite_column_simple.snap +++ /dev/null @@ -1,16 +0,0 @@ ---- -source: crates/tests/databases-tests/src/cockroach/query_tests.rs -expression: result ---- -[ - { - "rows": [ - { - "result": { - "address_line_1": "Somstreet 159", - "address_line_2": "Second door to the right" - } - } - ] - } -] diff --git a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__basic__select_composite_variable_simple.snap b/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__basic__select_composite_variable_simple.snap deleted file mode 100644 index fdf6a35d9..000000000 --- a/crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__basic__select_composite_variable_simple.snap +++ /dev/null @@ -1,26 +0,0 @@ ---- -source: crates/tests/databases-tests/src/cockroach/query_tests.rs -expression: result ---- -[ - { - "rows": [ - { - "result": { - "address_line_1": "Somstreet 159", - "address_line_2": "Second door to the right" - } - } - ] - }, - { - "rows": [ - { - "result": { - "address_line_1": "Somstreet 159", - "address_line_2": "Second door to the right" - } - } - ] - } -] diff --git a/crates/tests/databases-tests/src/ndc_metadata_snapshot_tests.rs b/crates/tests/databases-tests/src/ndc_metadata_snapshot_tests.rs index 60e46a8a1..6985088c2 100644 --- a/crates/tests/databases-tests/src/ndc_metadata_snapshot_tests.rs +++ b/crates/tests/databases-tests/src/ndc_metadata_snapshot_tests.rs @@ -1,24 +1,19 @@ #![cfg(test)] -use std::fs; use std::path::PathBuf; // each time we run `just generate-configuration` we save the old Postgres NDC configuration // directory in `static/ndc-metadata-snapshots`. This test parses each snapshot to ensure we are // still able to understand old versions -#[test_each::path( - glob = "static/ndc-metadata-snapshots/*/configuration.json", - name(segments = 2) -)] +#[test_each::path(glob = "static/ndc-metadata-snapshots/*", name(segments = 2))] fn test_snapshot(ndc_metadata_path: PathBuf) { - let file = fs::File::open(ndc_metadata_path).expect("fs::File::open"); + tokio::runtime::Builder::new_multi_thread() + .build() + .unwrap() + .block_on(async { + let ndc_metadata = + ndc_postgres_configuration::parse_configuration(ndc_metadata_path).await; - let ndc_metadata_json_value: serde_json::Value = - serde_json::from_reader(file).expect("serde_json::from_reader"); - - // TODO: have this respect the version-agnostic configuration interface? - serde_json::from_value::( - ndc_metadata_json_value.clone(), - ) - .expect("Unable to deserialize as RawConfiguration"); + ndc_metadata.expect("Unable to deserialize as RawConfiguration"); + }); } diff --git a/crates/tests/databases-tests/src/postgres/configuration_tests.rs b/crates/tests/databases-tests/src/postgres/configuration_tests.rs deleted file mode 100644 index 1ca488971..000000000 --- a/crates/tests/databases-tests/src/postgres/configuration_tests.rs +++ /dev/null @@ -1,69 +0,0 @@ -//! Tests that configuration generation has not changed. -//! -//! If you have changed it intentionally, run `just generate-configuration`. -//! -//! The github CI setup runs these tests subject to the filtering logic in -//! '.github/test-configuration.json'. Naming a test with the prefix 'postgres_current_only` will -//! ensure they only run on the latest version of postgres being tested. This is necessary because -//! they rely on supporting data (the chinook NDC metadata configuration) which we maintain only for -//! the latest version. - -#![cfg(test)] - -use super::common; -use tests_common::common_tests; - -#[tokio::test] -async fn get_configuration_schema() { - // TODO: have this respect the version-agnostic configuration interface? - let schema = schemars::schema_for!(ndc_postgres_configuration::version3::RawConfiguration); - insta::assert_json_snapshot!(schema); -} - -// version 3 tests - -#[tokio::test] -async fn postgres_current_only_broken_metadata_is_up_to_date() { - common_tests::configuration_v3_tests::configure_is_idempotent( - common::EMPTY_CONNECTION_URI, - common::BROKEN_QUERIES_NDC_METADATA_PATH, - ) - .await - .unwrap(); -} - -#[tokio::test] -async fn postgres_current_only_configure_v3_is_idempotent() { - common_tests::configuration_v3_tests::configure_is_idempotent( - common::CONNECTION_URI, - common::CHINOOK_NDC_METADATA_PATH, - ) - .await - .unwrap(); -} - -#[tokio::test] -async fn configuration_v3_conforms_to_the_schema() { - common_tests::configuration_v3_tests::configuration_conforms_to_the_schema( - common::CHINOOK_NDC_METADATA_PATH, - ) - .await - .unwrap(); -} - -#[tokio::test] -async fn postgres_current_only_configure_v3_initial_configuration_is_unchanged() { - let default_configuration = - common_tests::configuration_v3_tests::configure_initial_configuration_is_unchanged( - common::CONNECTION_URI, - ) - .await; - - insta::assert_json_snapshot!(default_configuration); -} - -#[tokio::test] -async fn get_rawconfiguration_v3_schema() { - let schema = schemars::schema_for!(ndc_postgres_configuration::version3::RawConfiguration); - insta::assert_json_snapshot!(schema); -} diff --git a/crates/tests/databases-tests/src/postgres/mod.rs b/crates/tests/databases-tests/src/postgres/mod.rs index 39cd9f9dd..4c2413270 100644 --- a/crates/tests/databases-tests/src/postgres/mod.rs +++ b/crates/tests/databases-tests/src/postgres/mod.rs @@ -1,8 +1,6 @@ pub mod common; -pub mod configuration_tests; pub mod explain_tests; pub mod mutation_tests; pub mod ndc_tests; -pub mod openapi_tests; pub mod query_tests; pub mod schema_tests; diff --git a/crates/tests/databases-tests/src/postgres/openapi_tests.rs b/crates/tests/databases-tests/src/postgres/openapi_tests.rs deleted file mode 100644 index 2eb739532..000000000 --- a/crates/tests/databases-tests/src/postgres/openapi_tests.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[cfg(test)] -mod openapi { - #[tokio::test] - async fn up_to_date_generated_schema() { - let generated_schema = openapi_generator::generator::generate_schema(); - let generated_schema_json = serde_json::to_value(&generated_schema).unwrap(); - - insta::assert_json_snapshot!(generated_schema_json); - } -} diff --git a/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__configuration_tests__get_rawconfiguration_v3_schema.snap b/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__configuration_tests__get_rawconfiguration_v3_schema.snap deleted file mode 100644 index 4f0b82c75..000000000 --- a/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__configuration_tests__get_rawconfiguration_v3_schema.snap +++ /dev/null @@ -1,1495 +0,0 @@ ---- -source: crates/tests/databases-tests/src/postgres/configuration_tests.rs -expression: schema ---- -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "RawConfiguration", - "description": "Initial configuration, just enough to connect to a database and elaborate a full 'Configuration'.", - "type": "object", - "required": [ - "connectionSettings", - "version" - ], - "properties": { - "version": { - "$ref": "#/definitions/Version" - }, - "$schema": { - "description": "Jsonschema of the configuration format.", - "default": null, - "type": [ - "string", - "null" - ] - }, - "connectionSettings": { - "description": "Database connection settings.", - "allOf": [ - { - "$ref": "#/definitions/DatabaseConnectionSettings" - } - ] - }, - "metadata": { - "description": "Connector metadata.", - "default": { - "tables": {}, - "compositeTypes": {}, - "nativeQueries": {}, - "aggregateFunctions": {}, - "comparisonOperators": {}, - "typeRepresentations": {} - }, - "allOf": [ - { - "$ref": "#/definitions/Metadata" - } - ] - }, - "introspectionOptions": { - "description": "Database introspection options.", - "default": { - "excludedSchemas": [ - "information_schema", - "pg_catalog", - "tiger", - "crdb_internal", - "columnar", - "columnar_internal" - ], - "unqualifiedSchemasForTables": [ - "public" - ], - "unqualifiedSchemasForTypesAndProcedures": [ - "public", - "pg_catalog", - "tiger", - "auth", - "pgsodium" - ], - "comparisonOperatorMapping": [ - { - "operatorName": "=", - "exposedName": "_eq", - "operatorKind": "equal" - }, - { - "operatorName": "<=", - "exposedName": "_lte", - "operatorKind": "custom" - }, - { - "operatorName": ">", - "exposedName": "_gt", - "operatorKind": "custom" - }, - { - "operatorName": ">=", - "exposedName": "_gte", - "operatorKind": "custom" - }, - { - "operatorName": "<", - "exposedName": "_lt", - "operatorKind": "custom" - }, - { - "operatorName": "!=", - "exposedName": "_neq", - "operatorKind": "custom" - }, - { - "operatorName": "LIKE", - "exposedName": "_like", - "operatorKind": "custom" - }, - { - "operatorName": "NOT LIKE", - "exposedName": "_nlike", - "operatorKind": "custom" - }, - { - "operatorName": "ILIKE", - "exposedName": "_ilike", - "operatorKind": "custom" - }, - { - "operatorName": "NOT ILIKE", - "exposedName": "_nilike", - "operatorKind": "custom" - }, - { - "operatorName": "SIMILAR TO", - "exposedName": "_similar", - "operatorKind": "custom" - }, - { - "operatorName": "NOT SIMILAR TO", - "exposedName": "_nsimilar", - "operatorKind": "custom" - }, - { - "operatorName": "<>", - "exposedName": "_neq", - "operatorKind": "custom" - }, - { - "operatorName": "~~", - "exposedName": "_like", - "operatorKind": "custom" - }, - { - "operatorName": "!~~", - "exposedName": "_nlike", - "operatorKind": "custom" - }, - { - "operatorName": "~~*", - "exposedName": "_ilike", - "operatorKind": "custom" - }, - { - "operatorName": "!~~*", - "exposedName": "_nilike", - "operatorKind": "custom" - }, - { - "operatorName": "~", - "exposedName": "_regex", - "operatorKind": "custom" - }, - { - "operatorName": "!~", - "exposedName": "_nregex", - "operatorKind": "custom" - }, - { - "operatorName": "~*", - "exposedName": "_iregex", - "operatorKind": "custom" - }, - { - "operatorName": "!~*", - "exposedName": "_niregex", - "operatorKind": "custom" - } - ], - "introspectPrefixFunctionComparisonOperators": [ - "box_above", - "box_below", - "box_contain", - "box_contain_pt", - "box_contained", - "box_left", - "box_overabove", - "box_overbelow", - "box_overlap", - "box_overleft", - "box_overright", - "box_right", - "box_same", - "circle_above", - "circle_below", - "circle_contain", - "circle_contain_pt", - "circle_contained", - "circle_left", - "circle_overabove", - "circle_overbelow", - "circle_overlap", - "circle_overleft", - "circle_overright", - "circle_right", - "circle_same", - "contains_2d", - "equals", - "geography_overlaps", - "geometry_above", - "geometry_below", - "geometry_contained_3d", - "geometry_contains", - "geometry_contains_3d", - "geometry_contains_nd", - "geometry_left", - "geometry_overabove", - "geometry_overbelow", - "geometry_overlaps", - "geometry_overlaps_3d", - "geometry_overlaps_nd", - "geometry_overleft", - "geometry_overright", - "geometry_right", - "geometry_same", - "geometry_same_3d", - "geometry_same_nd", - "geometry_within", - "geometry_within_nd", - "inet_same_family", - "inter_lb", - "inter_sb", - "inter_sl", - "is_contained_2d", - "ishorizontal", - "isparallel", - "isperp", - "isvertical", - "jsonb_contained", - "jsonb_contains", - "jsonb_exists", - "jsonb_path_exists_opr", - "jsonb_path_match_opr", - "line_intersect", - "line_parallel", - "line_perp", - "lseg_intersect", - "lseg_parallel", - "lseg_perp", - "network_overlap", - "network_sub", - "network_sup", - "on_pb", - "on_pl", - "on_ppath", - "on_ps", - "on_sb", - "on_sl", - "overlaps_2d", - "path_contain_pt", - "path_inter", - "point_above", - "point_below", - "point_horiz", - "point_left", - "point_right", - "point_vert", - "poly_above", - "poly_below", - "poly_contain", - "poly_contain_pt", - "poly_contained", - "poly_left", - "poly_overabove", - "poly_overbelow", - "poly_overlap", - "poly_overleft", - "poly_overright", - "poly_right", - "poly_same", - "pt_contained_poly", - "st_3dintersects", - "st_contains", - "st_containsproperly", - "st_coveredby", - "st_covers", - "st_crosses", - "st_disjoint", - "st_equals", - "st_intersects", - "st_isvalid", - "st_orderingequals", - "st_overlaps", - "st_relatematch", - "st_touches", - "st_within", - "starts_with", - "ts_match_qv", - "ts_match_tq", - "ts_match_tt", - "ts_match_vq", - "tsq_mcontained", - "tsq_mcontains", - "xmlexists", - "xmlvalidate", - "xpath_exists" - ] - }, - "allOf": [ - { - "$ref": "#/definitions/IntrospectionOptions" - } - ] - }, - "mutationsVersion": { - "description": "Which version of the generated mutation procedures to include in the schema response", - "default": null, - "anyOf": [ - { - "$ref": "#/definitions/MutationsVersion" - }, - { - "type": "null" - } - ] - } - }, - "definitions": { - "Version": { - "type": "string", - "enum": [ - "3" - ] - }, - "DatabaseConnectionSettings": { - "description": "Database connection settings.", - "type": "object", - "required": [ - "connectionUri" - ], - "properties": { - "connectionUri": { - "description": "Connection string for a Postgres-compatible database.", - "allOf": [ - { - "$ref": "#/definitions/ConnectionUri" - } - ] - }, - "poolSettings": { - "description": "Connection pool settings.", - "default": { - "maxConnections": 50, - "poolTimeout": 30, - "idleTimeout": 180, - "checkConnectionAfterIdle": 60, - "connectionLifetime": 600 - }, - "allOf": [ - { - "$ref": "#/definitions/PoolSettings" - } - ] - }, - "isolationLevel": { - "description": "Query isolation level.", - "default": "ReadCommitted", - "allOf": [ - { - "$ref": "#/definitions/IsolationLevel" - } - ] - } - } - }, - "ConnectionUri": { - "$ref": "#/definitions/Secret" - }, - "Secret": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "object", - "required": [ - "variable" - ], - "properties": { - "variable": { - "$ref": "#/definitions/Variable" - } - } - } - ] - }, - "Variable": { - "description": "The name of an an environment variable.", - "type": "string" - }, - "PoolSettings": { - "description": "Settings for the PostgreSQL connection pool", - "type": "object", - "properties": { - "maxConnections": { - "description": "maximum number of pool connections", - "default": 50, - "type": "integer", - "format": "uint32", - "minimum": 0.0 - }, - "poolTimeout": { - "description": "timeout for acquiring a connection from the pool (seconds)", - "default": 30, - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "idleTimeout": { - "description": "idle timeout for releasing a connection from the pool (seconds)", - "default": 180, - "type": [ - "integer", - "null" - ], - "format": "uint64", - "minimum": 0.0 - }, - "checkConnectionAfterIdle": { - "description": "check the connection is alive after being idle for N seconds. Set to null to always check.", - "default": 60, - "type": [ - "integer", - "null" - ], - "format": "uint64", - "minimum": 0.0 - }, - "connectionLifetime": { - "description": "maximum lifetime for an individual connection (seconds)", - "default": 600, - "type": [ - "integer", - "null" - ], - "format": "uint64", - "minimum": 0.0 - } - } - }, - "IsolationLevel": { - "description": "The isolation level of the transaction in which a query is executed.", - "oneOf": [ - { - "description": "Prevents reading data from another uncommitted transaction.", - "type": "string", - "enum": [ - "ReadCommitted" - ] - }, - { - "description": "Reading the same data twice is guaranteed to return the same result.", - "type": "string", - "enum": [ - "RepeatableRead" - ] - }, - { - "description": "Concurrent transactions behave identically to serializing them one at a time.", - "type": "string", - "enum": [ - "Serializable" - ] - } - ] - }, - "Metadata": { - "description": "Metadata information.", - "type": "object", - "properties": { - "tables": { - "default": {}, - "allOf": [ - { - "$ref": "#/definitions/TablesInfo" - } - ] - }, - "compositeTypes": { - "default": {}, - "allOf": [ - { - "$ref": "#/definitions/CompositeTypes" - } - ] - }, - "nativeQueries": { - "default": {}, - "allOf": [ - { - "$ref": "#/definitions/NativeQueries" - } - ] - }, - "aggregateFunctions": { - "default": {}, - "allOf": [ - { - "$ref": "#/definitions/AggregateFunctions" - } - ] - }, - "comparisonOperators": { - "default": {}, - "allOf": [ - { - "$ref": "#/definitions/ComparisonOperators" - } - ] - }, - "typeRepresentations": { - "default": {}, - "allOf": [ - { - "$ref": "#/definitions/TypeRepresentations" - } - ] - } - } - }, - "TablesInfo": { - "description": "Mapping from a \"table\" name to its information.", - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/TableInfo" - } - }, - "TableInfo": { - "description": "Information about a database table (or any other kind of relation).", - "type": "object", - "required": [ - "columns", - "schemaName", - "tableName" - ], - "properties": { - "schemaName": { - "type": "string" - }, - "tableName": { - "type": "string" - }, - "columns": { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/ColumnInfo" - } - }, - "uniquenessConstraints": { - "default": {}, - "allOf": [ - { - "$ref": "#/definitions/UniquenessConstraints" - } - ] - }, - "foreignRelations": { - "default": {}, - "allOf": [ - { - "$ref": "#/definitions/ForeignRelations" - } - ] - }, - "description": { - "default": null, - "type": [ - "string", - "null" - ] - } - } - }, - "ColumnInfo": { - "description": "Information about a database column.", - "type": "object", - "required": [ - "name", - "type" - ], - "properties": { - "name": { - "type": "string" - }, - "type": { - "$ref": "#/definitions/Type" - }, - "nullable": { - "default": "nullable", - "allOf": [ - { - "$ref": "#/definitions/Nullable" - } - ] - }, - "hasDefault": { - "$ref": "#/definitions/HasDefault" - }, - "isIdentity": { - "$ref": "#/definitions/IsIdentity" - }, - "isGenerated": { - "$ref": "#/definitions/IsGenerated" - }, - "description": { - "default": null, - "type": [ - "string", - "null" - ] - } - } - }, - "Type": { - "description": "The type of values that a column, field, or argument may take.", - "oneOf": [ - { - "type": "object", - "required": [ - "scalarType" - ], - "properties": { - "scalarType": { - "$ref": "#/definitions/ScalarType" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "compositeType" - ], - "properties": { - "compositeType": { - "type": "string" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "arrayType" - ], - "properties": { - "arrayType": { - "$ref": "#/definitions/Type" - } - }, - "additionalProperties": false - } - ] - }, - "ScalarType": { - "description": "A Scalar Type.", - "type": "string" - }, - "Nullable": { - "description": "Can this column contain null values", - "type": "string", - "enum": [ - "nullable", - "nonNullable" - ] - }, - "HasDefault": { - "description": "Does this column have a default value.", - "type": "string", - "enum": [ - "noDefault", - "hasDefault" - ] - }, - "IsIdentity": { - "description": "Is this column an identity column.", - "type": "string", - "enum": [ - "notIdentity", - "identityByDefault", - "identityAlways" - ] - }, - "IsGenerated": { - "description": "Is this column a generated column.", - "type": "string", - "enum": [ - "notGenerated", - "stored" - ] - }, - "UniquenessConstraints": { - "description": "A mapping from the name of a unique constraint to its value.", - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/UniquenessConstraint" - } - }, - "UniquenessConstraint": { - "description": "The set of columns that make up a uniqueness constraint.", - "type": "array", - "items": { - "type": "string" - }, - "uniqueItems": true - }, - "ForeignRelations": { - "description": "A mapping from the name of a foreign key constraint to its value.", - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/ForeignRelation" - } - }, - "ForeignRelation": { - "description": "A foreign key constraint.", - "type": "object", - "required": [ - "columnMapping", - "foreignTable" - ], - "properties": { - "foreignSchema": { - "type": [ - "string", - "null" - ] - }, - "foreignTable": { - "type": "string" - }, - "columnMapping": { - "type": "object", - "additionalProperties": { - "type": "string" - } - } - } - }, - "CompositeTypes": { - "description": "Map of all known composite types.", - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/CompositeType" - } - }, - "CompositeType": { - "description": "Information about a composite type. These are very similar to tables, but with the crucial difference that composite types do not support constraints (such as NOT NULL).", - "type": "object", - "required": [ - "fields", - "name" - ], - "properties": { - "name": { - "type": "string" - }, - "fields": { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/FieldInfo" - } - }, - "description": { - "default": null, - "type": [ - "string", - "null" - ] - } - } - }, - "FieldInfo": { - "description": "Information about a composite type field.", - "type": "object", - "required": [ - "name", - "type" - ], - "properties": { - "name": { - "type": "string" - }, - "type": { - "$ref": "#/definitions/Type" - }, - "description": { - "default": null, - "type": [ - "string", - "null" - ] - } - } - }, - "NativeQueries": { - "description": "Metadata information of native queries.", - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/NativeQueryInfo" - } - }, - "NativeQueryInfo": { - "description": "Information about a Native Query", - "type": "object", - "required": [ - "columns", - "sql" - ], - "properties": { - "sql": { - "description": "SQL expression to use for the Native Query. We can interpolate values using `{{variable_name}}` syntax, such as `SELECT * FROM authors WHERE name = {{author_name}}`", - "allOf": [ - { - "$ref": "#/definitions/NativeQuerySql" - } - ] - }, - "columns": { - "description": "Columns returned by the Native Query", - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/ReadOnlyColumnInfo" - } - }, - "arguments": { - "description": "Names and types of arguments that can be passed to this Native Query", - "default": {}, - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/ReadOnlyColumnInfo" - } - }, - "description": { - "default": null, - "type": [ - "string", - "null" - ] - }, - "isProcedure": { - "description": "True if this native query mutates the database", - "type": "boolean" - } - } - }, - "NativeQuerySql": { - "description": "Native Query SQL location.", - "anyOf": [ - { - "description": "Refer to an external Native Query SQL file.", - "type": "object", - "required": [ - "file" - ], - "properties": { - "file": { - "description": "Relative path to a sql file.", - "type": "string" - } - } - }, - { - "description": "Inline Native Query SQL string.", - "type": "object", - "required": [ - "inline" - ], - "properties": { - "inline": { - "description": "An inline Native Query SQL string.", - "allOf": [ - { - "$ref": "#/definitions/InlineNativeQuerySql" - } - ] - } - } - }, - { - "$ref": "#/definitions/InlineNativeQuerySql" - } - ] - }, - "InlineNativeQuerySql": { - "type": "string" - }, - "ReadOnlyColumnInfo": { - "description": "Information about a native query column.", - "type": "object", - "required": [ - "name", - "type" - ], - "properties": { - "name": { - "type": "string" - }, - "type": { - "$ref": "#/definitions/Type" - }, - "nullable": { - "default": "nullable", - "allOf": [ - { - "$ref": "#/definitions/Nullable" - } - ] - }, - "description": { - "default": null, - "type": [ - "string", - "null" - ] - } - } - }, - "AggregateFunctions": { - "description": "All supported aggregate functions, grouped by type.", - "type": "object", - "additionalProperties": { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/AggregateFunction" - } - } - }, - "AggregateFunction": { - "type": "object", - "required": [ - "returnType" - ], - "properties": { - "returnType": { - "$ref": "#/definitions/ScalarType" - } - } - }, - "ComparisonOperators": { - "description": "The complete list of supported binary operators for scalar types. Not all of these are supported for every type.", - "type": "object", - "additionalProperties": { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/ComparisonOperator" - } - } - }, - "ComparisonOperator": { - "description": "Represents a postgres binary comparison operator", - "type": "object", - "required": [ - "argumentType", - "operatorKind", - "operatorName" - ], - "properties": { - "operatorName": { - "type": "string" - }, - "operatorKind": { - "$ref": "#/definitions/OperatorKind" - }, - "argumentType": { - "$ref": "#/definitions/ScalarType" - }, - "isInfix": { - "default": true, - "type": "boolean" - } - } - }, - "OperatorKind": { - "description": "Is it a built-in operator, or a custom operator.", - "type": "string", - "enum": [ - "equal", - "in", - "custom" - ] - }, - "TypeRepresentations": { - "description": "Type representation of scalar types, grouped by type.", - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/TypeRepresentation" - } - }, - "TypeRepresentation": { - "description": "Type representation of a scalar type.", - "oneOf": [ - { - "description": "JSON booleans", - "type": "string", - "enum": [ - "boolean" - ] - }, - { - "description": "Any JSON string", - "type": "string", - "enum": [ - "string" - ] - }, - { - "description": "float4", - "type": "string", - "enum": [ - "float32" - ] - }, - { - "description": "float8", - "type": "string", - "enum": [ - "float64" - ] - }, - { - "description": "int2", - "type": "string", - "enum": [ - "int16" - ] - }, - { - "description": "int4", - "type": "string", - "enum": [ - "int32" - ] - }, - { - "description": "int8 as integer", - "type": "string", - "enum": [ - "int64" - ] - }, - { - "description": "int8 as string", - "type": "string", - "enum": [ - "int64AsString" - ] - }, - { - "description": "numeric", - "type": "string", - "enum": [ - "bigDecimal" - ] - }, - { - "description": "numeric as string", - "type": "string", - "enum": [ - "bigDecimalAsString" - ] - }, - { - "description": "timestamp", - "type": "string", - "enum": [ - "timestamp" - ] - }, - { - "description": "timestamp with timezone", - "type": "string", - "enum": [ - "timestamptz" - ] - }, - { - "description": "time", - "type": "string", - "enum": [ - "time" - ] - }, - { - "description": "time with timezone", - "type": "string", - "enum": [ - "timetz" - ] - }, - { - "description": "date", - "type": "string", - "enum": [ - "date" - ] - }, - { - "description": "uuid", - "type": "string", - "enum": [ - "uUID" - ] - }, - { - "description": "geography", - "type": "string", - "enum": [ - "geography" - ] - }, - { - "description": "geometry", - "type": "string", - "enum": [ - "geometry" - ] - }, - { - "description": "Any JSON number", - "type": "string", - "enum": [ - "number" - ] - }, - { - "description": "Any JSON number, with no decimal part", - "type": "string", - "enum": [ - "integer" - ] - }, - { - "description": "An arbitrary json.", - "type": "string", - "enum": [ - "json" - ] - }, - { - "description": "One of the specified string values", - "type": "object", - "required": [ - "enum" - ], - "properties": { - "enum": { - "type": "array", - "items": { - "type": "string" - } - } - }, - "additionalProperties": false - } - ] - }, - "IntrospectionOptions": { - "description": "Options which only influence how the configuration is updated.", - "type": "object", - "properties": { - "excludedSchemas": { - "description": "Schemas which are excluded from introspection. The default setting will exclude the internal schemas of Postgres, Citus, Cockroach, and the PostGIS extension.", - "default": [ - "information_schema", - "pg_catalog", - "tiger", - "crdb_internal", - "columnar", - "columnar_internal" - ], - "type": "array", - "items": { - "type": "string" - } - }, - "unqualifiedSchemasForTables": { - "description": "The names of Tables and Views in these schemas will be returned unqualified. The default setting will set the `public` schema as unqualified.", - "default": [ - "public" - ], - "type": "array", - "items": { - "type": "string" - } - }, - "unqualifiedSchemasForTypesAndProcedures": { - "description": "The types and procedures in these schemas will be returned unqualified.", - "default": [ - "public", - "pg_catalog", - "tiger", - "auth", - "pgsodium" - ], - "type": "array", - "items": { - "type": "string" - } - }, - "comparisonOperatorMapping": { - "description": "The mapping of comparison operator names to apply when updating the configuration", - "default": [ - { - "operatorName": "=", - "exposedName": "_eq", - "operatorKind": "equal" - }, - { - "operatorName": "<=", - "exposedName": "_lte", - "operatorKind": "custom" - }, - { - "operatorName": ">", - "exposedName": "_gt", - "operatorKind": "custom" - }, - { - "operatorName": ">=", - "exposedName": "_gte", - "operatorKind": "custom" - }, - { - "operatorName": "<", - "exposedName": "_lt", - "operatorKind": "custom" - }, - { - "operatorName": "!=", - "exposedName": "_neq", - "operatorKind": "custom" - }, - { - "operatorName": "LIKE", - "exposedName": "_like", - "operatorKind": "custom" - }, - { - "operatorName": "NOT LIKE", - "exposedName": "_nlike", - "operatorKind": "custom" - }, - { - "operatorName": "ILIKE", - "exposedName": "_ilike", - "operatorKind": "custom" - }, - { - "operatorName": "NOT ILIKE", - "exposedName": "_nilike", - "operatorKind": "custom" - }, - { - "operatorName": "SIMILAR TO", - "exposedName": "_similar", - "operatorKind": "custom" - }, - { - "operatorName": "NOT SIMILAR TO", - "exposedName": "_nsimilar", - "operatorKind": "custom" - }, - { - "operatorName": "<>", - "exposedName": "_neq", - "operatorKind": "custom" - }, - { - "operatorName": "~~", - "exposedName": "_like", - "operatorKind": "custom" - }, - { - "operatorName": "!~~", - "exposedName": "_nlike", - "operatorKind": "custom" - }, - { - "operatorName": "~~*", - "exposedName": "_ilike", - "operatorKind": "custom" - }, - { - "operatorName": "!~~*", - "exposedName": "_nilike", - "operatorKind": "custom" - }, - { - "operatorName": "~", - "exposedName": "_regex", - "operatorKind": "custom" - }, - { - "operatorName": "!~", - "exposedName": "_nregex", - "operatorKind": "custom" - }, - { - "operatorName": "~*", - "exposedName": "_iregex", - "operatorKind": "custom" - }, - { - "operatorName": "!~*", - "exposedName": "_niregex", - "operatorKind": "custom" - } - ], - "type": "array", - "items": { - "$ref": "#/definitions/ComparisonOperatorMapping" - } - }, - "introspectPrefixFunctionComparisonOperators": { - "description": "Which prefix functions (i.e., non-infix operators) to generate introspection metadata for.\n\nThis list will accept any boolean-returning function taking two concrete scalar types as arguments.\n\nThe default includes comparisons for various build-in types as well as those of PostGIS.", - "default": [ - "box_above", - "box_below", - "box_contain", - "box_contain_pt", - "box_contained", - "box_left", - "box_overabove", - "box_overbelow", - "box_overlap", - "box_overleft", - "box_overright", - "box_right", - "box_same", - "circle_above", - "circle_below", - "circle_contain", - "circle_contain_pt", - "circle_contained", - "circle_left", - "circle_overabove", - "circle_overbelow", - "circle_overlap", - "circle_overleft", - "circle_overright", - "circle_right", - "circle_same", - "contains_2d", - "equals", - "geography_overlaps", - "geometry_above", - "geometry_below", - "geometry_contained_3d", - "geometry_contains", - "geometry_contains_3d", - "geometry_contains_nd", - "geometry_left", - "geometry_overabove", - "geometry_overbelow", - "geometry_overlaps", - "geometry_overlaps_3d", - "geometry_overlaps_nd", - "geometry_overleft", - "geometry_overright", - "geometry_right", - "geometry_same", - "geometry_same_3d", - "geometry_same_nd", - "geometry_within", - "geometry_within_nd", - "inet_same_family", - "inter_lb", - "inter_sb", - "inter_sl", - "is_contained_2d", - "ishorizontal", - "isparallel", - "isperp", - "isvertical", - "jsonb_contained", - "jsonb_contains", - "jsonb_exists", - "jsonb_path_exists_opr", - "jsonb_path_match_opr", - "line_intersect", - "line_parallel", - "line_perp", - "lseg_intersect", - "lseg_parallel", - "lseg_perp", - "network_overlap", - "network_sub", - "network_sup", - "on_pb", - "on_pl", - "on_ppath", - "on_ps", - "on_sb", - "on_sl", - "overlaps_2d", - "path_contain_pt", - "path_inter", - "point_above", - "point_below", - "point_horiz", - "point_left", - "point_right", - "point_vert", - "poly_above", - "poly_below", - "poly_contain", - "poly_contain_pt", - "poly_contained", - "poly_left", - "poly_overabove", - "poly_overbelow", - "poly_overlap", - "poly_overleft", - "poly_overright", - "poly_right", - "poly_same", - "pt_contained_poly", - "st_3dintersects", - "st_contains", - "st_containsproperly", - "st_coveredby", - "st_covers", - "st_crosses", - "st_disjoint", - "st_equals", - "st_intersects", - "st_isvalid", - "st_orderingequals", - "st_overlaps", - "st_relatematch", - "st_touches", - "st_within", - "starts_with", - "ts_match_qv", - "ts_match_tq", - "ts_match_tt", - "ts_match_vq", - "tsq_mcontained", - "tsq_mcontains", - "xmlexists", - "xmlvalidate", - "xpath_exists" - ], - "type": "array", - "items": { - "type": "string" - } - } - } - }, - "ComparisonOperatorMapping": { - "description": "Define the names that comparison operators will be exposed as by the automatic introspection.", - "type": "object", - "required": [ - "exposedName", - "operatorKind", - "operatorName" - ], - "properties": { - "operatorName": { - "description": "The name of the operator as defined by the database", - "type": "string" - }, - "exposedName": { - "description": "The name the operator will appear under in the exposed API", - "type": "string" - }, - "operatorKind": { - "description": "Equal, In or Custom.", - "allOf": [ - { - "$ref": "#/definitions/OperatorKind" - } - ] - } - } - }, - "MutationsVersion": { - "description": "Which version of the generated mutations will be included in the schema", - "type": "string", - "enum": [ - "v1", - "veryExperimentalWip" - ] - } - } -} diff --git a/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__openapi_tests__openapi__up_to_date_generated_schema.snap b/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__openapi_tests__openapi__up_to_date_generated_schema.snap deleted file mode 100644 index 1ec7d954e..000000000 --- a/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__openapi_tests__openapi__up_to_date_generated_schema.snap +++ /dev/null @@ -1,1471 +0,0 @@ ---- -source: crates/tests/databases-tests/src/postgres/openapi_tests.rs -expression: generated_schema_json ---- -{ - "$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema", - "title": "RawConfiguration", - "description": "Initial configuration, just enough to connect to a database and elaborate a full 'Configuration'.", - "type": "object", - "required": [ - "connectionSettings", - "version" - ], - "properties": { - "version": { - "$ref": "#/components/schemas/Version" - }, - "$schema": { - "description": "Jsonschema of the configuration format.", - "default": null, - "type": "string", - "nullable": true - }, - "connectionSettings": { - "description": "Database connection settings.", - "allOf": [ - { - "$ref": "#/components/schemas/DatabaseConnectionSettings" - } - ] - }, - "metadata": { - "description": "Connector metadata.", - "default": { - "tables": {}, - "compositeTypes": {}, - "nativeQueries": {}, - "aggregateFunctions": {}, - "comparisonOperators": {}, - "typeRepresentations": {} - }, - "allOf": [ - { - "$ref": "#/components/schemas/Metadata" - } - ] - }, - "introspectionOptions": { - "description": "Database introspection options.", - "default": { - "excludedSchemas": [ - "information_schema", - "pg_catalog", - "tiger", - "crdb_internal", - "columnar", - "columnar_internal" - ], - "unqualifiedSchemasForTables": [ - "public" - ], - "unqualifiedSchemasForTypesAndProcedures": [ - "public", - "pg_catalog", - "tiger", - "auth", - "pgsodium" - ], - "comparisonOperatorMapping": [ - { - "operatorName": "=", - "exposedName": "_eq", - "operatorKind": "equal" - }, - { - "operatorName": "<=", - "exposedName": "_lte", - "operatorKind": "custom" - }, - { - "operatorName": ">", - "exposedName": "_gt", - "operatorKind": "custom" - }, - { - "operatorName": ">=", - "exposedName": "_gte", - "operatorKind": "custom" - }, - { - "operatorName": "<", - "exposedName": "_lt", - "operatorKind": "custom" - }, - { - "operatorName": "!=", - "exposedName": "_neq", - "operatorKind": "custom" - }, - { - "operatorName": "LIKE", - "exposedName": "_like", - "operatorKind": "custom" - }, - { - "operatorName": "NOT LIKE", - "exposedName": "_nlike", - "operatorKind": "custom" - }, - { - "operatorName": "ILIKE", - "exposedName": "_ilike", - "operatorKind": "custom" - }, - { - "operatorName": "NOT ILIKE", - "exposedName": "_nilike", - "operatorKind": "custom" - }, - { - "operatorName": "SIMILAR TO", - "exposedName": "_similar", - "operatorKind": "custom" - }, - { - "operatorName": "NOT SIMILAR TO", - "exposedName": "_nsimilar", - "operatorKind": "custom" - }, - { - "operatorName": "<>", - "exposedName": "_neq", - "operatorKind": "custom" - }, - { - "operatorName": "~~", - "exposedName": "_like", - "operatorKind": "custom" - }, - { - "operatorName": "!~~", - "exposedName": "_nlike", - "operatorKind": "custom" - }, - { - "operatorName": "~~*", - "exposedName": "_ilike", - "operatorKind": "custom" - }, - { - "operatorName": "!~~*", - "exposedName": "_nilike", - "operatorKind": "custom" - }, - { - "operatorName": "~", - "exposedName": "_regex", - "operatorKind": "custom" - }, - { - "operatorName": "!~", - "exposedName": "_nregex", - "operatorKind": "custom" - }, - { - "operatorName": "~*", - "exposedName": "_iregex", - "operatorKind": "custom" - }, - { - "operatorName": "!~*", - "exposedName": "_niregex", - "operatorKind": "custom" - } - ], - "introspectPrefixFunctionComparisonOperators": [ - "box_above", - "box_below", - "box_contain", - "box_contain_pt", - "box_contained", - "box_left", - "box_overabove", - "box_overbelow", - "box_overlap", - "box_overleft", - "box_overright", - "box_right", - "box_same", - "circle_above", - "circle_below", - "circle_contain", - "circle_contain_pt", - "circle_contained", - "circle_left", - "circle_overabove", - "circle_overbelow", - "circle_overlap", - "circle_overleft", - "circle_overright", - "circle_right", - "circle_same", - "contains_2d", - "equals", - "geography_overlaps", - "geometry_above", - "geometry_below", - "geometry_contained_3d", - "geometry_contains", - "geometry_contains_3d", - "geometry_contains_nd", - "geometry_left", - "geometry_overabove", - "geometry_overbelow", - "geometry_overlaps", - "geometry_overlaps_3d", - "geometry_overlaps_nd", - "geometry_overleft", - "geometry_overright", - "geometry_right", - "geometry_same", - "geometry_same_3d", - "geometry_same_nd", - "geometry_within", - "geometry_within_nd", - "inet_same_family", - "inter_lb", - "inter_sb", - "inter_sl", - "is_contained_2d", - "ishorizontal", - "isparallel", - "isperp", - "isvertical", - "jsonb_contained", - "jsonb_contains", - "jsonb_exists", - "jsonb_path_exists_opr", - "jsonb_path_match_opr", - "line_intersect", - "line_parallel", - "line_perp", - "lseg_intersect", - "lseg_parallel", - "lseg_perp", - "network_overlap", - "network_sub", - "network_sup", - "on_pb", - "on_pl", - "on_ppath", - "on_ps", - "on_sb", - "on_sl", - "overlaps_2d", - "path_contain_pt", - "path_inter", - "point_above", - "point_below", - "point_horiz", - "point_left", - "point_right", - "point_vert", - "poly_above", - "poly_below", - "poly_contain", - "poly_contain_pt", - "poly_contained", - "poly_left", - "poly_overabove", - "poly_overbelow", - "poly_overlap", - "poly_overleft", - "poly_overright", - "poly_right", - "poly_same", - "pt_contained_poly", - "st_3dintersects", - "st_contains", - "st_containsproperly", - "st_coveredby", - "st_covers", - "st_crosses", - "st_disjoint", - "st_equals", - "st_intersects", - "st_isvalid", - "st_orderingequals", - "st_overlaps", - "st_relatematch", - "st_touches", - "st_within", - "starts_with", - "ts_match_qv", - "ts_match_tq", - "ts_match_tt", - "ts_match_vq", - "tsq_mcontained", - "tsq_mcontains", - "xmlexists", - "xmlvalidate", - "xpath_exists" - ] - }, - "allOf": [ - { - "$ref": "#/components/schemas/IntrospectionOptions" - } - ] - }, - "mutationsVersion": { - "description": "Which version of the generated mutation procedures to include in the schema response", - "default": null, - "allOf": [ - { - "$ref": "#/components/schemas/MutationsVersion" - } - ], - "nullable": true - } - }, - "definitions": { - "Version": { - "type": "string", - "enum": [ - "3" - ] - }, - "DatabaseConnectionSettings": { - "description": "Database connection settings.", - "type": "object", - "required": [ - "connectionUri" - ], - "properties": { - "connectionUri": { - "description": "Connection string for a Postgres-compatible database.", - "allOf": [ - { - "$ref": "#/components/schemas/ConnectionUri" - } - ] - }, - "poolSettings": { - "description": "Connection pool settings.", - "default": { - "maxConnections": 50, - "poolTimeout": 30, - "idleTimeout": 180, - "checkConnectionAfterIdle": 60, - "connectionLifetime": 600 - }, - "allOf": [ - { - "$ref": "#/components/schemas/PoolSettings" - } - ] - }, - "isolationLevel": { - "description": "Query isolation level.", - "default": "ReadCommitted", - "allOf": [ - { - "$ref": "#/components/schemas/IsolationLevel" - } - ] - } - } - }, - "ConnectionUri": { - "$ref": "#/components/schemas/Secret" - }, - "Secret": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "object", - "required": [ - "variable" - ], - "properties": { - "variable": { - "$ref": "#/components/schemas/Variable" - } - } - } - ] - }, - "Variable": { - "description": "The name of an an environment variable.", - "type": "string" - }, - "PoolSettings": { - "description": "Settings for the PostgreSQL connection pool", - "type": "object", - "properties": { - "maxConnections": { - "description": "maximum number of pool connections", - "default": 50, - "type": "integer", - "format": "uint32", - "minimum": 0.0 - }, - "poolTimeout": { - "description": "timeout for acquiring a connection from the pool (seconds)", - "default": 30, - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "idleTimeout": { - "description": "idle timeout for releasing a connection from the pool (seconds)", - "default": 180, - "type": "integer", - "format": "uint64", - "minimum": 0.0, - "nullable": true - }, - "checkConnectionAfterIdle": { - "description": "check the connection is alive after being idle for N seconds. Set to null to always check.", - "default": 60, - "type": "integer", - "format": "uint64", - "minimum": 0.0, - "nullable": true - }, - "connectionLifetime": { - "description": "maximum lifetime for an individual connection (seconds)", - "default": 600, - "type": "integer", - "format": "uint64", - "minimum": 0.0, - "nullable": true - } - } - }, - "IsolationLevel": { - "description": "The isolation level of the transaction in which a query is executed.", - "oneOf": [ - { - "description": "Prevents reading data from another uncommitted transaction.", - "type": "string", - "enum": [ - "ReadCommitted" - ] - }, - { - "description": "Reading the same data twice is guaranteed to return the same result.", - "type": "string", - "enum": [ - "RepeatableRead" - ] - }, - { - "description": "Concurrent transactions behave identically to serializing them one at a time.", - "type": "string", - "enum": [ - "Serializable" - ] - } - ] - }, - "Metadata": { - "description": "Metadata information.", - "type": "object", - "properties": { - "tables": { - "default": {}, - "allOf": [ - { - "$ref": "#/components/schemas/TablesInfo" - } - ] - }, - "compositeTypes": { - "default": {}, - "allOf": [ - { - "$ref": "#/components/schemas/CompositeTypes" - } - ] - }, - "nativeQueries": { - "default": {}, - "allOf": [ - { - "$ref": "#/components/schemas/NativeQueries" - } - ] - }, - "aggregateFunctions": { - "default": {}, - "allOf": [ - { - "$ref": "#/components/schemas/AggregateFunctions" - } - ] - }, - "comparisonOperators": { - "default": {}, - "allOf": [ - { - "$ref": "#/components/schemas/ComparisonOperators" - } - ] - }, - "typeRepresentations": { - "default": {}, - "allOf": [ - { - "$ref": "#/components/schemas/TypeRepresentations" - } - ] - } - } - }, - "TablesInfo": { - "description": "Mapping from a \"table\" name to its information.", - "type": "object", - "additionalProperties": { - "$ref": "#/components/schemas/TableInfo" - } - }, - "TableInfo": { - "description": "Information about a database table (or any other kind of relation).", - "type": "object", - "required": [ - "columns", - "schemaName", - "tableName" - ], - "properties": { - "schemaName": { - "type": "string" - }, - "tableName": { - "type": "string" - }, - "columns": { - "type": "object", - "additionalProperties": { - "$ref": "#/components/schemas/ColumnInfo" - } - }, - "uniquenessConstraints": { - "default": {}, - "allOf": [ - { - "$ref": "#/components/schemas/UniquenessConstraints" - } - ] - }, - "foreignRelations": { - "default": {}, - "allOf": [ - { - "$ref": "#/components/schemas/ForeignRelations" - } - ] - }, - "description": { - "default": null, - "type": "string", - "nullable": true - } - } - }, - "ColumnInfo": { - "description": "Information about a database column.", - "type": "object", - "required": [ - "name", - "type" - ], - "properties": { - "name": { - "type": "string" - }, - "type": { - "$ref": "#/components/schemas/Type" - }, - "nullable": { - "default": "nullable", - "allOf": [ - { - "$ref": "#/components/schemas/Nullable" - } - ] - }, - "hasDefault": { - "$ref": "#/components/schemas/HasDefault" - }, - "isIdentity": { - "$ref": "#/components/schemas/IsIdentity" - }, - "isGenerated": { - "$ref": "#/components/schemas/IsGenerated" - }, - "description": { - "default": null, - "type": "string", - "nullable": true - } - } - }, - "Type": { - "description": "The type of values that a column, field, or argument may take.", - "oneOf": [ - { - "type": "object", - "required": [ - "scalarType" - ], - "properties": { - "scalarType": { - "$ref": "#/components/schemas/ScalarType" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "compositeType" - ], - "properties": { - "compositeType": { - "type": "string" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "arrayType" - ], - "properties": { - "arrayType": { - "$ref": "#/components/schemas/Type" - } - }, - "additionalProperties": false - } - ] - }, - "ScalarType": { - "description": "A Scalar Type.", - "type": "string" - }, - "Nullable": { - "description": "Can this column contain null values", - "type": "string", - "enum": [ - "nullable", - "nonNullable" - ] - }, - "HasDefault": { - "description": "Does this column have a default value.", - "type": "string", - "enum": [ - "noDefault", - "hasDefault" - ] - }, - "IsIdentity": { - "description": "Is this column an identity column.", - "type": "string", - "enum": [ - "notIdentity", - "identityByDefault", - "identityAlways" - ] - }, - "IsGenerated": { - "description": "Is this column a generated column.", - "type": "string", - "enum": [ - "notGenerated", - "stored" - ] - }, - "UniquenessConstraints": { - "description": "A mapping from the name of a unique constraint to its value.", - "type": "object", - "additionalProperties": { - "$ref": "#/components/schemas/UniquenessConstraint" - } - }, - "UniquenessConstraint": { - "description": "The set of columns that make up a uniqueness constraint.", - "type": "array", - "items": { - "type": "string" - }, - "uniqueItems": true - }, - "ForeignRelations": { - "description": "A mapping from the name of a foreign key constraint to its value.", - "type": "object", - "additionalProperties": { - "$ref": "#/components/schemas/ForeignRelation" - } - }, - "ForeignRelation": { - "description": "A foreign key constraint.", - "type": "object", - "required": [ - "columnMapping", - "foreignTable" - ], - "properties": { - "foreignSchema": { - "type": "string", - "nullable": true - }, - "foreignTable": { - "type": "string" - }, - "columnMapping": { - "type": "object", - "additionalProperties": { - "type": "string" - } - } - } - }, - "CompositeTypes": { - "description": "Map of all known composite types.", - "type": "object", - "additionalProperties": { - "$ref": "#/components/schemas/CompositeType" - } - }, - "CompositeType": { - "description": "Information about a composite type. These are very similar to tables, but with the crucial difference that composite types do not support constraints (such as NOT NULL).", - "type": "object", - "required": [ - "fields", - "name" - ], - "properties": { - "name": { - "type": "string" - }, - "fields": { - "type": "object", - "additionalProperties": { - "$ref": "#/components/schemas/FieldInfo" - } - }, - "description": { - "default": null, - "type": "string", - "nullable": true - } - } - }, - "FieldInfo": { - "description": "Information about a composite type field.", - "type": "object", - "required": [ - "name", - "type" - ], - "properties": { - "name": { - "type": "string" - }, - "type": { - "$ref": "#/components/schemas/Type" - }, - "description": { - "default": null, - "type": "string", - "nullable": true - } - } - }, - "NativeQueries": { - "description": "Metadata information of native queries.", - "type": "object", - "additionalProperties": { - "$ref": "#/components/schemas/NativeQueryInfo" - } - }, - "NativeQueryInfo": { - "description": "Information about a Native Query", - "type": "object", - "required": [ - "columns", - "sql" - ], - "properties": { - "sql": { - "description": "SQL expression to use for the Native Query. We can interpolate values using `{{variable_name}}` syntax, such as `SELECT * FROM authors WHERE name = {{author_name}}`", - "allOf": [ - { - "$ref": "#/components/schemas/NativeQuerySql" - } - ] - }, - "columns": { - "description": "Columns returned by the Native Query", - "type": "object", - "additionalProperties": { - "$ref": "#/components/schemas/ReadOnlyColumnInfo" - } - }, - "arguments": { - "description": "Names and types of arguments that can be passed to this Native Query", - "default": {}, - "type": "object", - "additionalProperties": { - "$ref": "#/components/schemas/ReadOnlyColumnInfo" - } - }, - "description": { - "default": null, - "type": "string", - "nullable": true - }, - "isProcedure": { - "description": "True if this native query mutates the database", - "type": "boolean" - } - } - }, - "NativeQuerySql": { - "description": "Native Query SQL location.", - "anyOf": [ - { - "description": "Refer to an external Native Query SQL file.", - "type": "object", - "required": [ - "file" - ], - "properties": { - "file": { - "description": "Relative path to a sql file.", - "type": "string" - } - } - }, - { - "description": "Inline Native Query SQL string.", - "type": "object", - "required": [ - "inline" - ], - "properties": { - "inline": { - "description": "An inline Native Query SQL string.", - "allOf": [ - { - "$ref": "#/components/schemas/InlineNativeQuerySql" - } - ] - } - } - }, - { - "$ref": "#/components/schemas/InlineNativeQuerySql" - } - ] - }, - "InlineNativeQuerySql": { - "type": "string" - }, - "ReadOnlyColumnInfo": { - "description": "Information about a native query column.", - "type": "object", - "required": [ - "name", - "type" - ], - "properties": { - "name": { - "type": "string" - }, - "type": { - "$ref": "#/components/schemas/Type" - }, - "nullable": { - "default": "nullable", - "allOf": [ - { - "$ref": "#/components/schemas/Nullable" - } - ] - }, - "description": { - "default": null, - "type": "string", - "nullable": true - } - } - }, - "AggregateFunctions": { - "description": "All supported aggregate functions, grouped by type.", - "type": "object", - "additionalProperties": { - "type": "object", - "additionalProperties": { - "$ref": "#/components/schemas/AggregateFunction" - } - } - }, - "AggregateFunction": { - "type": "object", - "required": [ - "returnType" - ], - "properties": { - "returnType": { - "$ref": "#/components/schemas/ScalarType" - } - } - }, - "ComparisonOperators": { - "description": "The complete list of supported binary operators for scalar types. Not all of these are supported for every type.", - "type": "object", - "additionalProperties": { - "type": "object", - "additionalProperties": { - "$ref": "#/components/schemas/ComparisonOperator" - } - } - }, - "ComparisonOperator": { - "description": "Represents a postgres binary comparison operator", - "type": "object", - "required": [ - "argumentType", - "operatorKind", - "operatorName" - ], - "properties": { - "operatorName": { - "type": "string" - }, - "operatorKind": { - "$ref": "#/components/schemas/OperatorKind" - }, - "argumentType": { - "$ref": "#/components/schemas/ScalarType" - }, - "isInfix": { - "default": true, - "type": "boolean" - } - } - }, - "OperatorKind": { - "description": "Is it a built-in operator, or a custom operator.", - "type": "string", - "enum": [ - "equal", - "in", - "custom" - ] - }, - "TypeRepresentations": { - "description": "Type representation of scalar types, grouped by type.", - "type": "object", - "additionalProperties": { - "$ref": "#/components/schemas/TypeRepresentation" - } - }, - "TypeRepresentation": { - "description": "Type representation of a scalar type.", - "oneOf": [ - { - "description": "JSON booleans", - "type": "string", - "enum": [ - "boolean" - ] - }, - { - "description": "Any JSON string", - "type": "string", - "enum": [ - "string" - ] - }, - { - "description": "float4", - "type": "string", - "enum": [ - "float32" - ] - }, - { - "description": "float8", - "type": "string", - "enum": [ - "float64" - ] - }, - { - "description": "int2", - "type": "string", - "enum": [ - "int16" - ] - }, - { - "description": "int4", - "type": "string", - "enum": [ - "int32" - ] - }, - { - "description": "int8 as integer", - "type": "string", - "enum": [ - "int64" - ] - }, - { - "description": "int8 as string", - "type": "string", - "enum": [ - "int64AsString" - ] - }, - { - "description": "numeric", - "type": "string", - "enum": [ - "bigDecimal" - ] - }, - { - "description": "numeric as string", - "type": "string", - "enum": [ - "bigDecimalAsString" - ] - }, - { - "description": "timestamp", - "type": "string", - "enum": [ - "timestamp" - ] - }, - { - "description": "timestamp with timezone", - "type": "string", - "enum": [ - "timestamptz" - ] - }, - { - "description": "time", - "type": "string", - "enum": [ - "time" - ] - }, - { - "description": "time with timezone", - "type": "string", - "enum": [ - "timetz" - ] - }, - { - "description": "date", - "type": "string", - "enum": [ - "date" - ] - }, - { - "description": "uuid", - "type": "string", - "enum": [ - "uUID" - ] - }, - { - "description": "geography", - "type": "string", - "enum": [ - "geography" - ] - }, - { - "description": "geometry", - "type": "string", - "enum": [ - "geometry" - ] - }, - { - "description": "Any JSON number", - "type": "string", - "enum": [ - "number" - ] - }, - { - "description": "Any JSON number, with no decimal part", - "type": "string", - "enum": [ - "integer" - ] - }, - { - "description": "An arbitrary json.", - "type": "string", - "enum": [ - "json" - ] - }, - { - "description": "One of the specified string values", - "type": "object", - "required": [ - "enum" - ], - "properties": { - "enum": { - "type": "array", - "items": { - "type": "string" - } - } - }, - "additionalProperties": false - } - ] - }, - "IntrospectionOptions": { - "description": "Options which only influence how the configuration is updated.", - "type": "object", - "properties": { - "excludedSchemas": { - "description": "Schemas which are excluded from introspection. The default setting will exclude the internal schemas of Postgres, Citus, Cockroach, and the PostGIS extension.", - "default": [ - "information_schema", - "pg_catalog", - "tiger", - "crdb_internal", - "columnar", - "columnar_internal" - ], - "type": "array", - "items": { - "type": "string" - } - }, - "unqualifiedSchemasForTables": { - "description": "The names of Tables and Views in these schemas will be returned unqualified. The default setting will set the `public` schema as unqualified.", - "default": [ - "public" - ], - "type": "array", - "items": { - "type": "string" - } - }, - "unqualifiedSchemasForTypesAndProcedures": { - "description": "The types and procedures in these schemas will be returned unqualified.", - "default": [ - "public", - "pg_catalog", - "tiger", - "auth", - "pgsodium" - ], - "type": "array", - "items": { - "type": "string" - } - }, - "comparisonOperatorMapping": { - "description": "The mapping of comparison operator names to apply when updating the configuration", - "default": [ - { - "operatorName": "=", - "exposedName": "_eq", - "operatorKind": "equal" - }, - { - "operatorName": "<=", - "exposedName": "_lte", - "operatorKind": "custom" - }, - { - "operatorName": ">", - "exposedName": "_gt", - "operatorKind": "custom" - }, - { - "operatorName": ">=", - "exposedName": "_gte", - "operatorKind": "custom" - }, - { - "operatorName": "<", - "exposedName": "_lt", - "operatorKind": "custom" - }, - { - "operatorName": "!=", - "exposedName": "_neq", - "operatorKind": "custom" - }, - { - "operatorName": "LIKE", - "exposedName": "_like", - "operatorKind": "custom" - }, - { - "operatorName": "NOT LIKE", - "exposedName": "_nlike", - "operatorKind": "custom" - }, - { - "operatorName": "ILIKE", - "exposedName": "_ilike", - "operatorKind": "custom" - }, - { - "operatorName": "NOT ILIKE", - "exposedName": "_nilike", - "operatorKind": "custom" - }, - { - "operatorName": "SIMILAR TO", - "exposedName": "_similar", - "operatorKind": "custom" - }, - { - "operatorName": "NOT SIMILAR TO", - "exposedName": "_nsimilar", - "operatorKind": "custom" - }, - { - "operatorName": "<>", - "exposedName": "_neq", - "operatorKind": "custom" - }, - { - "operatorName": "~~", - "exposedName": "_like", - "operatorKind": "custom" - }, - { - "operatorName": "!~~", - "exposedName": "_nlike", - "operatorKind": "custom" - }, - { - "operatorName": "~~*", - "exposedName": "_ilike", - "operatorKind": "custom" - }, - { - "operatorName": "!~~*", - "exposedName": "_nilike", - "operatorKind": "custom" - }, - { - "operatorName": "~", - "exposedName": "_regex", - "operatorKind": "custom" - }, - { - "operatorName": "!~", - "exposedName": "_nregex", - "operatorKind": "custom" - }, - { - "operatorName": "~*", - "exposedName": "_iregex", - "operatorKind": "custom" - }, - { - "operatorName": "!~*", - "exposedName": "_niregex", - "operatorKind": "custom" - } - ], - "type": "array", - "items": { - "$ref": "#/components/schemas/ComparisonOperatorMapping" - } - }, - "introspectPrefixFunctionComparisonOperators": { - "description": "Which prefix functions (i.e., non-infix operators) to generate introspection metadata for.\n\nThis list will accept any boolean-returning function taking two concrete scalar types as arguments.\n\nThe default includes comparisons for various build-in types as well as those of PostGIS.", - "default": [ - "box_above", - "box_below", - "box_contain", - "box_contain_pt", - "box_contained", - "box_left", - "box_overabove", - "box_overbelow", - "box_overlap", - "box_overleft", - "box_overright", - "box_right", - "box_same", - "circle_above", - "circle_below", - "circle_contain", - "circle_contain_pt", - "circle_contained", - "circle_left", - "circle_overabove", - "circle_overbelow", - "circle_overlap", - "circle_overleft", - "circle_overright", - "circle_right", - "circle_same", - "contains_2d", - "equals", - "geography_overlaps", - "geometry_above", - "geometry_below", - "geometry_contained_3d", - "geometry_contains", - "geometry_contains_3d", - "geometry_contains_nd", - "geometry_left", - "geometry_overabove", - "geometry_overbelow", - "geometry_overlaps", - "geometry_overlaps_3d", - "geometry_overlaps_nd", - "geometry_overleft", - "geometry_overright", - "geometry_right", - "geometry_same", - "geometry_same_3d", - "geometry_same_nd", - "geometry_within", - "geometry_within_nd", - "inet_same_family", - "inter_lb", - "inter_sb", - "inter_sl", - "is_contained_2d", - "ishorizontal", - "isparallel", - "isperp", - "isvertical", - "jsonb_contained", - "jsonb_contains", - "jsonb_exists", - "jsonb_path_exists_opr", - "jsonb_path_match_opr", - "line_intersect", - "line_parallel", - "line_perp", - "lseg_intersect", - "lseg_parallel", - "lseg_perp", - "network_overlap", - "network_sub", - "network_sup", - "on_pb", - "on_pl", - "on_ppath", - "on_ps", - "on_sb", - "on_sl", - "overlaps_2d", - "path_contain_pt", - "path_inter", - "point_above", - "point_below", - "point_horiz", - "point_left", - "point_right", - "point_vert", - "poly_above", - "poly_below", - "poly_contain", - "poly_contain_pt", - "poly_contained", - "poly_left", - "poly_overabove", - "poly_overbelow", - "poly_overlap", - "poly_overleft", - "poly_overright", - "poly_right", - "poly_same", - "pt_contained_poly", - "st_3dintersects", - "st_contains", - "st_containsproperly", - "st_coveredby", - "st_covers", - "st_crosses", - "st_disjoint", - "st_equals", - "st_intersects", - "st_isvalid", - "st_orderingequals", - "st_overlaps", - "st_relatematch", - "st_touches", - "st_within", - "starts_with", - "ts_match_qv", - "ts_match_tq", - "ts_match_tt", - "ts_match_vq", - "tsq_mcontained", - "tsq_mcontains", - "xmlexists", - "xmlvalidate", - "xpath_exists" - ], - "type": "array", - "items": { - "type": "string" - } - } - } - }, - "ComparisonOperatorMapping": { - "description": "Define the names that comparison operators will be exposed as by the automatic introspection.", - "type": "object", - "required": [ - "exposedName", - "operatorKind", - "operatorName" - ], - "properties": { - "operatorName": { - "description": "The name of the operator as defined by the database", - "type": "string" - }, - "exposedName": { - "description": "The name the operator will appear under in the exposed API", - "type": "string" - }, - "operatorKind": { - "description": "Equal, In or Custom.", - "allOf": [ - { - "$ref": "#/components/schemas/OperatorKind" - } - ] - } - } - }, - "MutationsVersion": { - "description": "Which version of the generated mutations will be included in the schema", - "type": "string", - "enum": [ - "v1", - "veryExperimentalWip" - ] - } - } -} diff --git a/crates/tests/tests-common/Cargo.toml b/crates/tests/tests-common/Cargo.toml index 6f047e22a..0369f53c9 100644 --- a/crates/tests/tests-common/Cargo.toml +++ b/crates/tests/tests-common/Cargo.toml @@ -23,12 +23,9 @@ axum = "0.6.20" axum-test-helper = "0.3.0" env_logger = "0.11.3" hyper = { version = "0.14.28", features = ["tcp"] } -jsonschema = { version = "0.17.1", default-features = false, features = ["resolve-http"] } reqwest = "0.11.27" -schemars = { version = "0.8.17", features = ["smol_str", "preserve_order"] } serde = "1.0.200" serde_json = { version = "1.0.116", features = ["raw_value"] } -similar-asserts = "1.5.0" sqlx = { version = "0.7.4", features = [ "json", "postgres", "runtime-tokio-rustls" ] } tokio = { version = "1.37.0", features = ["full"] } tokio-postgres = "0.7.10" diff --git a/crates/tests/tests-common/src/common_tests/configuration_v3_tests.rs b/crates/tests/tests-common/src/common_tests/configuration_v3_tests.rs deleted file mode 100644 index cebbb3009..000000000 --- a/crates/tests/tests-common/src/common_tests/configuration_v3_tests.rs +++ /dev/null @@ -1,81 +0,0 @@ -use std::collections::HashMap; -use std::path::Path; - -use similar_asserts::assert_eq; -use tokio::fs; - -use ndc_postgres_configuration::environment::Variable; -use ndc_postgres_configuration::version3::{connection_settings, introspect, RawConfiguration}; -use ndc_postgres_configuration::{ConnectionUri, Secret}; - -use crate::ndc_metadata::helpers::get_path_from_project_root; -use crate::schemas::check_value_conforms_to_schema; - -// Tests that configuration generation has not changed. -// -// This test does not use insta snapshots because it checks the NDC metadata file that is shared with -// other tests. -// -// If you have changed it intentionally, run `just generate-configuration`. -pub async fn configure_is_idempotent( - connection_string: &str, - chinook_ndc_metadata_path: impl AsRef, -) -> anyhow::Result<()> { - let expected_value = read_configuration(chinook_ndc_metadata_path).await?; - - let args: RawConfiguration = serde_json::from_value(expected_value.clone())?; - let environment = HashMap::from([( - connection_settings::DEFAULT_CONNECTION_URI_VARIABLE.into(), - connection_string.into(), - )]); - - let actual = introspect(args, environment).await?; - - let actual_value = serde_json::to_value(actual)?; - - assert_eq!(expected_value, actual_value); - Ok(()) -} - -pub async fn configure_initial_configuration_is_unchanged( - connection_string: &str, -) -> RawConfiguration { - let connection_uri_variable: Variable = "MAGIC_URI".into(); - let connection_settings = connection_settings::DatabaseConnectionSettings { - connection_uri: ConnectionUri(Secret::FromEnvironment { - variable: connection_uri_variable.clone(), - }), - ..connection_settings::DatabaseConnectionSettings::empty() - }; - let args = RawConfiguration { - connection_settings, - ..RawConfiguration::empty() - }; - let environment = HashMap::from([(connection_uri_variable, connection_string.into())]); - - introspect(args, environment) - .await - .expect("configuration::introspect") -} - -pub async fn configuration_conforms_to_the_schema( - chinook_ndc_metadata_path: impl AsRef, -) -> anyhow::Result<()> { - check_value_conforms_to_schema::( - &read_configuration(chinook_ndc_metadata_path).await?, - ); - Ok(()) -} - -async fn read_configuration( - chinook_ndc_metadata_path: impl AsRef, -) -> anyhow::Result { - let absolute_configuration_directory = get_path_from_project_root(chinook_ndc_metadata_path); - - let contents = - fs::read_to_string(absolute_configuration_directory.join("configuration.json")).await?; - - let multi_version: serde_json::Value = serde_json::from_str(&contents)?; - - Ok(multi_version) -} diff --git a/crates/tests/tests-common/src/common_tests/mod.rs b/crates/tests/tests-common/src/common_tests/mod.rs index c896d373e..bfc4d0097 100644 --- a/crates/tests/tests-common/src/common_tests/mod.rs +++ b/crates/tests/tests-common/src/common_tests/mod.rs @@ -1,2 +1 @@ -pub mod configuration_v3_tests; pub mod ndc_tests; diff --git a/crates/tests/tests-common/src/lib.rs b/crates/tests/tests-common/src/lib.rs index 1f08c2fff..53d72926b 100644 --- a/crates/tests/tests-common/src/lib.rs +++ b/crates/tests/tests-common/src/lib.rs @@ -5,4 +5,3 @@ pub mod common_tests; pub mod ndc_metadata; pub mod request; pub mod router; -pub mod schemas; diff --git a/crates/tests/tests-common/src/router.rs b/crates/tests/tests-common/src/router.rs index c2de3c5cf..704c638a8 100644 --- a/crates/tests/tests-common/src/router.rs +++ b/crates/tests/tests-common/src/router.rs @@ -16,8 +16,7 @@ pub async fn create_router( // Initialize server state with the configuration above, injecting the URI. let environment = HashMap::from([( - ndc_postgres_configuration::version3::connection_settings::DEFAULT_CONNECTION_URI_VARIABLE - .into(), + ndc_postgres_configuration::DEFAULT_CONNECTION_URI_VARIABLE.into(), connection_uri.to_string(), )]); let setup = PostgresSetup::new(environment); diff --git a/crates/tests/tests-common/src/schemas.rs b/crates/tests/tests-common/src/schemas.rs deleted file mode 100644 index b15c0b335..000000000 --- a/crates/tests/tests-common/src/schemas.rs +++ /dev/null @@ -1,32 +0,0 @@ -use std::fmt::Write; -/// Checks that a given value conforms to the schema generated by `schemars`. -/// -/// Panics with a human-readable error if the value does not conform, or if the -/// schema could not be compiled. -pub fn check_value_conforms_to_schema(value: &serde_json::Value) { - let schema_json = serde_json::to_value(schemars::schema_for!(T)) - .expect("the schema could not be converted to JSON"); - let schema = jsonschema::JSONSchema::options() - .with_draft(jsonschema::Draft::Draft7) - .compile(&schema_json) - .expect("the schema could not be compiled"); - - let result = schema.validate(value); - - match result { - Ok(()) => (), - Err(errors) => { - panic!( - "The configuration does not conform to the schema.\n{}", - errors.fold(String::new(), |mut str, error| { - let _ = write!( - str, - "{}\ninstance path: {}\nschema path: {}\n\n", - error, error.instance_path, error.schema_path - ); - str - }) - ) - } - } -}