From 4e55c247e5eb3337443b71d7a59a546f6203860e Mon Sep 17 00:00:00 2001 From: Philip Lykke Carlsen Date: Thu, 2 May 2024 12:29:04 +0200 Subject: [PATCH 01/18] Move everything around and then some --- crates/cli/src/lib.rs | 56 +++--- crates/cli/tests/initialize_tests.rs | 4 +- crates/cli/tests/update_tests.rs | 10 +- crates/configuration/src/configuration.rs | 74 ++++--- crates/configuration/src/error.rs | 3 + crates/configuration/src/lib.rs | 4 +- crates/configuration/src/version3/mod.rs | 100 +++++----- crates/configuration/src/version4/mod.rs | 180 +++++++++++------- .../connectors/ndc-postgres/src/connector.rs | 16 +- crates/documentation/openapi/src/generator.rs | 5 +- .../src/ndc_metadata_snapshot_tests.rs | 3 +- .../src/postgres/configuration_tests.rs | 3 +- .../src/ndc_metadata/configuration.rs | 52 ++--- 13 files changed, 279 insertions(+), 231 deletions(-) diff --git a/crates/cli/src/lib.rs b/crates/cli/src/lib.rs index b2262ed83..b5a44581f 100644 --- a/crates/cli/src/lib.rs +++ b/crates/cli/src/lib.rs @@ -33,6 +33,12 @@ pub enum Command { }, /// Update the configuration by introspecting the database, using the configuration options. Update, + /// Upgrade the configuration to the latest version. This does not involve the database. + Upgrade { + #[arg(long)] + dir_from: PathBuf, + dir_to: PathBuf, + }, } /// The set of errors that can go wrong _in addition to_ generic I/O or parsing errors. @@ -47,6 +53,7 @@ pub async fn run(command: Command, context: Context) -> anyhow match command { Command::Initialize { with_metadata } => initialize(with_metadata, context).await?, Command::Update => update(context).await?, + Command::Upgrade { dir_from, dir_to } => upgrade(dir_from, dir_to, context).await?, }; Ok(()) } @@ -60,33 +67,9 @@ pub async fn run(command: Command, context: Context) -> anyhow /// Optionally, this can also create the connector metadata, which is used by the Hasura CLI to /// automatically work with this CLI as a plugin. async fn initialize(with_metadata: bool, context: Context) -> anyhow::Result<()> { - let configuration_file = context - .context_path - .join(configuration::CONFIGURATION_FILENAME); - fs::create_dir_all(&context.context_path).await?; - - // refuse to initialize the directory unless it is empty - let mut items_in_dir = fs::read_dir(&context.context_path).await?; - if items_in_dir.next_entry().await?.is_some() { - Err(Error::DirectoryIsNotEmpty)?; - } - - // create the configuration file - fs::write( - configuration_file, - serde_json::to_string_pretty(&configuration::RawConfiguration::empty())? + "\n", - ) - .await?; - - // create the jsonschema file - let configuration_jsonschema_file_path = context - .context_path - .join(configuration::CONFIGURATION_JSONSCHEMA_FILENAME); - - let output = schemars::schema_for!(ndc_postgres_configuration::RawConfiguration); - fs::write( - &configuration_jsonschema_file_path, - serde_json::to_string_pretty(&output)? + "\n", + configuration::write_configuration( + configuration::ParsedConfiguration::initial(), + &context.context_path, ) .await?; @@ -139,10 +122,12 @@ async fn update(context: Context) -> anyhow::Result<()> { // We want to detect this scenario and retry, or fail if we are unable to. // We do that with a few attempts. for _attempt in 1..=UPDATE_ATTEMPTS { + let existing_configuration = + configuration::parse_configuration(context.context_path, context.environment); let configuration_file_path = context .context_path .join(configuration::CONFIGURATION_FILENAME); - let input: configuration::RawConfiguration = { + let input: configuration::ParsedConfiguration = { let configuration_file_contents = read_config_file_contents(&configuration_file_path).await?; serde_json::from_str(&configuration_file_contents)? @@ -150,7 +135,7 @@ async fn update(context: Context) -> anyhow::Result<()> { let output = configuration::introspect(input.clone(), &context.environment).await?; // Check that the input file did not change since we started introspecting, - let input_again_before_write: configuration::RawConfiguration = { + let input_again_before_write: configuration::ParsedConfiguration = { let configuration_file_contents = read_config_file_contents(&configuration_file_path).await?; serde_json::from_str(&configuration_file_contents)? @@ -181,6 +166,19 @@ async fn update(context: Context) -> anyhow::Result<()> { )) } +/// Upgrade the configuration in a directory by trying to read it and then write it back +/// out to a different directory. +/// +async fn upgrade( + dir_from: PathBuf, + dir_to: PathBuf, + context: Context, +) -> anyhow::Result<()> { + let configuration = configuration::parse_configuration(dir_from, context.environment).await?; + configuration::write_configuration(configuration, dir_to).await?; + Ok(()) +} + async fn read_config_file_contents(configuration_file_path: &PathBuf) -> anyhow::Result { fs::read_to_string(configuration_file_path) .await diff --git a/crates/cli/tests/initialize_tests.rs b/crates/cli/tests/initialize_tests.rs index fc0bae013..ef221a2ca 100644 --- a/crates/cli/tests/initialize_tests.rs +++ b/crates/cli/tests/initialize_tests.rs @@ -4,7 +4,7 @@ use tokio::fs; use ndc_postgres_cli::*; use ndc_postgres_configuration as configuration; -use ndc_postgres_configuration::RawConfiguration; +use ndc_postgres_configuration::ParsedConfiguration; #[tokio::test] async fn test_initialize_directory() -> anyhow::Result<()> { @@ -31,7 +31,7 @@ async fn test_initialize_directory() -> anyhow::Result<()> { assert!(configuration_file_path.exists()); let contents = fs::read_to_string(configuration_file_path).await?; common::assert_ends_with_newline(&contents); - let _: RawConfiguration = serde_json::from_str(&contents)?; + let _: ParsedConfiguration = serde_json::from_str(&contents)?; let metadata_file_path = dir .path() diff --git a/crates/cli/tests/update_tests.rs b/crates/cli/tests/update_tests.rs index 9c01cd877..64e457259 100644 --- a/crates/cli/tests/update_tests.rs +++ b/crates/cli/tests/update_tests.rs @@ -5,7 +5,7 @@ use tokio::fs; use ndc_postgres_cli::*; use ndc_postgres_configuration as configuration; use ndc_postgres_configuration::environment::FixedEnvironment; -use ndc_postgres_configuration::RawConfiguration; +use ndc_postgres_configuration::ParsedConfiguration; const CONNECTION_URI: &str = "postgresql://postgres:password@localhost:64002"; @@ -24,7 +24,7 @@ async fn test_update_configuration() -> anyhow::Result<()> { connection_uri: connection_uri.clone(), ..configuration::version3::connection_settings::DatabaseConnectionSettings::empty() }; - let input = RawConfiguration::Version3(configuration::version3::RawConfiguration { + let input = ParsedConfiguration::Version3(configuration::version3::RawConfiguration { connection_settings, ..configuration::version3::RawConfiguration::empty() }); @@ -44,9 +44,9 @@ async fn test_update_configuration() -> anyhow::Result<()> { assert!(configuration_file_path.exists()); let contents = fs::read_to_string(configuration_file_path).await?; common::assert_ends_with_newline(&contents); - let output: RawConfiguration = serde_json::from_str(&contents)?; + let output: ParsedConfiguration = serde_json::from_str(&contents)?; match output { - RawConfiguration::Version3(configuration::version3::RawConfiguration { + ParsedConfiguration::Version3(configuration::version3::RawConfiguration { connection_settings, metadata, .. @@ -55,7 +55,7 @@ async fn test_update_configuration() -> anyhow::Result<()> { let some_table_metadata = metadata.tables.0.get("Artist"); assert!(some_table_metadata.is_some()); } - RawConfiguration::Version4(_) => panic!("Expected version 3"), + ParsedConfiguration::Version4(_) => panic!("Expected version 3"), } Ok(()) diff --git a/crates/configuration/src/configuration.rs b/crates/configuration/src/configuration.rs index 34303a408..908bb1b90 100644 --- a/crates/configuration/src/configuration.rs +++ b/crates/configuration/src/configuration.rs @@ -2,9 +2,6 @@ use std::path::Path; -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - use query_engine_metadata::metadata; use crate::environment::Environment; @@ -13,22 +10,25 @@ use crate::values::{IsolationLevel, PoolSettings}; use crate::version3; use crate::version4; -pub const CONFIGURATION_FILENAME: &str = "configuration.json"; -pub const CONFIGURATION_JSONSCHEMA_FILENAME: &str = "schema.json"; - -/// The parsed connector configuration. -#[derive(Clone, PartialEq, Eq, Debug, Deserialize, Serialize, JsonSchema)] -#[serde(tag = "version")] -pub enum RawConfiguration { - #[serde(rename = "3")] +/// The parsed connector configuration. This data type is an enum with cases for each supported +/// version. +/// +/// It supports various uses: +/// +/// * 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) +#[derive(Clone, PartialEq, Eq, Debug)] +pub enum ParsedConfiguration { Version3(version3::RawConfiguration), - #[serde(rename = "4")] - Version4(version4::RawConfiguration), + Version4(version4::ParsedConfiguration), } -impl RawConfiguration { - pub fn empty() -> Self { - RawConfiguration::Version3(version3::RawConfiguration::empty()) +impl ParsedConfiguration { + pub fn initial() -> Self { + ParsedConfiguration::Version3(version3::RawConfiguration::empty()) } } @@ -47,14 +47,14 @@ pub struct Configuration { } pub async fn introspect( - input: RawConfiguration, + input: ParsedConfiguration, environment: impl Environment, -) -> anyhow::Result { +) -> anyhow::Result { match input { - RawConfiguration::Version3(config) => Ok(RawConfiguration::Version3( + ParsedConfiguration::Version3(config) => Ok(ParsedConfiguration::Version3( version3::introspect(config, environment).await?, )), - RawConfiguration::Version4(config) => Ok(RawConfiguration::Version4( + ParsedConfiguration::Version4(config) => Ok(ParsedConfiguration::Version4( version4::introspect(config, environment).await?, )), } @@ -62,16 +62,30 @@ pub async fn introspect( pub async fn parse_configuration( configuration_dir: impl AsRef + Send, - environment: impl Environment, -) -> Result { +) -> Result { // Try parsing each supported version in turn - match version4::parse_configuration(configuration_dir.as_ref(), &environment).await { - Err(v4_err) => { - match version3::parse_configuration(configuration_dir.as_ref(), &environment).await { - Err(v3_err) => Err(Error::UnableToParseAnyVersions(vec![v3_err, v4_err])), - Ok(config) => Ok(config), - } - } - Ok(config) => Ok(config), + match version4::parse_configuration(configuration_dir.as_ref()).await { + Err(v4_err) => match version3::parse_configuration(configuration_dir.as_ref()).await { + Err(v3_err) => Err(Error::UnableToParseAnyVersions(vec![v3_err, v4_err])), + Ok(config) => Ok(ParsedConfiguration::Version3(config)), + }, + Ok(config) => Ok(ParsedConfiguration::Version4(config)), } } + +pub fn make_runtime_configuration( + parsed_config: ParsedConfiguration, + environment: impl Environment, +) -> Configuration { + todo!() +} + +/// Write out a runtime configuration to a directory. We would mostly only expect this function to +/// support the latest version. +pub async fn write_configuration( + configuration: ParsedConfiguration, + out_dir: impl AsRef, +) -> Result<(), Error> { + todo!() + // version4::write_configuration(configuration, out_dir).await +} diff --git a/crates/configuration/src/error.rs b/crates/configuration/src/error.rs index 6ec671bc6..e393db93b 100644 --- a/crates/configuration/src/error.rs +++ b/crates/configuration/src/error.rs @@ -33,4 +33,7 @@ pub enum Error { #[error("Unable to parse any configuration versions: TODO")] UnableToParseAnyVersions(Vec), + + #[error("directory is not empty")] + DirectoryIsNotEmpty, } diff --git a/crates/configuration/src/lib.rs b/crates/configuration/src/lib.rs index 3fb0b4412..71c752cd5 100644 --- a/crates/configuration/src/lib.rs +++ b/crates/configuration/src/lib.rs @@ -7,8 +7,8 @@ pub mod version3; pub mod version4; pub use configuration::{ - introspect, parse_configuration, Configuration, RawConfiguration, CONFIGURATION_FILENAME, - CONFIGURATION_JSONSCHEMA_FILENAME, + introspect, make_runtime_configuration, parse_configuration, write_configuration, + Configuration, ParsedConfiguration, }; pub use error::Error; pub use values::{ConnectionUri, IsolationLevel, PoolSettings, Secret}; diff --git a/crates/configuration/src/version3/mod.rs b/crates/configuration/src/version3/mod.rs index 99fd1a03c..b03917093 100644 --- a/crates/configuration/src/version3/mod.rs +++ b/crates/configuration/src/version3/mod.rs @@ -22,6 +22,8 @@ use crate::environment::Environment; use crate::error::Error; use crate::values::{ConnectionUri, Secret}; +const CONFIGURATION_FILENAME: &str = "configuration.json"; +const CONFIGURATION_JSONSCHEMA_FILENAME: &str = "schema.json"; const CONFIGURATION_QUERY: &str = include_str!("version3.sql"); /// Initial configuration, just enough to connect to a database and elaborate a full @@ -49,7 +51,7 @@ pub struct RawConfiguration { impl RawConfiguration { pub fn empty() -> Self { Self { - schema: Some(crate::CONFIGURATION_JSONSCHEMA_FILENAME.to_string()), + schema: Some(CONFIGURATION_JSONSCHEMA_FILENAME.to_string()), connection_settings: connection_settings::DatabaseConnectionSettings::empty(), metadata: metadata::Metadata::default(), introspection_options: options::IntrospectionOptions::default(), @@ -495,52 +497,58 @@ fn filter_type_representations( pub async fn parse_configuration( configuration_dir: impl AsRef, - environment: impl Environment, -) -> Result { - let configuration_file = configuration_dir - .as_ref() - .join(crate::CONFIGURATION_FILENAME); - - let configuration_file_contents = - fs::read_to_string(&configuration_file) - .await - .map_err(|err| { - Error::IoErrorButStringified(format!("{}: {}", &configuration_file.display(), err)) - })?; - let mut configuration: RawConfiguration = serde_json::from_str(&configuration_file_contents) - .map_err(|error| Error::ParseError { - file_path: configuration_file.clone(), - line: error.line(), - column: error.column(), - message: error.to_string(), - })?; - // look for native query sql file references and read from disk. - for native_query_sql in configuration.metadata.native_queries.0.values_mut() { - native_query_sql.sql = metadata::NativeQuerySqlEither::NativeQuerySql( - native_query_sql - .sql - .from_external(configuration_dir.as_ref()) - .map_err(Error::IoErrorButStringified)?, - ); - } + // environment: impl Environment, +) -> Result { + // let configuration_file = configuration_dir.as_ref().join(CONFIGURATION_FILENAME); + // + // let configuration_file_contents = + // fs::read_to_string(&configuration_file) + // .await + // .map_err(|err| { + // Error::IoErrorButStringified(format!("{}: {}", &configuration_file.display(), err)) + // })?; + // let mut configuration: RawConfiguration = serde_json::from_str(&configuration_file_contents) + // .map_err(|error| Error::ParseError { + // file_path: configuration_file.clone(), + // line: error.line(), + // column: error.column(), + // message: error.to_string(), + // })?; + // // look for native query sql file references and read from disk. + // for native_query_sql in configuration.metadata.native_queries.0.values_mut() { + // native_query_sql.sql = metadata::NativeQuerySqlEither::NativeQuerySql( + // native_query_sql + // .sql + // .from_external(configuration_dir.as_ref()) + // .map_err(Error::IoErrorButStringified)?, + // ); + // } + // + // let connection_uri = + // match configuration.connection_settings.connection_uri { + // ConnectionUri(Secret::Plain(uri)) => Ok(uri), + // ConnectionUri(Secret::FromEnvironment { variable }) => environment + // .read(&variable) + // .map_err(|error| Error::MissingEnvironmentVariable { + // file_path: configuration_file, + // message: error.to_string(), + // }), + // }?; + // Ok(crate::Configuration { + // metadata: convert_metadata(configuration.metadata), + // pool_settings: configuration.connection_settings.pool_settings, + // connection_uri, + // isolation_level: configuration.connection_settings.isolation_level, + // mutations_version: convert_mutations_version(configuration.mutations_version), + // }) + todo!() +} - let connection_uri = - match configuration.connection_settings.connection_uri { - ConnectionUri(Secret::Plain(uri)) => Ok(uri), - ConnectionUri(Secret::FromEnvironment { variable }) => environment - .read(&variable) - .map_err(|error| Error::MissingEnvironmentVariable { - file_path: configuration_file, - message: error.to_string(), - }), - }?; - Ok(crate::Configuration { - metadata: convert_metadata(configuration.metadata), - pool_settings: configuration.connection_settings.pool_settings, - connection_uri, - isolation_level: configuration.connection_settings.isolation_level, - mutations_version: convert_mutations_version(configuration.mutations_version), - }) +pub fn make_runtime_configuration( + parsed_config: RawConfiguration, + environment: impl Environment, +) -> crate::Configuration { + todo!() } // This function is used by tests as well diff --git a/crates/configuration/src/version4/mod.rs b/crates/configuration/src/version4/mod.rs index 653ac57f4..bb9ecfb61 100644 --- a/crates/configuration/src/version4/mod.rs +++ b/crates/configuration/src/version4/mod.rs @@ -23,13 +23,15 @@ use crate::environment::Environment; use crate::error::Error; use crate::values::{ConnectionUri, Secret}; +const CONFIGURATION_FILENAME: &str = "configuration.json"; +const CONFIGURATION_JSONSCHEMA_FILENAME: &str = "schema.json"; const CONFIGURATION_QUERY: &str = include_str!("introspection.sql"); /// Initial configuration, just enough to connect to a database and elaborate a full /// 'Configuration'. #[derive(Clone, PartialEq, Eq, Debug, Deserialize, Serialize, JsonSchema)] #[serde(rename_all = "camelCase")] -pub struct RawConfiguration { +pub struct ParsedConfiguration { /// Jsonschema of the configuration format. #[serde(rename = "$schema")] #[serde(default)] @@ -47,10 +49,10 @@ pub struct RawConfiguration { pub mutations_version: Option, } -impl RawConfiguration { +impl ParsedConfiguration { pub fn empty() -> Self { Self { - schema: Some(crate::CONFIGURATION_JSONSCHEMA_FILENAME.to_string()), + schema: Some(CONFIGURATION_JSONSCHEMA_FILENAME.to_string()), connection_settings: connection_settings::DatabaseConnectionSettings::empty(), metadata: metadata::Metadata::default(), introspection_options: options::IntrospectionOptions::default(), @@ -64,8 +66,8 @@ impl RawConfiguration { /// Validate the user configuration. pub fn validate_raw_configuration( file_path: PathBuf, - config: RawConfiguration, -) -> Result { + config: ParsedConfiguration, +) -> Result { match &config.connection_settings.connection_uri { ConnectionUri(Secret::Plain(uri)) if uri.is_empty() => { Err(Error::EmptyConnectionUri { file_path }) @@ -78,9 +80,9 @@ pub fn validate_raw_configuration( /// Construct the NDC metadata configuration by introspecting the database. pub async fn introspect( - args: RawConfiguration, + args: ParsedConfiguration, environment: impl Environment, -) -> anyhow::Result { +) -> anyhow::Result { let uri = match &args.connection_settings.connection_uri { ConnectionUri(Secret::Plain(value)) => Cow::Borrowed(value), ConnectionUri(Secret::FromEnvironment { variable }) => { @@ -160,7 +162,7 @@ pub async fn introspect( // composite_types, // ); // - Ok(RawConfiguration { + Ok(ParsedConfiguration { schema: args.schema, connection_settings: args.connection_settings, metadata: metadata::Metadata { @@ -405,70 +407,112 @@ fn base_type_representations() -> BTreeMap pub async fn parse_configuration( configuration_dir: impl AsRef, + // environment: impl Environment, +) -> Result { + // let configuration_file = configuration_dir.as_ref().join(CONFIGURATION_FILENAME); + // + // let configuration_file_contents = + // fs::read_to_string(&configuration_file) + // .await + // .map_err(|err| { + // Error::IoErrorButStringified(format!("{}: {}", &configuration_file.display(), err)) + // })?; + // let configuration_json_value = + // serde_json::to_value(configuration_file_contents).map_err(|error| Error::ParseError { + // file_path: configuration_file.clone(), + // line: error.line(), + // column: error.column(), + // message: error.to_string(), + // })?; + // + // let version_tag = configuration_json_value + // .as_object() + // .and_then(|o| o.get("version")) + // .and_then(|v| v.as_str()); + // match version_tag { + // Some("4") => {} + // _ => Err(Error::DidNotFindExpectedVersionTag("4".to_string()))?, + // } + // + // let mut configuration: ParsedConfiguration = serde_json::from_value(configuration_json_value) + // .map_err(|error| Error::ParseError { + // file_path: configuration_file.clone(), + // line: error.line(), + // column: error.column(), + // message: error.to_string(), + // })?; + // + // // look for native query sql file references and read from disk. + // for native_query_sql in configuration.metadata.native_queries.0.values_mut() { + // native_query_sql.sql = metadata::NativeQuerySqlEither::NativeQuerySql( + // native_query_sql + // .sql + // .from_external(configuration_dir.as_ref()) + // .map_err(Error::IoErrorButStringified)?, + // ); + // } + // + // let connection_uri = + // match configuration.connection_settings.connection_uri { + // ConnectionUri(Secret::Plain(uri)) => Ok(uri), + // ConnectionUri(Secret::FromEnvironment { variable }) => environment + // .read(&variable) + // .map_err(|error| Error::MissingEnvironmentVariable { + // file_path: configuration_file, + // message: error.to_string(), + // }), + // }?; + // Ok(crate::Configuration { + // metadata: convert_metadata(configuration.metadata), + // pool_settings: configuration.connection_settings.pool_settings, + // connection_uri, + // isolation_level: configuration.connection_settings.isolation_level, + // mutations_version: convert_mutations_version(configuration.mutations_version), + // }) + todo!() +} + +pub fn make_runtime_configuration( + parsed_config: ParsedConfiguration, environment: impl Environment, -) -> Result { - let configuration_file = configuration_dir - .as_ref() - .join(crate::CONFIGURATION_FILENAME); - - let configuration_file_contents = - fs::read_to_string(&configuration_file) - .await - .map_err(|err| { - Error::IoErrorButStringified(format!("{}: {}", &configuration_file.display(), err)) - })?; - let configuration_json_value = - serde_json::to_value(configuration_file_contents).map_err(|error| Error::ParseError { - file_path: configuration_file.clone(), - line: error.line(), - column: error.column(), - message: error.to_string(), - })?; - - let version_tag = configuration_json_value - .as_object() - .and_then(|o| o.get("version")) - .and_then(|v| v.as_str()); - match version_tag { - Some("4") => {} - _ => Err(Error::DidNotFindExpectedVersionTag("4".to_string()))?, - } +) -> crate::Configuration { + todo!() +} + +pub async fn write_configuration( + configuration: ParsedConfiguration, + out_dir: impl AsRef, +) -> Result<(), Error> { + let configuration_file = out_dir.as_ref().to_owned().join(CONFIGURATION_FILENAME); + fs::create_dir_all(out_dir.as_ref()).await?; - let mut configuration: RawConfiguration = serde_json::from_value(configuration_json_value) - .map_err(|error| Error::ParseError { - file_path: configuration_file.clone(), - line: error.line(), - column: error.column(), - message: error.to_string(), - })?; - - // look for native query sql file references and read from disk. - for native_query_sql in configuration.metadata.native_queries.0.values_mut() { - native_query_sql.sql = metadata::NativeQuerySqlEither::NativeQuerySql( - native_query_sql - .sql - .from_external(configuration_dir.as_ref()) - .map_err(Error::IoErrorButStringified)?, - ); + // refuse to initialize the directory unless it is empty + let mut items_in_dir = fs::read_dir(out_dir.as_ref()).await?; + if items_in_dir.next_entry().await?.is_some() { + Err(Error::DirectoryIsNotEmpty)?; } - let connection_uri = - match configuration.connection_settings.connection_uri { - ConnectionUri(Secret::Plain(uri)) => Ok(uri), - ConnectionUri(Secret::FromEnvironment { variable }) => environment - .read(&variable) - .map_err(|error| Error::MissingEnvironmentVariable { - file_path: configuration_file, - message: error.to_string(), - }), - }?; - Ok(crate::Configuration { - metadata: convert_metadata(configuration.metadata), - pool_settings: configuration.connection_settings.pool_settings, - connection_uri, - isolation_level: configuration.connection_settings.isolation_level, - mutations_version: convert_mutations_version(configuration.mutations_version), - }) + // create the configuration file + fs::write( + configuration_file, + serde_json::to_string_pretty(&configuration).map_err(|e| Error::IoError(e.into()))? + "\n", + ) + .await?; + + // create the jsonschema file + let configuration_jsonschema_file_path = out_dir + .as_ref() + .to_owned() + .join(CONFIGURATION_JSONSCHEMA_FILENAME); + + let output = schemars::schema_for!(ParsedConfiguration); + fs::write( + &configuration_jsonschema_file_path, + serde_json::to_string_pretty(&output).map_err(|e| Error::IoError(e.into()))? + "\n", + ) + .await?; + + Ok(()) } // This function is used by tests as well diff --git a/crates/connectors/ndc-postgres/src/connector.rs b/crates/connectors/ndc-postgres/src/connector.rs index 2ab12ee0d..182496b36 100644 --- a/crates/connectors/ndc-postgres/src/connector.rs +++ b/crates/connectors/ndc-postgres/src/connector.rs @@ -217,10 +217,12 @@ impl ConnectorSetup for PostgresSetup { &self, configuration_dir: impl AsRef + Send, ) -> Result<::Configuration, connector::ParseError> { - configuration::parse_configuration(configuration_dir, &self.environment) + // Note that we don't log validation errors, because they are part of the normal business + // operation of configuration validation, i.e. they don't represent an error condition that + // signifies that anything has gone wrong with the ndc process or infrastructure. + let parsed_configuration = configuration::parse_configuration(configuration_dir) .instrument(info_span!("parse configuration")) .await - .map(Arc::new) .map_err(|error| match error { configuration::Error::ParseError { file_path, @@ -256,14 +258,16 @@ impl ConnectorSetup for PostgresSetup { connector::ParseError::Other(inner.into()) } configuration::Error::DidNotFindExpectedVersionTag(_) + | configuration::Error::DirectoryIsNotEmpty | configuration::Error::UnableToParseAnyVersions(_) => { connector::ParseError::Other(Box::new(error)) } - }) + })?; - // Note that we don't log validation errors, because they are part of the normal business - // operation of configuration validation, i.e. they don't represent an error condition that - // signifies that anything has gone wrong with the ndc process or infrastructure. + Ok(Arc::new(configuration::make_runtime_configuration( + parsed_configuration, + &self.environment, + ))) } /// Initialize the connector's in-memory state. diff --git a/crates/documentation/openapi/src/generator.rs b/crates/documentation/openapi/src/generator.rs index aea86e22e..4e2fa8325 100644 --- a/crates/documentation/openapi/src/generator.rs +++ b/crates/documentation/openapi/src/generator.rs @@ -1,9 +1,8 @@ use schemars::{gen::SchemaSettings, schema::RootSchema}; -use ndc_postgres_configuration::RawConfiguration; - pub fn generate_schema() -> RootSchema { SchemaSettings::openapi3() .into_generator() - .into_root_schema_for::() + // TODO: Make this part of the public interface of the configuration crate? + .into_root_schema_for::() } 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 8cbbc5fb4..60e46a8a1 100644 --- a/crates/tests/databases-tests/src/ndc_metadata_snapshot_tests.rs +++ b/crates/tests/databases-tests/src/ndc_metadata_snapshot_tests.rs @@ -16,7 +16,8 @@ fn test_snapshot(ndc_metadata_path: PathBuf) { let ndc_metadata_json_value: serde_json::Value = serde_json::from_reader(file).expect("serde_json::from_reader"); - serde_json::from_value::( + // TODO: have this respect the version-agnostic configuration interface? + serde_json::from_value::( ndc_metadata_json_value.clone(), ) .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 index b956b3ab0..1ca488971 100644 --- a/crates/tests/databases-tests/src/postgres/configuration_tests.rs +++ b/crates/tests/databases-tests/src/postgres/configuration_tests.rs @@ -15,7 +15,8 @@ use tests_common::common_tests; #[tokio::test] async fn get_configuration_schema() { - let schema = schemars::schema_for!(ndc_postgres_configuration::RawConfiguration); + // TODO: have this respect the version-agnostic configuration interface? + let schema = schemars::schema_for!(ndc_postgres_configuration::version3::RawConfiguration); insta::assert_json_snapshot!(schema); } diff --git a/crates/tests/tests-common/src/ndc_metadata/configuration.rs b/crates/tests/tests-common/src/ndc_metadata/configuration.rs index b9ea48538..af94e4aaa 100644 --- a/crates/tests/tests-common/src/ndc_metadata/configuration.rs +++ b/crates/tests/tests-common/src/ndc_metadata/configuration.rs @@ -5,7 +5,7 @@ use std::path::Path; use tokio::fs; -use ndc_postgres_configuration::RawConfiguration; +use ndc_postgres_configuration::ParsedConfiguration; use super::helpers::get_path_from_project_root; @@ -19,17 +19,14 @@ pub async fn copy_ndc_metadata_with_new_postgres_url( db_name: &str, ) -> anyhow::Result<()> { let ndc_metadata_dir_path = get_path_from_project_root(main_ndc_metadata_path); + let temp_deploys_path = get_path_from_project_root(temp_deploys_path); let ndc_metadata_path = ndc_metadata_dir_path.join("configuration.json"); - let new_ndc_metadata = serde_json::from_str::( - &std::fs::read_to_string(&ndc_metadata_path) - .map_err(|err| anyhow::anyhow!("{}: {}", &ndc_metadata_path.display(), err))?, - ) - .map_err(|err| anyhow::anyhow!("{}: {}", &ndc_metadata_path.display(), err))?; - - let new_ndc_metadata = set_connection_uri(new_ndc_metadata, new_connection_uri.into()); + let configuration = ndc_postgres_configuration::parse_configuration(ndc_metadata_dir_path) + .await + .map_err(|err| anyhow::anyhow!("{}: {}", &ndc_metadata_path.display(), err))?; - let temp_deploys_path = get_path_from_project_root(temp_deploys_path); + let new_ndc_metadata = set_connection_uri(configuration, new_connection_uri.into()); // make sure the directory where all temp deploys are copied to exists fs::create_dir_all(&temp_deploys_path) @@ -38,31 +35,10 @@ pub async fn copy_ndc_metadata_with_new_postgres_url( let new_ndc_metadata_dir = temp_deploys_path.join(db_name); - copy_dir::copy_dir(&ndc_metadata_dir_path, &new_ndc_metadata_dir).map_err(|err| { - anyhow::anyhow!( - r#"copy_dir failed. -from: {} -to: {} -error: {}"#, - &ndc_metadata_dir_path.display(), - &new_ndc_metadata_dir.display(), - err - ) - })?; + ndc_postgres_configuration::write_configuration(new_ndc_metadata, &new_ndc_metadata_dir) + .await + .map_err(|err| anyhow::anyhow!("{}: {}", &new_ndc_metadata_dir.display(), err))?; - let new_ndc_metadata_path = new_ndc_metadata_dir.join("configuration.json"); - fs::write( - get_path_from_project_root(&new_ndc_metadata_path), - serde_json::to_string_pretty(&new_ndc_metadata)?, - ) - .await - .map_err(|err| { - anyhow::anyhow!( - "{}: {}", - &get_path_from_project_root(new_ndc_metadata_path).display(), - err - ) - })?; Ok(()) } @@ -80,15 +56,15 @@ pub async fn delete_ndc_metadata(ndc_metadata_path: impl AsRef) -> anyhow: Ok(()) } -fn set_connection_uri(input: RawConfiguration, connection_uri: String) -> RawConfiguration { +fn set_connection_uri(input: ParsedConfiguration, connection_uri: String) -> ParsedConfiguration { match input { - RawConfiguration::Version3(mut config) => { + ParsedConfiguration::Version3(mut config) => { config.connection_settings.connection_uri = connection_uri.into(); - RawConfiguration::Version3(config) + ParsedConfiguration::Version3(config) } - RawConfiguration::Version4(mut config) => { + ParsedConfiguration::Version4(mut config) => { config.connection_settings.connection_uri = connection_uri.into(); - RawConfiguration::Version4(config) + ParsedConfiguration::Version4(config) } } } From d1b9ce9ee23daf26141e84b49f6821eb75acfa7b Mon Sep 17 00:00:00 2001 From: Philip Lykke Carlsen Date: Thu, 2 May 2024 13:33:42 +0200 Subject: [PATCH 02/18] Fill in the blanks. Split up configuration error type --- crates/configuration/src/configuration.rs | 31 ++-- crates/configuration/src/error.rs | 26 ++- crates/configuration/src/lib.rs | 6 +- crates/configuration/src/version3/mod.rs | 105 ++++++------ crates/configuration/src/version4/mod.rs | 162 ++++++++++-------- .../connectors/ndc-postgres/src/connector.rs | 44 +++-- .../src/ndc_metadata/configuration.rs | 2 +- 7 files changed, 211 insertions(+), 165 deletions(-) diff --git a/crates/configuration/src/configuration.rs b/crates/configuration/src/configuration.rs index 908bb1b90..e97945759 100644 --- a/crates/configuration/src/configuration.rs +++ b/crates/configuration/src/configuration.rs @@ -5,7 +5,9 @@ use std::path::Path; use query_engine_metadata::metadata; use crate::environment::Environment; -use crate::error::Error; +use crate::error::{ + MakeRuntimeConfigurationError, ParseConfigurationError, WriteParsedConfigurationError, +}; use crate::values::{IsolationLevel, PoolSettings}; use crate::version3; use crate::version4; @@ -62,11 +64,13 @@ pub async fn introspect( pub async fn parse_configuration( configuration_dir: impl AsRef + Send, -) -> Result { +) -> Result { // Try parsing each supported version in turn match version4::parse_configuration(configuration_dir.as_ref()).await { Err(v4_err) => match version3::parse_configuration(configuration_dir.as_ref()).await { - Err(v3_err) => Err(Error::UnableToParseAnyVersions(vec![v3_err, v4_err])), + Err(v3_err) => Err(ParseConfigurationError::UnableToParseAnyVersions(vec![ + v3_err, v4_err, + ])), Ok(config) => Ok(ParsedConfiguration::Version3(config)), }, Ok(config) => Ok(ParsedConfiguration::Version4(config)), @@ -76,16 +80,23 @@ pub async fn parse_configuration( pub fn make_runtime_configuration( parsed_config: ParsedConfiguration, environment: impl Environment, -) -> Configuration { - todo!() +) -> Result { + match parsed_config { + ParsedConfiguration::Version3(c) => version3::make_runtime_configuration(c, environment), + ParsedConfiguration::Version4(c) => version4::make_runtime_configuration(c, environment), + } } /// Write out a runtime configuration to a directory. We would mostly only expect this function to /// support the latest version. -pub async fn write_configuration( - configuration: ParsedConfiguration, +pub async fn write_parsed_configuration( + parsed_config: ParsedConfiguration, out_dir: impl AsRef, -) -> Result<(), Error> { - todo!() - // version4::write_configuration(configuration, out_dir).await +) -> Result<(), WriteParsedConfigurationError> { + match parsed_config { + ParsedConfiguration::Version3(_) => Err( + WriteParsedConfigurationError::VersionNotSupported("3".to_string()), + ), + ParsedConfiguration::Version4(c) => version4::write_parsed_configuration(c, out_dir).await, + } } diff --git a/crates/configuration/src/error.rs b/crates/configuration/src/error.rs index e393db93b..cfa695f78 100644 --- a/crates/configuration/src/error.rs +++ b/crates/configuration/src/error.rs @@ -6,7 +6,7 @@ /// want a dependency on that crate here, as this crate is used by the CLI. Duplicating here and /// converting the values later means we can avoid that dependency. #[derive(Debug, thiserror::Error)] -pub enum Error { +pub enum ParseConfigurationError { #[error("parse error on {file_path}:{line}:{column}: {message}")] ParseError { file_path: std::path::PathBuf, @@ -16,11 +16,6 @@ pub enum Error { }, #[error("empty connection URI")] EmptyConnectionUri { file_path: std::path::PathBuf }, - #[error("missing environment variable when processing {file_path}: {message}")] - MissingEnvironmentVariable { - file_path: std::path::PathBuf, - message: String, - }, #[error("I/O error: {0}")] IoErrorButStringified(String), @@ -32,8 +27,25 @@ pub enum Error { DidNotFindExpectedVersionTag(String), #[error("Unable to parse any configuration versions: TODO")] - UnableToParseAnyVersions(Vec), + UnableToParseAnyVersions(Vec), +} +#[derive(Debug, thiserror::Error)] +pub enum WriteParsedConfigurationError { #[error("directory is not empty")] DirectoryIsNotEmpty, + #[error("Version not supported: {0}")] + VersionNotSupported(String), + + #[error("I/O error: {0}")] + IoError(#[from] std::io::Error), +} + +#[derive(Debug, thiserror::Error)] +pub enum MakeRuntimeConfigurationError { + #[error("missing environment variable when processing {file_path}: {message}")] + MissingEnvironmentVariable { + file_path: std::path::PathBuf, + message: String, + }, } diff --git a/crates/configuration/src/lib.rs b/crates/configuration/src/lib.rs index 71c752cd5..3d2507067 100644 --- a/crates/configuration/src/lib.rs +++ b/crates/configuration/src/lib.rs @@ -2,13 +2,13 @@ mod configuration; mod values; pub mod environment; -mod error; +pub mod error; +// TODO: make these two private! pub mod version3; pub mod version4; pub use configuration::{ - introspect, make_runtime_configuration, parse_configuration, write_configuration, + introspect, make_runtime_configuration, parse_configuration, write_parsed_configuration, Configuration, ParsedConfiguration, }; -pub use error::Error; pub use values::{ConnectionUri, IsolationLevel, PoolSettings, Secret}; diff --git a/crates/configuration/src/version3/mod.rs b/crates/configuration/src/version3/mod.rs index b03917093..6a444d451 100644 --- a/crates/configuration/src/version3/mod.rs +++ b/crates/configuration/src/version3/mod.rs @@ -19,7 +19,7 @@ use tracing::{info_span, Instrument}; use metadata::database; use crate::environment::Environment; -use crate::error::Error; +use crate::error::{MakeRuntimeConfigurationError, ParseConfigurationError}; use crate::values::{ConnectionUri, Secret}; const CONFIGURATION_FILENAME: &str = "configuration.json"; @@ -66,10 +66,10 @@ impl RawConfiguration { pub fn validate_raw_configuration( file_path: PathBuf, config: RawConfiguration, -) -> Result { +) -> Result { match &config.connection_settings.connection_uri { ConnectionUri(Secret::Plain(uri)) if uri.is_empty() => { - Err(Error::EmptyConnectionUri { file_path }) + Err(ParseConfigurationError::EmptyConnectionUri { file_path }) } _ => Ok(()), }?; @@ -497,58 +497,61 @@ fn filter_type_representations( pub async fn parse_configuration( configuration_dir: impl AsRef, - // environment: impl Environment, -) -> Result { - // let configuration_file = configuration_dir.as_ref().join(CONFIGURATION_FILENAME); - // - // let configuration_file_contents = - // fs::read_to_string(&configuration_file) - // .await - // .map_err(|err| { - // Error::IoErrorButStringified(format!("{}: {}", &configuration_file.display(), err)) - // })?; - // let mut configuration: RawConfiguration = serde_json::from_str(&configuration_file_contents) - // .map_err(|error| Error::ParseError { - // file_path: configuration_file.clone(), - // line: error.line(), - // column: error.column(), - // message: error.to_string(), - // })?; - // // look for native query sql file references and read from disk. - // for native_query_sql in configuration.metadata.native_queries.0.values_mut() { - // native_query_sql.sql = metadata::NativeQuerySqlEither::NativeQuerySql( - // native_query_sql - // .sql - // .from_external(configuration_dir.as_ref()) - // .map_err(Error::IoErrorButStringified)?, - // ); - // } - // - // let connection_uri = - // match configuration.connection_settings.connection_uri { - // ConnectionUri(Secret::Plain(uri)) => Ok(uri), - // ConnectionUri(Secret::FromEnvironment { variable }) => environment - // .read(&variable) - // .map_err(|error| Error::MissingEnvironmentVariable { - // file_path: configuration_file, - // message: error.to_string(), - // }), - // }?; - // Ok(crate::Configuration { - // metadata: convert_metadata(configuration.metadata), - // pool_settings: configuration.connection_settings.pool_settings, - // connection_uri, - // isolation_level: configuration.connection_settings.isolation_level, - // mutations_version: convert_mutations_version(configuration.mutations_version), - // }) - todo!() +) -> Result { + let configuration_file = configuration_dir.as_ref().join(CONFIGURATION_FILENAME); + + let configuration_file_contents = + fs::read_to_string(&configuration_file) + .await + .map_err(|err| { + ParseConfigurationError::IoErrorButStringified(format!( + "{}: {}", + &configuration_file.display(), + err + )) + })?; + let mut configuration: RawConfiguration = serde_json::from_str(&configuration_file_contents) + .map_err(|error| ParseConfigurationError::ParseError { + file_path: configuration_file.clone(), + line: error.line(), + column: error.column(), + message: error.to_string(), + })?; + // look for native query sql file references and read from disk. + for native_query_sql in configuration.metadata.native_queries.0.values_mut() { + native_query_sql.sql = metadata::NativeQuerySqlEither::NativeQuerySql( + native_query_sql + .sql + .from_external(configuration_dir.as_ref()) + .map_err(ParseConfigurationError::IoErrorButStringified)?, + ); + } + + Ok(configuration) } pub fn make_runtime_configuration( - parsed_config: RawConfiguration, + configuration: RawConfiguration, environment: impl Environment, -) -> crate::Configuration { - todo!() +) -> Result { + let connection_uri = match configuration.connection_settings.connection_uri { + ConnectionUri(Secret::Plain(uri)) => Ok(uri), + ConnectionUri(Secret::FromEnvironment { variable }) => { + environment.read(&variable).map_err(|error| { + MakeRuntimeConfigurationError::MissingEnvironmentVariable { + file_path: "configuration.json".into(), + message: error.to_string(), + } + }) + } + }?; + Ok(crate::Configuration { + metadata: convert_metadata(configuration.metadata), + pool_settings: configuration.connection_settings.pool_settings, + connection_uri, + isolation_level: configuration.connection_settings.isolation_level, + mutations_version: convert_mutations_version(configuration.mutations_version), + }) } // This function is used by tests as well diff --git a/crates/configuration/src/version4/mod.rs b/crates/configuration/src/version4/mod.rs index bb9ecfb61..daf61b484 100644 --- a/crates/configuration/src/version4/mod.rs +++ b/crates/configuration/src/version4/mod.rs @@ -20,7 +20,9 @@ use tracing::{info_span, Instrument}; use metadata::database; use crate::environment::Environment; -use crate::error::Error; +use crate::error::{ + MakeRuntimeConfigurationError, ParseConfigurationError, WriteParsedConfigurationError, +}; use crate::values::{ConnectionUri, Secret}; const CONFIGURATION_FILENAME: &str = "configuration.json"; @@ -67,10 +69,10 @@ impl ParsedConfiguration { pub fn validate_raw_configuration( file_path: PathBuf, config: ParsedConfiguration, -) -> Result { +) -> Result { match &config.connection_settings.connection_uri { ConnectionUri(Secret::Plain(uri)) if uri.is_empty() => { - Err(Error::EmptyConnectionUri { file_path }) + Err(ParseConfigurationError::EmptyConnectionUri { file_path }) } _ => Ok(()), }?; @@ -407,95 +409,105 @@ fn base_type_representations() -> BTreeMap pub async fn parse_configuration( configuration_dir: impl AsRef, - // environment: impl Environment, -) -> Result { - // let configuration_file = configuration_dir.as_ref().join(CONFIGURATION_FILENAME); - // - // let configuration_file_contents = - // fs::read_to_string(&configuration_file) - // .await - // .map_err(|err| { - // Error::IoErrorButStringified(format!("{}: {}", &configuration_file.display(), err)) - // })?; - // let configuration_json_value = - // serde_json::to_value(configuration_file_contents).map_err(|error| Error::ParseError { - // file_path: configuration_file.clone(), - // line: error.line(), - // column: error.column(), - // message: error.to_string(), - // })?; - // - // let version_tag = configuration_json_value - // .as_object() - // .and_then(|o| o.get("version")) - // .and_then(|v| v.as_str()); - // match version_tag { - // Some("4") => {} - // _ => Err(Error::DidNotFindExpectedVersionTag("4".to_string()))?, - // } - // - // let mut configuration: ParsedConfiguration = serde_json::from_value(configuration_json_value) - // .map_err(|error| Error::ParseError { - // file_path: configuration_file.clone(), - // line: error.line(), - // column: error.column(), - // message: error.to_string(), - // })?; - // - // // look for native query sql file references and read from disk. - // for native_query_sql in configuration.metadata.native_queries.0.values_mut() { - // native_query_sql.sql = metadata::NativeQuerySqlEither::NativeQuerySql( - // native_query_sql - // .sql - // .from_external(configuration_dir.as_ref()) - // .map_err(Error::IoErrorButStringified)?, - // ); - // } - // - // let connection_uri = - // match configuration.connection_settings.connection_uri { - // ConnectionUri(Secret::Plain(uri)) => Ok(uri), - // ConnectionUri(Secret::FromEnvironment { variable }) => environment - // .read(&variable) - // .map_err(|error| Error::MissingEnvironmentVariable { - // file_path: configuration_file, - // message: error.to_string(), - // }), - // }?; - // Ok(crate::Configuration { - // metadata: convert_metadata(configuration.metadata), - // pool_settings: configuration.connection_settings.pool_settings, - // connection_uri, - // isolation_level: configuration.connection_settings.isolation_level, - // mutations_version: convert_mutations_version(configuration.mutations_version), - // }) - todo!() +) -> Result { + let configuration_file = configuration_dir.as_ref().join(CONFIGURATION_FILENAME); + + let configuration_file_contents = + fs::read_to_string(&configuration_file) + .await + .map_err(|err| { + ParseConfigurationError::IoErrorButStringified(format!( + "{}: {}", + &configuration_file.display(), + err + )) + })?; + let configuration_json_value = + serde_json::to_value(configuration_file_contents).map_err(|error| { + ParseConfigurationError::ParseError { + file_path: configuration_file.clone(), + line: error.line(), + column: error.column(), + message: error.to_string(), + } + })?; + + let version_tag = configuration_json_value + .as_object() + .and_then(|o| o.get("version")) + .and_then(|v| v.as_str()); + match version_tag { + Some("4") => {} + _ => Err(ParseConfigurationError::DidNotFindExpectedVersionTag( + "4".to_string(), + ))?, + } + + let mut parsed_config: ParsedConfiguration = serde_json::from_value(configuration_json_value) + .map_err(|error| { + ParseConfigurationError::ParseError { + file_path: configuration_file.clone(), + line: error.line(), + column: error.column(), + message: error.to_string(), + } + })?; + // look for native query sql file references and read from disk. + for native_query_sql in parsed_config.metadata.native_queries.0.values_mut() { + native_query_sql.sql = metadata::NativeQuerySqlEither::NativeQuerySql( + native_query_sql + .sql + .from_external(configuration_dir.as_ref()) + .map_err(ParseConfigurationError::IoErrorButStringified)?, + ); + } + + Ok(parsed_config) } pub fn make_runtime_configuration( parsed_config: ParsedConfiguration, environment: impl Environment, -) -> crate::Configuration { - todo!() +) -> Result { + let connection_uri = match parsed_config.connection_settings.connection_uri { + ConnectionUri(Secret::Plain(uri)) => Ok(uri), + ConnectionUri(Secret::FromEnvironment { variable }) => { + environment.read(&variable).map_err(|error| { + MakeRuntimeConfigurationError::MissingEnvironmentVariable { + file_path: "configuration.json".into(), + message: error.to_string(), + } + }) + } + }?; + Ok(crate::Configuration { + metadata: convert_metadata(parsed_config.metadata), + pool_settings: parsed_config.connection_settings.pool_settings, + connection_uri, + isolation_level: parsed_config.connection_settings.isolation_level, + mutations_version: convert_mutations_version(parsed_config.mutations_version), + }) } -pub async fn write_configuration( - configuration: ParsedConfiguration, +pub async fn write_parsed_configuration( + parsed_config: ParsedConfiguration, out_dir: impl AsRef, -) -> Result<(), Error> { +) -> Result<(), WriteParsedConfigurationError> { let configuration_file = out_dir.as_ref().to_owned().join(CONFIGURATION_FILENAME); fs::create_dir_all(out_dir.as_ref()).await?; // refuse to initialize the directory unless it is empty let mut items_in_dir = fs::read_dir(out_dir.as_ref()).await?; if items_in_dir.next_entry().await?.is_some() { - Err(Error::DirectoryIsNotEmpty)?; + Err(WriteParsedConfigurationError::DirectoryIsNotEmpty)?; } // create the configuration file fs::write( configuration_file, - serde_json::to_string_pretty(&configuration).map_err(|e| Error::IoError(e.into()))? + "\n", + serde_json::to_string_pretty(&parsed_config) + .map_err(|e| WriteParsedConfigurationError::IoError(e.into()))? + + "\n", ) .await?; @@ -508,7 +520,9 @@ pub async fn write_configuration( let output = schemars::schema_for!(ParsedConfiguration); fs::write( &configuration_jsonschema_file_path, - serde_json::to_string_pretty(&output).map_err(|e| Error::IoError(e.into()))? + "\n", + serde_json::to_string_pretty(&output) + .map_err(|e| WriteParsedConfigurationError::IoError(e.into()))? + + "\n", ) .await?; diff --git a/crates/connectors/ndc-postgres/src/connector.rs b/crates/connectors/ndc-postgres/src/connector.rs index 182496b36..11c5496ce 100644 --- a/crates/connectors/ndc-postgres/src/connector.rs +++ b/crates/connectors/ndc-postgres/src/connector.rs @@ -224,7 +224,7 @@ impl ConnectorSetup for PostgresSetup { .instrument(info_span!("parse configuration")) .await .map_err(|error| match error { - configuration::Error::ParseError { + configuration::error::ParseConfigurationError::ParseError { file_path, line, column, @@ -235,7 +235,7 @@ impl ConnectorSetup for PostgresSetup { column, message, }), - configuration::Error::EmptyConnectionUri { file_path } => { + configuration::error::ParseConfigurationError::EmptyConnectionUri { file_path } => { connector::ParseError::ValidateError(connector::InvalidNodes(vec![ connector::InvalidNode { file_path, @@ -244,30 +244,36 @@ impl ConnectorSetup for PostgresSetup { }, ])) } - configuration::Error::MissingEnvironmentVariable { file_path, message } => { - connector::ParseError::ValidateError(connector::InvalidNodes(vec![ - connector::InvalidNode { - file_path, - node_path: vec![connector::KeyOrIndex::Key("connectionUri".into())], - message, - }, - ])) + configuration::error::ParseConfigurationError::IoError(inner) => { + connector::ParseError::IoError(inner) } - configuration::Error::IoError(inner) => connector::ParseError::IoError(inner), - configuration::Error::IoErrorButStringified(inner) => { + configuration::error::ParseConfigurationError::IoErrorButStringified(inner) => { connector::ParseError::Other(inner.into()) } - configuration::Error::DidNotFindExpectedVersionTag(_) - | configuration::Error::DirectoryIsNotEmpty - | configuration::Error::UnableToParseAnyVersions(_) => { + configuration::error::ParseConfigurationError::DidNotFindExpectedVersionTag(_) + | configuration::error::ParseConfigurationError::UnableToParseAnyVersions(_) => { connector::ParseError::Other(Box::new(error)) } })?; - Ok(Arc::new(configuration::make_runtime_configuration( - parsed_configuration, - &self.environment, - ))) + let runtime_configuration = + configuration::make_runtime_configuration(parsed_configuration, &self.environment) + .map_err(|error| { + match error { + configuration::error::MakeRuntimeConfigurationError::MissingEnvironmentVariable { + file_path, + message, + } => connector::ParseError::ValidateError(connector::InvalidNodes(vec![ + connector::InvalidNode { + file_path, + node_path: vec![connector::KeyOrIndex::Key("connectionUri".into())], + message, + }, + ])), + } + })?; + + Ok(Arc::new(runtime_configuration)) } /// Initialize the connector's in-memory state. diff --git a/crates/tests/tests-common/src/ndc_metadata/configuration.rs b/crates/tests/tests-common/src/ndc_metadata/configuration.rs index af94e4aaa..f8b1dc7bb 100644 --- a/crates/tests/tests-common/src/ndc_metadata/configuration.rs +++ b/crates/tests/tests-common/src/ndc_metadata/configuration.rs @@ -35,7 +35,7 @@ pub async fn copy_ndc_metadata_with_new_postgres_url( let new_ndc_metadata_dir = temp_deploys_path.join(db_name); - ndc_postgres_configuration::write_configuration(new_ndc_metadata, &new_ndc_metadata_dir) + ndc_postgres_configuration::write_parsed_configuration(new_ndc_metadata, &new_ndc_metadata_dir) .await .map_err(|err| anyhow::anyhow!("{}: {}", &new_ndc_metadata_dir.display(), err))?; From 87d29ec92cbf141f90c02285d20e942d8da03af3 Mon Sep 17 00:00:00 2001 From: Philip Lykke Carlsen Date: Thu, 2 May 2024 14:05:38 +0200 Subject: [PATCH 03/18] Upgrade action stub --- crates/cli/src/lib.rs | 61 ++++++----------------- crates/cli/tests/initialize_tests.rs | 2 +- crates/cli/tests/update_tests.rs | 5 +- crates/configuration/src/configuration.rs | 9 ++++ crates/configuration/src/lib.rs | 4 +- crates/configuration/src/version4/mod.rs | 6 +++ 6 files changed, 35 insertions(+), 52 deletions(-) diff --git a/crates/cli/src/lib.rs b/crates/cli/src/lib.rs index b5a44581f..e480f007d 100644 --- a/crates/cli/src/lib.rs +++ b/crates/cli/src/lib.rs @@ -53,7 +53,7 @@ pub async fn run(command: Command, context: Context) -> anyhow match command { Command::Initialize { with_metadata } => initialize(with_metadata, context).await?, Command::Update => update(context).await?, - Command::Upgrade { dir_from, dir_to } => upgrade(dir_from, dir_to, context).await?, + Command::Upgrade { dir_from, dir_to } => upgrade(dir_from, dir_to).await?, }; Ok(()) } @@ -67,7 +67,7 @@ pub async fn run(command: Command, context: Context) -> anyhow /// Optionally, this can also create the connector metadata, which is used by the Hasura CLI to /// automatically work with this CLI as a plugin. async fn initialize(with_metadata: bool, context: Context) -> anyhow::Result<()> { - configuration::write_configuration( + configuration::write_parsed_configuration( configuration::ParsedConfiguration::initial(), &context.context_path, ) @@ -123,36 +123,22 @@ async fn update(context: Context) -> anyhow::Result<()> { // We do that with a few attempts. for _attempt in 1..=UPDATE_ATTEMPTS { let existing_configuration = - configuration::parse_configuration(context.context_path, context.environment); - let configuration_file_path = context - .context_path - .join(configuration::CONFIGURATION_FILENAME); - let input: configuration::ParsedConfiguration = { - let configuration_file_contents = - read_config_file_contents(&configuration_file_path).await?; - serde_json::from_str(&configuration_file_contents)? - }; - let output = configuration::introspect(input.clone(), &context.environment).await?; + configuration::parse_configuration(&context.context_path).await?; + let output = + configuration::introspect(existing_configuration.clone(), &context.environment).await?; // Check that the input file did not change since we started introspecting, - let input_again_before_write: configuration::ParsedConfiguration = { - let configuration_file_contents = - read_config_file_contents(&configuration_file_path).await?; - serde_json::from_str(&configuration_file_contents)? - }; + let input_again_before_write = + configuration::parse_configuration(&context.context_path).await?; // and skip this attempt if it has. - if input_again_before_write == input { + if input_again_before_write == existing_configuration { // If the introspection result is different than the current config, // change it. Otherwise, continue. - if input == output { + if existing_configuration == output { // The configuration is up-to-date. Nothing to do. } else { - fs::write( - &configuration_file_path, - serde_json::to_string_pretty(&output)? + "\n", - ) - .await?; + configuration::write_parsed_configuration(output, &context.context_path).await?; } return Ok(()); } @@ -169,27 +155,10 @@ async fn update(context: Context) -> anyhow::Result<()> { /// Upgrade the configuration in a directory by trying to read it and then write it back /// out to a different directory. /// -async fn upgrade( - dir_from: PathBuf, - dir_to: PathBuf, - context: Context, -) -> anyhow::Result<()> { - let configuration = configuration::parse_configuration(dir_from, context.environment).await?; - configuration::write_configuration(configuration, dir_to).await?; +async fn upgrade(dir_from: PathBuf, dir_to: PathBuf) -> anyhow::Result<()> { + let old_configuration = configuration::parse_configuration(dir_from).await?; + let upgraded_configuration = configuration::upgrade_to_latest_version(old_configuration) + .map_err(|e| anyhow::anyhow!("{e:?}"))?; + configuration::write_parsed_configuration(upgraded_configuration, dir_to).await?; Ok(()) } - -async fn read_config_file_contents(configuration_file_path: &PathBuf) -> anyhow::Result { - fs::read_to_string(configuration_file_path) - .await - .map_err(|err| { - if err.kind() == std::io::ErrorKind::NotFound { - anyhow::anyhow!( - "{}: No such file or directory.", - configuration_file_path.display() - ) - } else { - err.into() - } - }) -} diff --git a/crates/cli/tests/initialize_tests.rs b/crates/cli/tests/initialize_tests.rs index ef221a2ca..59f330df6 100644 --- a/crates/cli/tests/initialize_tests.rs +++ b/crates/cli/tests/initialize_tests.rs @@ -31,7 +31,7 @@ async fn test_initialize_directory() -> anyhow::Result<()> { assert!(configuration_file_path.exists()); let contents = fs::read_to_string(configuration_file_path).await?; common::assert_ends_with_newline(&contents); - let _: ParsedConfiguration = serde_json::from_str(&contents)?; + let _: ParsedConfiguration = configuration::parse_configuration(&dir).await?; let metadata_file_path = dir .path() diff --git a/crates/cli/tests/update_tests.rs b/crates/cli/tests/update_tests.rs index 64e457259..1817fec89 100644 --- a/crates/cli/tests/update_tests.rs +++ b/crates/cli/tests/update_tests.rs @@ -18,7 +18,6 @@ async fn test_update_configuration() -> anyhow::Result<()> { }); { - let configuration_file_path = dir.path().join("configuration.json"); let connection_settings = configuration::version3::connection_settings::DatabaseConnectionSettings { connection_uri: connection_uri.clone(), @@ -28,7 +27,7 @@ async fn test_update_configuration() -> anyhow::Result<()> { connection_settings, ..configuration::version3::RawConfiguration::empty() }); - fs::write(configuration_file_path, serde_json::to_string(&input)?).await?; + configuration::write_parsed_configuration(input, &dir).await?; } let environment = @@ -44,7 +43,7 @@ async fn test_update_configuration() -> anyhow::Result<()> { assert!(configuration_file_path.exists()); let contents = fs::read_to_string(configuration_file_path).await?; common::assert_ends_with_newline(&contents); - let output: ParsedConfiguration = serde_json::from_str(&contents)?; + let output: ParsedConfiguration = configuration::parse_configuration(&dir).await?; match output { ParsedConfiguration::Version3(configuration::version3::RawConfiguration { connection_settings, diff --git a/crates/configuration/src/configuration.rs b/crates/configuration/src/configuration.rs index e97945759..137f1d3d9 100644 --- a/crates/configuration/src/configuration.rs +++ b/crates/configuration/src/configuration.rs @@ -100,3 +100,12 @@ pub async fn write_parsed_configuration( ParsedConfiguration::Version4(c) => version4::write_parsed_configuration(c, out_dir).await, } } + +pub fn upgrade_to_latest_version( + parsed_config: ParsedConfiguration, +) -> Result { + match parsed_config { + ParsedConfiguration::Version3(v) => version4::upgrade_from_v3(v), + ParsedConfiguration::Version4(_) => Ok(parsed_config), + } +} diff --git a/crates/configuration/src/lib.rs b/crates/configuration/src/lib.rs index 3d2507067..b2c89bc02 100644 --- a/crates/configuration/src/lib.rs +++ b/crates/configuration/src/lib.rs @@ -8,7 +8,7 @@ pub mod version3; pub mod version4; pub use configuration::{ - introspect, make_runtime_configuration, parse_configuration, write_parsed_configuration, - Configuration, ParsedConfiguration, + introspect, make_runtime_configuration, parse_configuration, upgrade_to_latest_version, + write_parsed_configuration, Configuration, ParsedConfiguration, }; pub use values::{ConnectionUri, IsolationLevel, PoolSettings, Secret}; diff --git a/crates/configuration/src/version4/mod.rs b/crates/configuration/src/version4/mod.rs index daf61b484..36243214f 100644 --- a/crates/configuration/src/version4/mod.rs +++ b/crates/configuration/src/version4/mod.rs @@ -1009,3 +1009,9 @@ fn convert_mutations_version( } }) } + +pub(crate) fn upgrade_from_v3( + v: crate::version3::RawConfiguration, +) -> Result { + todo!() +} From 443ae397493f2bccd0aa8ff9162f96aae03d566a Mon Sep 17 00:00:00 2001 From: Philip Lykke Carlsen Date: Thu, 2 May 2024 14:11:44 +0200 Subject: [PATCH 04/18] Move conversion function to separate file --- crates/configuration/src/version4/mod.rs | 512 +----------------- .../src/version4/to_runtime_configuration.rs | 512 ++++++++++++++++++ 2 files changed, 515 insertions(+), 509 deletions(-) create mode 100644 crates/configuration/src/version4/to_runtime_configuration.rs diff --git a/crates/configuration/src/version4/mod.rs b/crates/configuration/src/version4/mod.rs index 36243214f..60bed2e2c 100644 --- a/crates/configuration/src/version4/mod.rs +++ b/crates/configuration/src/version4/mod.rs @@ -4,12 +4,13 @@ mod comparison; pub mod connection_settings; mod metadata; mod options; +mod to_runtime_configuration; use std::borrow::Cow; use std::collections::BTreeMap; use std::path::{Path, PathBuf}; +pub use to_runtime_configuration::make_runtime_configuration; -use query_engine_metadata; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use sqlx::postgres::PgConnection; @@ -20,9 +21,7 @@ use tracing::{info_span, Instrument}; use metadata::database; use crate::environment::Environment; -use crate::error::{ - MakeRuntimeConfigurationError, ParseConfigurationError, WriteParsedConfigurationError, -}; +use crate::error::{ParseConfigurationError, WriteParsedConfigurationError}; use crate::values::{ConnectionUri, Secret}; const CONFIGURATION_FILENAME: &str = "configuration.json"; @@ -465,30 +464,6 @@ pub async fn parse_configuration( Ok(parsed_config) } -pub fn make_runtime_configuration( - parsed_config: ParsedConfiguration, - environment: impl Environment, -) -> Result { - let connection_uri = match parsed_config.connection_settings.connection_uri { - ConnectionUri(Secret::Plain(uri)) => Ok(uri), - ConnectionUri(Secret::FromEnvironment { variable }) => { - environment.read(&variable).map_err(|error| { - MakeRuntimeConfigurationError::MissingEnvironmentVariable { - file_path: "configuration.json".into(), - message: error.to_string(), - } - }) - } - }?; - Ok(crate::Configuration { - metadata: convert_metadata(parsed_config.metadata), - pool_settings: parsed_config.connection_settings.pool_settings, - connection_uri, - isolation_level: parsed_config.connection_settings.isolation_level, - mutations_version: convert_mutations_version(parsed_config.mutations_version), - }) -} - pub async fn write_parsed_configuration( parsed_config: ParsedConfiguration, out_dir: impl AsRef, @@ -529,487 +504,6 @@ pub async fn write_parsed_configuration( Ok(()) } -// This function is used by tests as well -pub fn convert_metadata(metadata: metadata::Metadata) -> query_engine_metadata::metadata::Metadata { - // let (scalar_types, composite_types) = transitively_occurring_types( - // occurring_scalar_types( - // &metadata.tables, - // &metadata.native_queries, - // &metadata.aggregate_functions, - // ), - // &occurring_composite_types(&metadata.tables, &metadata.native_queries), - // metadata.composite_types, - // ); - // - query_engine_metadata::metadata::Metadata { - tables: convert_tables(metadata.tables), - composite_types: convert_composite_types(metadata.composite_types), - native_queries: convert_native_queries(metadata.native_queries), - scalar_types: convert_scalar_types(metadata.scalar_types), - } -} - -fn convert_scalar_types( - scalar_types: metadata::ScalarTypes, -) -> query_engine_metadata::metadata::ScalarTypes { - // let aggregates = convert_aggregate_functions(aggregate_functions); - // let comparisons = convert_comparison_operators(comparison_operators); - // let representations = convert_type_representations(type_representations); - - query_engine_metadata::metadata::ScalarTypes( - scalar_types - .0 - .into_iter() - .map(|(scalar_type_name, scalar_type)| { - ( - convert_scalar_type_name(scalar_type_name.clone()), - query_engine_metadata::metadata::ScalarType { - type_name: scalar_type.type_name, - schema_name: Some(scalar_type.schema_name), - description: scalar_type.description, - aggregate_functions: scalar_type - .aggregate_functions - .into_iter() - .map(|(k, v)| (k, convert_aggregate_function(v))) - .collect(), - comparison_operators: scalar_type - .comparison_operators - .into_iter() - .map(|(k, v)| (k, convert_comparison_operator(v))) - .collect(), - type_representation: scalar_type - .type_representation - .map(convert_type_representation), - }, - ) - }) - .collect(), - ) -} - -fn convert_scalar_type_name( - scalar_type_name: metadata::ScalarTypeName, -) -> query_engine_metadata::metadata::ScalarTypeName { - query_engine_metadata::metadata::ScalarTypeName(scalar_type_name.0) -} - -fn convert_aggregate_function( - aggregate_function: metadata::AggregateFunction, -) -> query_engine_metadata::metadata::AggregateFunction { - query_engine_metadata::metadata::AggregateFunction { - return_type: convert_scalar_type_name(aggregate_function.return_type), - } -} - -fn convert_native_queries( - native_queries: metadata::NativeQueries, -) -> query_engine_metadata::metadata::NativeQueries { - query_engine_metadata::metadata::NativeQueries( - native_queries - .0 - .into_iter() - .map(|(k, v)| (k, convert_native_query_info(v))) - .collect(), - ) -} - -fn convert_native_query_info( - native_query_info: metadata::NativeQueryInfo, -) -> query_engine_metadata::metadata::NativeQueryInfo { - query_engine_metadata::metadata::NativeQueryInfo { - sql: convert_native_query_sql_either(native_query_info.sql), - columns: native_query_info - .columns - .into_iter() - .map(|(k, v)| (k, convert_read_only_column_info(v))) - .collect(), - arguments: native_query_info - .arguments - .into_iter() - .map(|(k, v)| (k, convert_read_only_column_info(v))) - .collect(), - description: native_query_info.description, - is_procedure: native_query_info.is_procedure, - } -} - -fn convert_read_only_column_info( - read_only_column_info: metadata::ReadOnlyColumnInfo, -) -> query_engine_metadata::metadata::ReadOnlyColumnInfo { - query_engine_metadata::metadata::ReadOnlyColumnInfo { - name: read_only_column_info.name, - r#type: convert_type(read_only_column_info.r#type), - nullable: convert_nullable(&read_only_column_info.nullable), - description: read_only_column_info.description, - } -} - -fn convert_nullable(nullable: &metadata::Nullable) -> query_engine_metadata::metadata::Nullable { - match nullable { - metadata::Nullable::Nullable => query_engine_metadata::metadata::Nullable::Nullable, - metadata::Nullable::NonNullable => query_engine_metadata::metadata::Nullable::NonNullable, - } -} - -fn convert_type(r#type: metadata::Type) -> query_engine_metadata::metadata::Type { - match r#type { - metadata::Type::ScalarType(t) => { - query_engine_metadata::metadata::Type::ScalarType(convert_scalar_type_name(t)) - } - metadata::Type::CompositeType(t) => query_engine_metadata::metadata::Type::CompositeType( - query_engine_metadata::metadata::CompositeTypeName(t.0), - ), - metadata::Type::ArrayType(t) => { - query_engine_metadata::metadata::Type::ArrayType(Box::new(convert_type(*t))) - } - } -} - -fn convert_native_query_sql_either( - sql: metadata::NativeQuerySqlEither, -) -> query_engine_metadata::metadata::NativeQuerySqlEither { - match sql { - metadata::NativeQuerySqlEither::NativeQuerySql(internal_sql) => { - query_engine_metadata::metadata::NativeQuerySqlEither::NativeQuerySql( - convert_native_query_sql_internal(internal_sql), - ) - } - metadata::NativeQuerySqlEither::NativeQuerySqlExternal(external_sql) => { - query_engine_metadata::metadata::NativeQuerySqlEither::NativeQuerySqlExternal( - convert_native_query_sql_external(external_sql), - ) - } - } -} - -fn convert_native_query_sql_internal( - internal_sql: metadata::NativeQuerySql, -) -> query_engine_metadata::metadata::NativeQuerySql { - match internal_sql { - metadata::NativeQuerySql::FromFile { file, sql } => { - query_engine_metadata::metadata::NativeQuerySql::FromFile { - file, - sql: convert_native_query_parts(sql), - } - } - metadata::NativeQuerySql::Inline { sql } => { - query_engine_metadata::metadata::NativeQuerySql::Inline { - sql: convert_native_query_parts(sql), - } - } - } -} - -fn convert_native_query_sql_external( - external_sql: metadata::NativeQuerySqlExternal, -) -> query_engine_metadata::metadata::NativeQuerySqlExternal { - match external_sql { - metadata::NativeQuerySqlExternal::File { file } => { - query_engine_metadata::metadata::NativeQuerySqlExternal::File { file } - } - metadata::NativeQuerySqlExternal::Inline { inline } => { - query_engine_metadata::metadata::NativeQuerySqlExternal::Inline { - inline: convert_native_query_parts(inline), - } - } - metadata::NativeQuerySqlExternal::InlineUntagged(parts) => { - query_engine_metadata::metadata::NativeQuerySqlExternal::InlineUntagged( - convert_native_query_parts(parts), - ) - } - } -} - -fn convert_native_query_parts( - inline: metadata::NativeQueryParts, -) -> query_engine_metadata::metadata::NativeQueryParts { - query_engine_metadata::metadata::NativeQueryParts( - inline - .0 - .into_iter() - .map(convert_native_query_part) - .collect(), - ) -} - -fn convert_native_query_part( - native_query_part: metadata::NativeQueryPart, -) -> query_engine_metadata::metadata::NativeQueryPart { - match native_query_part { - metadata::NativeQueryPart::Text(t) => { - query_engine_metadata::metadata::NativeQueryPart::Text(t) - } - metadata::NativeQueryPart::Parameter(p) => { - query_engine_metadata::metadata::NativeQueryPart::Parameter(p) - } - } -} - -fn convert_type_representation( - type_representation: metadata::TypeRepresentation, -) -> query_engine_metadata::metadata::TypeRepresentation { - match type_representation { - metadata::TypeRepresentation::Boolean => { - query_engine_metadata::metadata::TypeRepresentation::Boolean - } - metadata::TypeRepresentation::String => { - query_engine_metadata::metadata::TypeRepresentation::String - } - metadata::TypeRepresentation::Float32 => { - query_engine_metadata::metadata::TypeRepresentation::Float32 - } - metadata::TypeRepresentation::Float64 => { - query_engine_metadata::metadata::TypeRepresentation::Float64 - } - metadata::TypeRepresentation::Int16 => { - query_engine_metadata::metadata::TypeRepresentation::Int16 - } - metadata::TypeRepresentation::Int32 => { - query_engine_metadata::metadata::TypeRepresentation::Int32 - } - metadata::TypeRepresentation::Int64 => { - query_engine_metadata::metadata::TypeRepresentation::Int64 - } - metadata::TypeRepresentation::Int64AsString => { - query_engine_metadata::metadata::TypeRepresentation::Int64AsString - } - metadata::TypeRepresentation::BigDecimal => { - query_engine_metadata::metadata::TypeRepresentation::BigDecimal - } - metadata::TypeRepresentation::BigDecimalAsString => { - query_engine_metadata::metadata::TypeRepresentation::BigDecimalAsString - } - metadata::TypeRepresentation::Timestamp => { - query_engine_metadata::metadata::TypeRepresentation::Timestamp - } - metadata::TypeRepresentation::Timestamptz => { - query_engine_metadata::metadata::TypeRepresentation::Timestamptz - } - metadata::TypeRepresentation::Time => { - query_engine_metadata::metadata::TypeRepresentation::Time - } - metadata::TypeRepresentation::Timetz => { - query_engine_metadata::metadata::TypeRepresentation::Timetz - } - metadata::TypeRepresentation::Date => { - query_engine_metadata::metadata::TypeRepresentation::Date - } - metadata::TypeRepresentation::UUID => { - query_engine_metadata::metadata::TypeRepresentation::UUID - } - metadata::TypeRepresentation::Geography => { - query_engine_metadata::metadata::TypeRepresentation::Geography - } - metadata::TypeRepresentation::Geometry => { - query_engine_metadata::metadata::TypeRepresentation::Geometry - } - // This is deprecated in ndc-spec - metadata::TypeRepresentation::Number - | metadata::TypeRepresentation::Integer - | metadata::TypeRepresentation::Json => { - query_engine_metadata::metadata::TypeRepresentation::Json - } - metadata::TypeRepresentation::Enum(v) => { - query_engine_metadata::metadata::TypeRepresentation::Enum(v) - } - } -} - -fn convert_comparison_operator( - comparison_operator: metadata::ComparisonOperator, -) -> query_engine_metadata::metadata::ComparisonOperator { - query_engine_metadata::metadata::ComparisonOperator { - operator_name: comparison_operator.operator_name, - operator_kind: convert_operator_kind(&comparison_operator.operator_kind), - argument_type: convert_scalar_type_name(comparison_operator.argument_type), - is_infix: comparison_operator.is_infix, - } -} - -fn convert_operator_kind( - operator_kind: &metadata::OperatorKind, -) -> query_engine_metadata::metadata::OperatorKind { - match operator_kind { - metadata::OperatorKind::Equal => query_engine_metadata::metadata::OperatorKind::Equal, - metadata::OperatorKind::In => query_engine_metadata::metadata::OperatorKind::In, - metadata::OperatorKind::Custom => query_engine_metadata::metadata::OperatorKind::Custom, - } -} - -fn convert_composite_types( - composite_types: metadata::CompositeTypes, -) -> query_engine_metadata::metadata::CompositeTypes { - query_engine_metadata::metadata::CompositeTypes( - composite_types - .0 - .into_iter() - .map(|(k, composite_type)| { - ( - query_engine_metadata::metadata::CompositeTypeName(k), - convert_composite_type(composite_type), - ) - }) - .collect(), - ) -} - -fn convert_composite_type( - composite_type: metadata::CompositeType, -) -> query_engine_metadata::metadata::CompositeType { - query_engine_metadata::metadata::CompositeType { - type_name: composite_type.type_name, - schema_name: Some(composite_type.schema_name), - fields: composite_type - .fields - .into_iter() - .map(|(k, field)| (k, convert_composite_type_field_info(field))) - .collect(), - description: composite_type.description, - } -} - -fn convert_composite_type_field_info( - field: metadata::FieldInfo, -) -> query_engine_metadata::metadata::FieldInfo { - query_engine_metadata::metadata::FieldInfo { - field_name: field.field_name, - r#type: convert_type(field.r#type), - description: field.description, - } -} - -pub fn convert_tables(tables: metadata::TablesInfo) -> query_engine_metadata::metadata::TablesInfo { - query_engine_metadata::metadata::TablesInfo( - tables - .0 - .into_iter() - .map(|(k, table_info)| (k, convert_table_info(table_info))) - .collect(), - ) -} - -fn convert_table_info( - table_info: metadata::TableInfo, -) -> query_engine_metadata::metadata::TableInfo { - query_engine_metadata::metadata::TableInfo { - schema_name: table_info.schema_name, - table_name: table_info.table_name, - columns: table_info - .columns - .into_iter() - .map(|(k, column_info)| (k, convert_column_info(column_info))) - .collect(), - uniqueness_constraints: convert_uniqueness_constraints(table_info.uniqueness_constraints), - foreign_relations: convert_foreign_relations(table_info.foreign_relations), - description: table_info.description, - } -} - -fn convert_foreign_relations( - foreign_relations: metadata::ForeignRelations, -) -> query_engine_metadata::metadata::ForeignRelations { - query_engine_metadata::metadata::ForeignRelations( - foreign_relations - .0 - .into_iter() - .map(|(k, foreign_relation)| (k, convert_foreign_relation(foreign_relation))) - .collect(), - ) -} - -fn convert_foreign_relation( - foreign_relation: metadata::ForeignRelation, -) -> query_engine_metadata::metadata::ForeignRelation { - query_engine_metadata::metadata::ForeignRelation { - foreign_schema: foreign_relation.foreign_schema, - foreign_table: foreign_relation.foreign_table, - column_mapping: foreign_relation.column_mapping, - } -} - -fn convert_uniqueness_constraints( - uniqueness_constraints: metadata::UniquenessConstraints, -) -> query_engine_metadata::metadata::UniquenessConstraints { - query_engine_metadata::metadata::UniquenessConstraints( - uniqueness_constraints - .0 - .into_iter() - .map(|(k, uniqueness_constraint)| { - (k, convert_uniqueness_constraint(uniqueness_constraint)) - }) - .collect(), - ) -} - -fn convert_uniqueness_constraint( - uniqueness_constraint: metadata::UniquenessConstraint, -) -> query_engine_metadata::metadata::UniquenessConstraint { - query_engine_metadata::metadata::UniquenessConstraint(uniqueness_constraint.0) -} - -fn convert_column_info( - column_info: metadata::ColumnInfo, -) -> query_engine_metadata::metadata::ColumnInfo { - query_engine_metadata::metadata::ColumnInfo { - name: column_info.name, - r#type: convert_type(column_info.r#type), - nullable: convert_nullable(&column_info.nullable), - has_default: convert_has_default(&column_info.has_default), - is_identity: convert_is_identity(&column_info.is_identity), - is_generated: convert_is_generated(&column_info.is_generated), - description: column_info.description, - } -} - -fn convert_is_generated( - is_generated: &metadata::IsGenerated, -) -> query_engine_metadata::metadata::IsGenerated { - match is_generated { - metadata::IsGenerated::NotGenerated => { - query_engine_metadata::metadata::IsGenerated::NotGenerated - } - metadata::IsGenerated::Stored => query_engine_metadata::metadata::IsGenerated::Stored, - } -} - -fn convert_is_identity( - is_identity: &metadata::IsIdentity, -) -> query_engine_metadata::metadata::IsIdentity { - match is_identity { - metadata::IsIdentity::NotIdentity => { - query_engine_metadata::metadata::IsIdentity::NotIdentity - } - metadata::IsIdentity::IdentityByDefault => { - query_engine_metadata::metadata::IsIdentity::IdentityByDefault - } - metadata::IsIdentity::IdentityAlways => { - query_engine_metadata::metadata::IsIdentity::IdentityAlways - } - } -} - -fn convert_has_default( - has_default: &metadata::HasDefault, -) -> query_engine_metadata::metadata::HasDefault { - match has_default { - metadata::HasDefault::NoDefault => query_engine_metadata::metadata::HasDefault::NoDefault, - metadata::HasDefault::HasDefault => query_engine_metadata::metadata::HasDefault::HasDefault, - } -} - -fn convert_mutations_version( - mutations_version_opt: Option, -) -> Option { - mutations_version_opt.map(|mutations_version| match mutations_version { - metadata::mutations::MutationsVersion::V1 => { - query_engine_metadata::metadata::mutations::MutationsVersion::V1 - } - metadata::mutations::MutationsVersion::VeryExperimentalWip => { - query_engine_metadata::metadata::mutations::MutationsVersion::VeryExperimentalWip - } - }) -} - pub(crate) fn upgrade_from_v3( v: crate::version3::RawConfiguration, ) -> Result { diff --git a/crates/configuration/src/version4/to_runtime_configuration.rs b/crates/configuration/src/version4/to_runtime_configuration.rs new file mode 100644 index 000000000..1bc0c0b36 --- /dev/null +++ b/crates/configuration/src/version4/to_runtime_configuration.rs @@ -0,0 +1,512 @@ +use query_engine_metadata; + +use super::metadata; +use super::ParsedConfiguration; +use crate::environment::Environment; +use crate::error::MakeRuntimeConfigurationError; +use crate::values::{ConnectionUri, Secret}; + +pub fn make_runtime_configuration( + parsed_config: ParsedConfiguration, + environment: impl Environment, +) -> Result { + let connection_uri = match parsed_config.connection_settings.connection_uri { + ConnectionUri(Secret::Plain(uri)) => Ok(uri), + ConnectionUri(Secret::FromEnvironment { variable }) => { + environment.read(&variable).map_err(|error| { + MakeRuntimeConfigurationError::MissingEnvironmentVariable { + file_path: "configuration.json".into(), + message: error.to_string(), + } + }) + } + }?; + Ok(crate::Configuration { + metadata: convert_metadata(parsed_config.metadata), + pool_settings: parsed_config.connection_settings.pool_settings, + connection_uri, + isolation_level: parsed_config.connection_settings.isolation_level, + mutations_version: convert_mutations_version(parsed_config.mutations_version), + }) +} + +// This function is used by tests as well +pub fn convert_metadata(metadata: metadata::Metadata) -> query_engine_metadata::metadata::Metadata { + // let (scalar_types, composite_types) = transitively_occurring_types( + // occurring_scalar_types( + // &metadata.tables, + // &metadata.native_queries, + // &metadata.aggregate_functions, + // ), + // &occurring_composite_types(&metadata.tables, &metadata.native_queries), + // metadata.composite_types, + // ); + // + query_engine_metadata::metadata::Metadata { + tables: convert_tables(metadata.tables), + composite_types: convert_composite_types(metadata.composite_types), + native_queries: convert_native_queries(metadata.native_queries), + scalar_types: convert_scalar_types(metadata.scalar_types), + } +} + +fn convert_scalar_types( + scalar_types: metadata::ScalarTypes, +) -> query_engine_metadata::metadata::ScalarTypes { + // let aggregates = convert_aggregate_functions(aggregate_functions); + // let comparisons = convert_comparison_operators(comparison_operators); + // let representations = convert_type_representations(type_representations); + + query_engine_metadata::metadata::ScalarTypes( + scalar_types + .0 + .into_iter() + .map(|(scalar_type_name, scalar_type)| { + ( + convert_scalar_type_name(scalar_type_name.clone()), + query_engine_metadata::metadata::ScalarType { + type_name: scalar_type.type_name, + schema_name: Some(scalar_type.schema_name), + description: scalar_type.description, + aggregate_functions: scalar_type + .aggregate_functions + .into_iter() + .map(|(k, v)| (k, convert_aggregate_function(v))) + .collect(), + comparison_operators: scalar_type + .comparison_operators + .into_iter() + .map(|(k, v)| (k, convert_comparison_operator(v))) + .collect(), + type_representation: scalar_type + .type_representation + .map(convert_type_representation), + }, + ) + }) + .collect(), + ) +} + +fn convert_scalar_type_name( + scalar_type_name: metadata::ScalarTypeName, +) -> query_engine_metadata::metadata::ScalarTypeName { + query_engine_metadata::metadata::ScalarTypeName(scalar_type_name.0) +} + +fn convert_aggregate_function( + aggregate_function: metadata::AggregateFunction, +) -> query_engine_metadata::metadata::AggregateFunction { + query_engine_metadata::metadata::AggregateFunction { + return_type: convert_scalar_type_name(aggregate_function.return_type), + } +} + +fn convert_native_queries( + native_queries: metadata::NativeQueries, +) -> query_engine_metadata::metadata::NativeQueries { + query_engine_metadata::metadata::NativeQueries( + native_queries + .0 + .into_iter() + .map(|(k, v)| (k, convert_native_query_info(v))) + .collect(), + ) +} + +fn convert_native_query_info( + native_query_info: metadata::NativeQueryInfo, +) -> query_engine_metadata::metadata::NativeQueryInfo { + query_engine_metadata::metadata::NativeQueryInfo { + sql: convert_native_query_sql_either(native_query_info.sql), + columns: native_query_info + .columns + .into_iter() + .map(|(k, v)| (k, convert_read_only_column_info(v))) + .collect(), + arguments: native_query_info + .arguments + .into_iter() + .map(|(k, v)| (k, convert_read_only_column_info(v))) + .collect(), + description: native_query_info.description, + is_procedure: native_query_info.is_procedure, + } +} + +fn convert_read_only_column_info( + read_only_column_info: metadata::ReadOnlyColumnInfo, +) -> query_engine_metadata::metadata::ReadOnlyColumnInfo { + query_engine_metadata::metadata::ReadOnlyColumnInfo { + name: read_only_column_info.name, + r#type: convert_type(read_only_column_info.r#type), + nullable: convert_nullable(&read_only_column_info.nullable), + description: read_only_column_info.description, + } +} + +fn convert_nullable(nullable: &metadata::Nullable) -> query_engine_metadata::metadata::Nullable { + match nullable { + metadata::Nullable::Nullable => query_engine_metadata::metadata::Nullable::Nullable, + metadata::Nullable::NonNullable => query_engine_metadata::metadata::Nullable::NonNullable, + } +} + +fn convert_type(r#type: metadata::Type) -> query_engine_metadata::metadata::Type { + match r#type { + metadata::Type::ScalarType(t) => { + query_engine_metadata::metadata::Type::ScalarType(convert_scalar_type_name(t)) + } + metadata::Type::CompositeType(t) => query_engine_metadata::metadata::Type::CompositeType( + query_engine_metadata::metadata::CompositeTypeName(t.0), + ), + metadata::Type::ArrayType(t) => { + query_engine_metadata::metadata::Type::ArrayType(Box::new(convert_type(*t))) + } + } +} + +fn convert_native_query_sql_either( + sql: metadata::NativeQuerySqlEither, +) -> query_engine_metadata::metadata::NativeQuerySqlEither { + match sql { + metadata::NativeQuerySqlEither::NativeQuerySql(internal_sql) => { + query_engine_metadata::metadata::NativeQuerySqlEither::NativeQuerySql( + convert_native_query_sql_internal(internal_sql), + ) + } + metadata::NativeQuerySqlEither::NativeQuerySqlExternal(external_sql) => { + query_engine_metadata::metadata::NativeQuerySqlEither::NativeQuerySqlExternal( + convert_native_query_sql_external(external_sql), + ) + } + } +} + +fn convert_native_query_sql_internal( + internal_sql: metadata::NativeQuerySql, +) -> query_engine_metadata::metadata::NativeQuerySql { + match internal_sql { + metadata::NativeQuerySql::FromFile { file, sql } => { + query_engine_metadata::metadata::NativeQuerySql::FromFile { + file, + sql: convert_native_query_parts(sql), + } + } + metadata::NativeQuerySql::Inline { sql } => { + query_engine_metadata::metadata::NativeQuerySql::Inline { + sql: convert_native_query_parts(sql), + } + } + } +} + +fn convert_native_query_sql_external( + external_sql: metadata::NativeQuerySqlExternal, +) -> query_engine_metadata::metadata::NativeQuerySqlExternal { + match external_sql { + metadata::NativeQuerySqlExternal::File { file } => { + query_engine_metadata::metadata::NativeQuerySqlExternal::File { file } + } + metadata::NativeQuerySqlExternal::Inline { inline } => { + query_engine_metadata::metadata::NativeQuerySqlExternal::Inline { + inline: convert_native_query_parts(inline), + } + } + metadata::NativeQuerySqlExternal::InlineUntagged(parts) => { + query_engine_metadata::metadata::NativeQuerySqlExternal::InlineUntagged( + convert_native_query_parts(parts), + ) + } + } +} + +fn convert_native_query_parts( + inline: metadata::NativeQueryParts, +) -> query_engine_metadata::metadata::NativeQueryParts { + query_engine_metadata::metadata::NativeQueryParts( + inline + .0 + .into_iter() + .map(convert_native_query_part) + .collect(), + ) +} + +fn convert_native_query_part( + native_query_part: metadata::NativeQueryPart, +) -> query_engine_metadata::metadata::NativeQueryPart { + match native_query_part { + metadata::NativeQueryPart::Text(t) => { + query_engine_metadata::metadata::NativeQueryPart::Text(t) + } + metadata::NativeQueryPart::Parameter(p) => { + query_engine_metadata::metadata::NativeQueryPart::Parameter(p) + } + } +} + +fn convert_type_representation( + type_representation: metadata::TypeRepresentation, +) -> query_engine_metadata::metadata::TypeRepresentation { + match type_representation { + metadata::TypeRepresentation::Boolean => { + query_engine_metadata::metadata::TypeRepresentation::Boolean + } + metadata::TypeRepresentation::String => { + query_engine_metadata::metadata::TypeRepresentation::String + } + metadata::TypeRepresentation::Float32 => { + query_engine_metadata::metadata::TypeRepresentation::Float32 + } + metadata::TypeRepresentation::Float64 => { + query_engine_metadata::metadata::TypeRepresentation::Float64 + } + metadata::TypeRepresentation::Int16 => { + query_engine_metadata::metadata::TypeRepresentation::Int16 + } + metadata::TypeRepresentation::Int32 => { + query_engine_metadata::metadata::TypeRepresentation::Int32 + } + metadata::TypeRepresentation::Int64 => { + query_engine_metadata::metadata::TypeRepresentation::Int64 + } + metadata::TypeRepresentation::Int64AsString => { + query_engine_metadata::metadata::TypeRepresentation::Int64AsString + } + metadata::TypeRepresentation::BigDecimal => { + query_engine_metadata::metadata::TypeRepresentation::BigDecimal + } + metadata::TypeRepresentation::BigDecimalAsString => { + query_engine_metadata::metadata::TypeRepresentation::BigDecimalAsString + } + metadata::TypeRepresentation::Timestamp => { + query_engine_metadata::metadata::TypeRepresentation::Timestamp + } + metadata::TypeRepresentation::Timestamptz => { + query_engine_metadata::metadata::TypeRepresentation::Timestamptz + } + metadata::TypeRepresentation::Time => { + query_engine_metadata::metadata::TypeRepresentation::Time + } + metadata::TypeRepresentation::Timetz => { + query_engine_metadata::metadata::TypeRepresentation::Timetz + } + metadata::TypeRepresentation::Date => { + query_engine_metadata::metadata::TypeRepresentation::Date + } + metadata::TypeRepresentation::UUID => { + query_engine_metadata::metadata::TypeRepresentation::UUID + } + metadata::TypeRepresentation::Geography => { + query_engine_metadata::metadata::TypeRepresentation::Geography + } + metadata::TypeRepresentation::Geometry => { + query_engine_metadata::metadata::TypeRepresentation::Geometry + } + // This is deprecated in ndc-spec + metadata::TypeRepresentation::Number + | metadata::TypeRepresentation::Integer + | metadata::TypeRepresentation::Json => { + query_engine_metadata::metadata::TypeRepresentation::Json + } + metadata::TypeRepresentation::Enum(v) => { + query_engine_metadata::metadata::TypeRepresentation::Enum(v) + } + } +} + +fn convert_comparison_operator( + comparison_operator: metadata::ComparisonOperator, +) -> query_engine_metadata::metadata::ComparisonOperator { + query_engine_metadata::metadata::ComparisonOperator { + operator_name: comparison_operator.operator_name, + operator_kind: convert_operator_kind(&comparison_operator.operator_kind), + argument_type: convert_scalar_type_name(comparison_operator.argument_type), + is_infix: comparison_operator.is_infix, + } +} + +fn convert_operator_kind( + operator_kind: &metadata::OperatorKind, +) -> query_engine_metadata::metadata::OperatorKind { + match operator_kind { + metadata::OperatorKind::Equal => query_engine_metadata::metadata::OperatorKind::Equal, + metadata::OperatorKind::In => query_engine_metadata::metadata::OperatorKind::In, + metadata::OperatorKind::Custom => query_engine_metadata::metadata::OperatorKind::Custom, + } +} + +fn convert_composite_types( + composite_types: metadata::CompositeTypes, +) -> query_engine_metadata::metadata::CompositeTypes { + query_engine_metadata::metadata::CompositeTypes( + composite_types + .0 + .into_iter() + .map(|(k, composite_type)| { + ( + query_engine_metadata::metadata::CompositeTypeName(k), + convert_composite_type(composite_type), + ) + }) + .collect(), + ) +} + +fn convert_composite_type( + composite_type: metadata::CompositeType, +) -> query_engine_metadata::metadata::CompositeType { + query_engine_metadata::metadata::CompositeType { + type_name: composite_type.type_name, + schema_name: Some(composite_type.schema_name), + fields: composite_type + .fields + .into_iter() + .map(|(k, field)| (k, convert_composite_type_field_info(field))) + .collect(), + description: composite_type.description, + } +} + +fn convert_composite_type_field_info( + field: metadata::FieldInfo, +) -> query_engine_metadata::metadata::FieldInfo { + query_engine_metadata::metadata::FieldInfo { + field_name: field.field_name, + r#type: convert_type(field.r#type), + description: field.description, + } +} + +pub fn convert_tables(tables: metadata::TablesInfo) -> query_engine_metadata::metadata::TablesInfo { + query_engine_metadata::metadata::TablesInfo( + tables + .0 + .into_iter() + .map(|(k, table_info)| (k, convert_table_info(table_info))) + .collect(), + ) +} + +fn convert_table_info( + table_info: metadata::TableInfo, +) -> query_engine_metadata::metadata::TableInfo { + query_engine_metadata::metadata::TableInfo { + schema_name: table_info.schema_name, + table_name: table_info.table_name, + columns: table_info + .columns + .into_iter() + .map(|(k, column_info)| (k, convert_column_info(column_info))) + .collect(), + uniqueness_constraints: convert_uniqueness_constraints(table_info.uniqueness_constraints), + foreign_relations: convert_foreign_relations(table_info.foreign_relations), + description: table_info.description, + } +} + +fn convert_foreign_relations( + foreign_relations: metadata::ForeignRelations, +) -> query_engine_metadata::metadata::ForeignRelations { + query_engine_metadata::metadata::ForeignRelations( + foreign_relations + .0 + .into_iter() + .map(|(k, foreign_relation)| (k, convert_foreign_relation(foreign_relation))) + .collect(), + ) +} + +fn convert_foreign_relation( + foreign_relation: metadata::ForeignRelation, +) -> query_engine_metadata::metadata::ForeignRelation { + query_engine_metadata::metadata::ForeignRelation { + foreign_schema: foreign_relation.foreign_schema, + foreign_table: foreign_relation.foreign_table, + column_mapping: foreign_relation.column_mapping, + } +} + +fn convert_uniqueness_constraints( + uniqueness_constraints: metadata::UniquenessConstraints, +) -> query_engine_metadata::metadata::UniquenessConstraints { + query_engine_metadata::metadata::UniquenessConstraints( + uniqueness_constraints + .0 + .into_iter() + .map(|(k, uniqueness_constraint)| { + (k, convert_uniqueness_constraint(uniqueness_constraint)) + }) + .collect(), + ) +} + +fn convert_uniqueness_constraint( + uniqueness_constraint: metadata::UniquenessConstraint, +) -> query_engine_metadata::metadata::UniquenessConstraint { + query_engine_metadata::metadata::UniquenessConstraint(uniqueness_constraint.0) +} + +fn convert_column_info( + column_info: metadata::ColumnInfo, +) -> query_engine_metadata::metadata::ColumnInfo { + query_engine_metadata::metadata::ColumnInfo { + name: column_info.name, + r#type: convert_type(column_info.r#type), + nullable: convert_nullable(&column_info.nullable), + has_default: convert_has_default(&column_info.has_default), + is_identity: convert_is_identity(&column_info.is_identity), + is_generated: convert_is_generated(&column_info.is_generated), + description: column_info.description, + } +} + +fn convert_is_generated( + is_generated: &metadata::IsGenerated, +) -> query_engine_metadata::metadata::IsGenerated { + match is_generated { + metadata::IsGenerated::NotGenerated => { + query_engine_metadata::metadata::IsGenerated::NotGenerated + } + metadata::IsGenerated::Stored => query_engine_metadata::metadata::IsGenerated::Stored, + } +} + +fn convert_is_identity( + is_identity: &metadata::IsIdentity, +) -> query_engine_metadata::metadata::IsIdentity { + match is_identity { + metadata::IsIdentity::NotIdentity => { + query_engine_metadata::metadata::IsIdentity::NotIdentity + } + metadata::IsIdentity::IdentityByDefault => { + query_engine_metadata::metadata::IsIdentity::IdentityByDefault + } + metadata::IsIdentity::IdentityAlways => { + query_engine_metadata::metadata::IsIdentity::IdentityAlways + } + } +} + +fn convert_has_default( + has_default: &metadata::HasDefault, +) -> query_engine_metadata::metadata::HasDefault { + match has_default { + metadata::HasDefault::NoDefault => query_engine_metadata::metadata::HasDefault::NoDefault, + metadata::HasDefault::HasDefault => query_engine_metadata::metadata::HasDefault::HasDefault, + } +} + +fn convert_mutations_version( + mutations_version_opt: Option, +) -> Option { + mutations_version_opt.map(|mutations_version| match mutations_version { + metadata::mutations::MutationsVersion::V1 => { + query_engine_metadata::metadata::mutations::MutationsVersion::V1 + } + metadata::mutations::MutationsVersion::VeryExperimentalWip => { + query_engine_metadata::metadata::mutations::MutationsVersion::VeryExperimentalWip + } + }) +} From bc806909c2a27f32eb32e32ee729161a6b11558b Mon Sep 17 00:00:00 2001 From: Philip Lykke Carlsen Date: Thu, 2 May 2024 15:40:12 +0200 Subject: [PATCH 05/18] Upgrade v3 -> v4 Wow that was tedious --- crates/cli/src/lib.rs | 3 +- crates/configuration/src/configuration.rs | 10 +- crates/configuration/src/version3/mod.rs | 6 +- crates/configuration/src/version4/mod.rs | 10 +- .../src/version4/upgrade_from_v3.rs | 591 ++++++++++++++++++ 5 files changed, 603 insertions(+), 17 deletions(-) create mode 100644 crates/configuration/src/version4/upgrade_from_v3.rs diff --git a/crates/cli/src/lib.rs b/crates/cli/src/lib.rs index e480f007d..72934c87a 100644 --- a/crates/cli/src/lib.rs +++ b/crates/cli/src/lib.rs @@ -157,8 +157,7 @@ async fn update(context: Context) -> anyhow::Result<()> { /// async fn upgrade(dir_from: PathBuf, dir_to: PathBuf) -> anyhow::Result<()> { let old_configuration = configuration::parse_configuration(dir_from).await?; - let upgraded_configuration = configuration::upgrade_to_latest_version(old_configuration) - .map_err(|e| anyhow::anyhow!("{e:?}"))?; + let upgraded_configuration = configuration::upgrade_to_latest_version(old_configuration); configuration::write_parsed_configuration(upgraded_configuration, dir_to).await?; Ok(()) } diff --git a/crates/configuration/src/configuration.rs b/crates/configuration/src/configuration.rs index 137f1d3d9..76a00b67d 100644 --- a/crates/configuration/src/configuration.rs +++ b/crates/configuration/src/configuration.rs @@ -101,11 +101,11 @@ pub async fn write_parsed_configuration( } } -pub fn upgrade_to_latest_version( - parsed_config: ParsedConfiguration, -) -> Result { +pub fn upgrade_to_latest_version(parsed_config: ParsedConfiguration) -> ParsedConfiguration { match parsed_config { - ParsedConfiguration::Version3(v) => version4::upgrade_from_v3(v), - ParsedConfiguration::Version4(_) => Ok(parsed_config), + ParsedConfiguration::Version3(v) => { + ParsedConfiguration::Version4(version4::upgrade_from_v3(v)) + } + ParsedConfiguration::Version4(_) => parsed_config, } } diff --git a/crates/configuration/src/version3/mod.rs b/crates/configuration/src/version3/mod.rs index 6a444d451..4772964df 100644 --- a/crates/configuration/src/version3/mod.rs +++ b/crates/configuration/src/version3/mod.rs @@ -1,9 +1,9 @@ //! Internal Configuration and state for our connector. -mod comparison; +pub(crate) mod comparison; pub mod connection_settings; -mod metadata; -mod options; +pub(crate) mod metadata; +pub(crate) mod options; use std::borrow::Cow; use std::collections::{BTreeMap, BTreeSet}; diff --git a/crates/configuration/src/version4/mod.rs b/crates/configuration/src/version4/mod.rs index 60bed2e2c..ba87c4488 100644 --- a/crates/configuration/src/version4/mod.rs +++ b/crates/configuration/src/version4/mod.rs @@ -1,15 +1,17 @@ //! Internal Configuration and state for our connector. mod comparison; -pub mod connection_settings; +mod connection_settings; mod metadata; mod options; mod to_runtime_configuration; +mod upgrade_from_v3; use std::borrow::Cow; use std::collections::BTreeMap; use std::path::{Path, PathBuf}; pub use to_runtime_configuration::make_runtime_configuration; +pub use upgrade_from_v3::upgrade_from_v3; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -503,9 +505,3 @@ pub async fn write_parsed_configuration( Ok(()) } - -pub(crate) fn upgrade_from_v3( - v: crate::version3::RawConfiguration, -) -> Result { - todo!() -} diff --git a/crates/configuration/src/version4/upgrade_from_v3.rs b/crates/configuration/src/version4/upgrade_from_v3.rs new file mode 100644 index 000000000..325890fe7 --- /dev/null +++ b/crates/configuration/src/version4/upgrade_from_v3.rs @@ -0,0 +1,591 @@ +#![allow(clippy::needless_pass_by_value)] + +use std::collections::BTreeMap; +use std::collections::BTreeSet; + +use crate::version3; +use crate::version4::comparison; +use crate::version4::connection_settings; +use crate::version4::metadata; +use crate::version4::options; +use crate::version4::ParsedConfiguration; + +pub fn upgrade_from_v3(v: version3::RawConfiguration) -> crate::version4::ParsedConfiguration { + let version3::RawConfiguration { + schema, + connection_settings, + metadata, + introspection_options, + mutations_version, + } = v; + + ParsedConfiguration { + schema, + connection_settings: upgrade_connection_settings(connection_settings), + metadata: upgrade_metadata(metadata), + introspection_options: ugrade_introspection_options(introspection_options), + mutations_version: mutations_version.map(upgrade_mutations_version), + } +} + +fn ugrade_introspection_options( + introspection_options: version3::options::IntrospectionOptions, +) -> options::IntrospectionOptions { + let version3::options::IntrospectionOptions { + excluded_schemas, + unqualified_schemas_for_tables, + unqualified_schemas_for_types_and_procedures, + comparison_operator_mapping, + introspect_prefix_function_comparison_operators, + } = introspection_options; + + options::IntrospectionOptions { + excluded_schemas, + unqualified_schemas_for_tables, + unqualified_schemas_for_types_and_procedures, + comparison_operator_mapping: comparison_operator_mapping + .into_iter() + .map(upgrade_comparison_operator_mapping) + .collect(), + introspect_prefix_function_comparison_operators, + } +} + +fn upgrade_comparison_operator_mapping( + comparison_operator_mapping: version3::comparison::ComparisonOperatorMapping, +) -> comparison::ComparisonOperatorMapping { + let version3::comparison::ComparisonOperatorMapping { + operator_name, + exposed_name, + operator_kind, + } = comparison_operator_mapping; + + comparison::ComparisonOperatorMapping { + operator_name, + exposed_name, + operator_kind: upgrade_operator_kind(operator_kind), + } +} + +fn upgrade_operator_kind( + operator_kind: version3::metadata::OperatorKind, +) -> metadata::OperatorKind { + match operator_kind { + version3::metadata::OperatorKind::Equal => metadata::OperatorKind::Equal, + version3::metadata::OperatorKind::In => metadata::OperatorKind::In, + version3::metadata::OperatorKind::Custom => metadata::OperatorKind::Custom, + } +} + +fn upgrade_mutations_version( + mutations_version: version3::metadata::mutations::MutationsVersion, +) -> metadata::mutations::MutationsVersion { + match mutations_version { + version3::metadata::mutations::MutationsVersion::V1 => { + metadata::mutations::MutationsVersion::V1 + } + version3::metadata::mutations::MutationsVersion::VeryExperimentalWip => { + metadata::mutations::MutationsVersion::VeryExperimentalWip + } + } +} + +fn upgrade_connection_settings( + connection_settings: version3::connection_settings::DatabaseConnectionSettings, +) -> connection_settings::DatabaseConnectionSettings { + let version3::connection_settings::DatabaseConnectionSettings { + connection_uri, + pool_settings, + isolation_level, + } = connection_settings; + + connection_settings::DatabaseConnectionSettings { + connection_uri, + pool_settings, + isolation_level, + } +} + +fn upgrade_metadata(metadata: version3::metadata::Metadata) -> metadata::Metadata { + let version3::metadata::Metadata { + tables, + composite_types, + native_queries, + aggregate_functions, + comparison_operators, + type_representations, + } = metadata; + + metadata::Metadata { + tables: upgrade_tables(tables), + scalar_types: upgrade_scalar_types( + aggregate_functions, + comparison_operators, + type_representations, + ), + composite_types: upgrade_composite_types(composite_types), + native_queries: upgrade_native_queries(native_queries), + } +} + +fn upgrade_native_queries( + native_queries: version3::metadata::NativeQueries, +) -> metadata::NativeQueries { + let version3::metadata::NativeQueries(native_queries_map) = native_queries; + + metadata::NativeQueries( + native_queries_map + .into_iter() + .map(|(name, native_query_info)| (name, upgrade_native_query_info(native_query_info))) + .collect(), + ) +} + +fn upgrade_native_query_info( + native_query_info: version3::metadata::NativeQueryInfo, +) -> metadata::NativeQueryInfo { + let version3::metadata::NativeQueryInfo { + sql, + columns, + arguments, + description, + is_procedure, + } = native_query_info; + + metadata::NativeQueryInfo { + sql: upgrade_native_query_sql_either(sql), + columns: columns + .into_iter() + .map(|(name, read_only_column_info)| { + (name, upgrade_read_only_column_info(read_only_column_info)) + }) + .collect(), + arguments: arguments + .into_iter() + .map(|(name, read_only_column_info)| { + (name, upgrade_read_only_column_info(read_only_column_info)) + }) + .collect(), + description, + is_procedure, + } +} + +fn upgrade_read_only_column_info( + read_only_column_info: version3::metadata::ReadOnlyColumnInfo, +) -> metadata::ReadOnlyColumnInfo { + let version3::metadata::ReadOnlyColumnInfo { + name, + r#type, + nullable, + description, + } = read_only_column_info; + + metadata::ReadOnlyColumnInfo { + name, + r#type: upgrade_type(r#type), + nullable: upgrade_nullable(nullable), + description, + } +} + +fn upgrade_nullable(nullable: version3::metadata::Nullable) -> metadata::Nullable { + match nullable { + version3::metadata::Nullable::Nullable => metadata::Nullable::Nullable, + version3::metadata::Nullable::NonNullable => metadata::Nullable::NonNullable, + } +} + +fn upgrade_type(r#type: version3::metadata::Type) -> metadata::Type { + match r#type { + version3::metadata::Type::ScalarType(scalar_type) => { + metadata::Type::ScalarType(upgrade_scalar_type(scalar_type)) + } + version3::metadata::Type::CompositeType(composite_type) => { + metadata::Type::CompositeType(upgrade_composite_type_name(composite_type)) + } + version3::metadata::Type::ArrayType(array_type) => { + metadata::Type::ArrayType(Box::new(upgrade_type(*array_type))) + } + } +} + +fn upgrade_composite_type_name(composite_type: String) -> metadata::CompositeTypeName { + metadata::CompositeTypeName(composite_type) +} + +fn upgrade_scalar_type(scalar_type: version3::metadata::ScalarType) -> metadata::ScalarTypeName { + let version3::metadata::ScalarType(name) = scalar_type; + metadata::ScalarTypeName(name) +} + +fn upgrade_native_query_sql_either( + sql: version3::metadata::NativeQuerySqlEither, +) -> metadata::NativeQuerySqlEither { + match sql { + version3::metadata::NativeQuerySqlEither::NativeQuerySql(native_query_sql) => { + metadata::NativeQuerySqlEither::NativeQuerySql(upgrade_native_query_sql( + native_query_sql, + )) + } + version3::metadata::NativeQuerySqlEither::NativeQuerySqlExternal( + native_query_sql_external, + ) => metadata::NativeQuerySqlEither::NativeQuerySqlExternal( + upgrade_native_query_sql_external(native_query_sql_external), + ), + } +} + +fn upgrade_native_query_sql_external( + native_query_sql_external: version3::metadata::NativeQuerySqlExternal, +) -> metadata::NativeQuerySqlExternal { + match native_query_sql_external { + version3::metadata::NativeQuerySqlExternal::File { file } => { + metadata::NativeQuerySqlExternal::File { file } + } + version3::metadata::NativeQuerySqlExternal::Inline { inline } => { + metadata::NativeQuerySqlExternal::Inline { + inline: upgrade_native_query_parts(inline), + } + } + version3::metadata::NativeQuerySqlExternal::InlineUntagged(native_query_parts) => { + metadata::NativeQuerySqlExternal::InlineUntagged(upgrade_native_query_parts( + native_query_parts, + )) + } + } +} + +fn upgrade_native_query_parts( + native_query_parts: version3::metadata::NativeQueryParts, +) -> metadata::NativeQueryParts { + metadata::NativeQueryParts( + native_query_parts + .0 + .into_iter() + .map(upgrade_native_query_part) + .collect(), + ) +} + +fn upgrade_native_query_part( + native_query_part: version3::metadata::NativeQueryPart, +) -> metadata::NativeQueryPart { + match native_query_part { + version3::metadata::NativeQueryPart::Text(text) => metadata::NativeQueryPart::Text(text), + version3::metadata::NativeQueryPart::Parameter(parameter) => { + metadata::NativeQueryPart::Parameter(parameter) + } + } +} + +fn upgrade_native_query_sql( + native_query_sql: version3::metadata::NativeQuerySql, +) -> metadata::NativeQuerySql { + match native_query_sql { + version3::metadata::NativeQuerySql::FromFile { file, sql } => { + metadata::NativeQuerySql::FromFile { + file, + sql: upgrade_native_query_parts(sql), + } + } + version3::metadata::NativeQuerySql::Inline { sql } => metadata::NativeQuerySql::Inline { + sql: upgrade_native_query_parts(sql), + }, + } +} + +fn upgrade_composite_types( + composite_types: version3::metadata::CompositeTypes, +) -> metadata::CompositeTypes { + metadata::CompositeTypes( + composite_types + .0 + .into_iter() + .map(|(name, composite_type)| (name, upgrade_composite_type(composite_type))) + .collect(), + ) +} + +fn upgrade_composite_type( + composite_type: version3::metadata::CompositeType, +) -> metadata::CompositeType { + let version3::metadata::CompositeType { + name, + fields, + description, + } = composite_type; + + metadata::CompositeType { + type_name: name, + schema_name: "public".to_string(), // TODO!! Check this? + fields: fields + .into_iter() + .map(|(name, field_info)| (name, upgrade_field_info(field_info))) + .collect(), + description, + } +} + +fn upgrade_field_info(field_info: version3::metadata::FieldInfo) -> metadata::FieldInfo { + let version3::metadata::FieldInfo { + name, + r#type, + description, + } = field_info; + + metadata::FieldInfo { + field_name: name, + r#type: upgrade_type(r#type), + description, + } +} + +fn upgrade_scalar_types( + aggregate_functions: version3::metadata::AggregateFunctions, + comparison_operators: version3::metadata::ComparisonOperators, + type_representations: version3::metadata::TypeRepresentations, +) -> metadata::ScalarTypes { + let scalar_type_names: BTreeSet<&version3::metadata::ScalarType> = aggregate_functions + .0 + .keys() + .chain(comparison_operators.0.keys()) + .chain(type_representations.0.keys()) + .collect(); + + metadata::ScalarTypes( + scalar_type_names + .into_iter() + .map(|s @ version3::metadata::ScalarType(scalar_type_name)| { + ( + metadata::ScalarTypeName(scalar_type_name.clone()), + metadata::ScalarType { + type_name: scalar_type_name.to_string(), + schema_name: "public".to_string(), // TODO! check this? + description: None, + aggregate_functions: aggregate_functions + .0 + .get(s) + .cloned() + .unwrap_or(BTreeMap::new()) + .into_iter() + .map(|(name, aggregate_function)| { + (name, upgrade_aggregate_function(aggregate_function)) + }) + .collect(), + comparison_operators: comparison_operators + .0 + .get(s) + .cloned() + .unwrap_or(BTreeMap::new()) + .into_iter() + .map(|(name, comparison_operator)| { + (name, upgrade_comparison_operator(comparison_operator)) + }) + .collect(), + type_representation: type_representations + .0 + .get(s) + .cloned() + .map(upgrade_type_representation), + }, + ) + }) + .collect(), + ) +} + +fn upgrade_type_representation( + type_representation: version3::metadata::TypeRepresentation, +) -> metadata::TypeRepresentation { + match type_representation { + version3::metadata::TypeRepresentation::Boolean => metadata::TypeRepresentation::Boolean, + version3::metadata::TypeRepresentation::String => metadata::TypeRepresentation::String, + version3::metadata::TypeRepresentation::Float32 => metadata::TypeRepresentation::Float32, + version3::metadata::TypeRepresentation::Float64 => metadata::TypeRepresentation::Float64, + version3::metadata::TypeRepresentation::Int16 => metadata::TypeRepresentation::Int16, + version3::metadata::TypeRepresentation::Int32 => metadata::TypeRepresentation::Int32, + version3::metadata::TypeRepresentation::Int64 => metadata::TypeRepresentation::Int64, + version3::metadata::TypeRepresentation::Int64AsString => { + metadata::TypeRepresentation::Int64AsString + } + version3::metadata::TypeRepresentation::BigDecimal => { + metadata::TypeRepresentation::BigDecimal + } + version3::metadata::TypeRepresentation::BigDecimalAsString => { + metadata::TypeRepresentation::BigDecimalAsString + } + version3::metadata::TypeRepresentation::Timestamp => { + metadata::TypeRepresentation::Timestamp + } + version3::metadata::TypeRepresentation::Timestamptz => { + metadata::TypeRepresentation::Timestamptz + } + version3::metadata::TypeRepresentation::Time => metadata::TypeRepresentation::Time, + version3::metadata::TypeRepresentation::Timetz => metadata::TypeRepresentation::Timetz, + version3::metadata::TypeRepresentation::Date => metadata::TypeRepresentation::Date, + version3::metadata::TypeRepresentation::UUID => metadata::TypeRepresentation::UUID, + version3::metadata::TypeRepresentation::Geography => { + metadata::TypeRepresentation::Geography + } + version3::metadata::TypeRepresentation::Geometry => metadata::TypeRepresentation::Geometry, + version3::metadata::TypeRepresentation::Number => metadata::TypeRepresentation::Number, + version3::metadata::TypeRepresentation::Integer => metadata::TypeRepresentation::Integer, + version3::metadata::TypeRepresentation::Json => metadata::TypeRepresentation::Json, + version3::metadata::TypeRepresentation::Enum(enum_alternatives) => { + metadata::TypeRepresentation::Enum(enum_alternatives) + } + } +} + +fn upgrade_comparison_operator( + comparison_operator: version3::metadata::ComparisonOperator, +) -> metadata::ComparisonOperator { + let version3::metadata::ComparisonOperator { + operator_name, + operator_kind, + argument_type, + is_infix, + } = comparison_operator; + metadata::ComparisonOperator { + operator_name, + operator_kind: upgrade_operator_kind(operator_kind), + argument_type: upgrade_scalar_type(argument_type), + is_infix, + } +} + +fn upgrade_aggregate_function( + aggregate_function: version3::metadata::AggregateFunction, +) -> metadata::AggregateFunction { + let version3::metadata::AggregateFunction { return_type } = aggregate_function; + + metadata::AggregateFunction { + return_type: upgrade_scalar_type(return_type), + } +} + +fn upgrade_tables(tables: version3::metadata::TablesInfo) -> metadata::TablesInfo { + metadata::TablesInfo( + tables + .0 + .into_iter() + .map(|(name, table_info)| (name, upgrade_table_info(table_info))) + .collect(), + ) +} + +fn upgrade_table_info(table_info: version3::metadata::TableInfo) -> metadata::TableInfo { + let version3::metadata::TableInfo { + schema_name, + table_name, + columns, + uniqueness_constraints, + foreign_relations, + description, + } = table_info; + metadata::TableInfo { + schema_name, + table_name, + columns: columns + .into_iter() + .map(|(name, column_info)| (name, upgrade_column_info(column_info))) + .collect(), + uniqueness_constraints: upgrade_uniqueness_constraints(uniqueness_constraints), + foreign_relations: upgrade_foreign_relations(foreign_relations), + description, + } +} + +fn upgrade_foreign_relations( + foreign_relations: version3::metadata::ForeignRelations, +) -> metadata::ForeignRelations { + metadata::ForeignRelations( + foreign_relations + .0 + .into_iter() + .map(|(name, foreign_relation)| (name, upgrade_foreign_relation(foreign_relation))) + .collect(), + ) +} + +fn upgrade_foreign_relation( + foreign_relation: version3::metadata::ForeignRelation, +) -> metadata::ForeignRelation { + let version3::metadata::ForeignRelation { + foreign_schema, + foreign_table, + column_mapping, + } = foreign_relation; + metadata::ForeignRelation { + foreign_schema, + foreign_table, + column_mapping, + } +} + +fn upgrade_uniqueness_constraints( + uniqueness_constraints: version3::metadata::UniquenessConstraints, +) -> metadata::UniquenessConstraints { + metadata::UniquenessConstraints( + uniqueness_constraints + .0 + .into_iter() + .map(|(name, uniqueness_constraint)| { + (name, upgrade_uniqueness_constraint(uniqueness_constraint)) + }) + .collect(), + ) +} + +fn upgrade_uniqueness_constraint( + uniqueness_constraint: version3::metadata::UniquenessConstraint, +) -> metadata::UniquenessConstraint { + metadata::UniquenessConstraint(uniqueness_constraint.0) +} + +fn upgrade_column_info(column_info: version3::metadata::ColumnInfo) -> metadata::ColumnInfo { + let version3::metadata::ColumnInfo { + name, + r#type, + nullable, + has_default, + is_identity, + is_generated, + description, + } = column_info; + + metadata::ColumnInfo { + name, + r#type: upgrade_type(r#type), + nullable: upgrade_nullable(nullable), + has_default: upgrade_has_default(has_default), + is_identity: upgrade_is_identity(is_identity), + is_generated: upgrade_is_generated(is_generated), + description, + } +} + +fn upgrade_is_generated(is_generated: version3::metadata::IsGenerated) -> metadata::IsGenerated { + match is_generated { + version3::metadata::IsGenerated::NotGenerated => metadata::IsGenerated::NotGenerated, + version3::metadata::IsGenerated::Stored => metadata::IsGenerated::Stored, + } +} + +fn upgrade_is_identity(is_identity: version3::metadata::IsIdentity) -> metadata::IsIdentity { + match is_identity { + version3::metadata::IsIdentity::NotIdentity => metadata::IsIdentity::NotIdentity, + version3::metadata::IsIdentity::IdentityByDefault => { + metadata::IsIdentity::IdentityByDefault + } + version3::metadata::IsIdentity::IdentityAlways => metadata::IsIdentity::IdentityAlways, + } +} + +fn upgrade_has_default(has_default: version3::metadata::HasDefault) -> metadata::HasDefault { + match has_default { + version3::metadata::HasDefault::NoDefault => metadata::HasDefault::NoDefault, + version3::metadata::HasDefault::HasDefault => metadata::HasDefault::HasDefault, + } +} From 47c0d8733cfa02fa83de37ef5ab45897de85b09e Mon Sep 17 00:00:00 2001 From: Philip Lykke Carlsen Date: Thu, 2 May 2024 16:45:40 +0200 Subject: [PATCH 06/18] fixups --- crates/cli/src/lib.rs | 6 ++++ crates/configuration/src/configuration.rs | 7 ++--- crates/configuration/src/error.rs | 2 -- crates/configuration/src/version3/mod.rs | 38 ++++++++++++++++++++++- crates/configuration/src/version4/mod.rs | 6 ---- 5 files changed, 45 insertions(+), 14 deletions(-) diff --git a/crates/cli/src/lib.rs b/crates/cli/src/lib.rs index 72934c87a..11b978bd6 100644 --- a/crates/cli/src/lib.rs +++ b/crates/cli/src/lib.rs @@ -67,6 +67,12 @@ pub async fn run(command: Command, context: Context) -> anyhow /// Optionally, this can also create the connector metadata, which is used by the Hasura CLI to /// automatically work with this CLI as a plugin. async fn initialize(with_metadata: bool, context: Context) -> anyhow::Result<()> { + // refuse to initialize the directory unless it is empty + let mut items_in_dir = fs::read_dir(&context.context_path).await?; + if items_in_dir.next_entry().await?.is_some() { + Err(Error::DirectoryIsNotEmpty)?; + } + configuration::write_parsed_configuration( configuration::ParsedConfiguration::initial(), &context.context_path, diff --git a/crates/configuration/src/configuration.rs b/crates/configuration/src/configuration.rs index 76a00b67d..1d8696089 100644 --- a/crates/configuration/src/configuration.rs +++ b/crates/configuration/src/configuration.rs @@ -87,16 +87,13 @@ pub fn make_runtime_configuration( } } -/// Write out a runtime configuration to a directory. We would mostly only expect this function to -/// support the latest version. +/// Write out a parsed configuration to a directory. pub async fn write_parsed_configuration( parsed_config: ParsedConfiguration, out_dir: impl AsRef, ) -> Result<(), WriteParsedConfigurationError> { match parsed_config { - ParsedConfiguration::Version3(_) => Err( - WriteParsedConfigurationError::VersionNotSupported("3".to_string()), - ), + ParsedConfiguration::Version3(c) => version3::write_parsed_configuration(c, out_dir).await, ParsedConfiguration::Version4(c) => version4::write_parsed_configuration(c, out_dir).await, } } diff --git a/crates/configuration/src/error.rs b/crates/configuration/src/error.rs index cfa695f78..d2227495f 100644 --- a/crates/configuration/src/error.rs +++ b/crates/configuration/src/error.rs @@ -32,8 +32,6 @@ pub enum ParseConfigurationError { #[derive(Debug, thiserror::Error)] pub enum WriteParsedConfigurationError { - #[error("directory is not empty")] - DirectoryIsNotEmpty, #[error("Version not supported: {0}")] VersionNotSupported(String), diff --git a/crates/configuration/src/version3/mod.rs b/crates/configuration/src/version3/mod.rs index 4772964df..6f00efdd7 100644 --- a/crates/configuration/src/version3/mod.rs +++ b/crates/configuration/src/version3/mod.rs @@ -19,7 +19,9 @@ use tracing::{info_span, Instrument}; use metadata::database; use crate::environment::Environment; -use crate::error::{MakeRuntimeConfigurationError, ParseConfigurationError}; +use crate::error::{ + MakeRuntimeConfigurationError, ParseConfigurationError, WriteParsedConfigurationError, +}; use crate::values::{ConnectionUri, Secret}; const CONFIGURATION_FILENAME: &str = "configuration.json"; @@ -554,6 +556,40 @@ pub fn make_runtime_configuration( }) } +pub async fn write_parsed_configuration( + parsed_config: RawConfiguration, + out_dir: impl AsRef, +) -> Result<(), WriteParsedConfigurationError> { + let configuration_file = out_dir.as_ref().to_owned().join(CONFIGURATION_FILENAME); + fs::create_dir_all(out_dir.as_ref()).await?; + + // create the configuration file + fs::write( + configuration_file, + serde_json::to_string_pretty(&parsed_config) + .map_err(|e| WriteParsedConfigurationError::IoError(e.into()))? + + "\n", + ) + .await?; + + // create the jsonschema file + let configuration_jsonschema_file_path = out_dir + .as_ref() + .to_owned() + .join(CONFIGURATION_JSONSCHEMA_FILENAME); + + let output = schemars::schema_for!(RawConfiguration); + fs::write( + &configuration_jsonschema_file_path, + serde_json::to_string_pretty(&output) + .map_err(|e| WriteParsedConfigurationError::IoError(e.into()))? + + "\n", + ) + .await?; + + Ok(()) +} + // This function is used by tests as well pub fn convert_metadata(metadata: metadata::Metadata) -> query_engine_metadata::metadata::Metadata { let (scalar_types, composite_types) = transitively_occurring_types( diff --git a/crates/configuration/src/version4/mod.rs b/crates/configuration/src/version4/mod.rs index ba87c4488..7796d3826 100644 --- a/crates/configuration/src/version4/mod.rs +++ b/crates/configuration/src/version4/mod.rs @@ -473,12 +473,6 @@ pub async fn write_parsed_configuration( let configuration_file = out_dir.as_ref().to_owned().join(CONFIGURATION_FILENAME); fs::create_dir_all(out_dir.as_ref()).await?; - // refuse to initialize the directory unless it is empty - let mut items_in_dir = fs::read_dir(out_dir.as_ref()).await?; - if items_in_dir.next_entry().await?.is_some() { - Err(WriteParsedConfigurationError::DirectoryIsNotEmpty)?; - } - // create the configuration file fs::write( configuration_file, From 15a86d9328e813682af74c40ee4028a07ddecc62 Mon Sep 17 00:00:00 2001 From: Philip Lykke Carlsen Date: Thu, 2 May 2024 16:45:54 +0200 Subject: [PATCH 07/18] Test expectations --- ...ation_tests__get_configuration_schema.snap | 1979 +++----------- ..._openapi__up_to_date_generated_schema.snap | 2311 ++++------------- 2 files changed, 795 insertions(+), 3495 deletions(-) diff --git a/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__configuration_tests__get_configuration_schema.snap b/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__configuration_tests__get_configuration_schema.snap index 32a82400f..293bdf7e9 100644 --- a/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__configuration_tests__get_configuration_schema.snap +++ b/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__configuration_tests__get_configuration_schema.snap @@ -5,651 +5,320 @@ expression: schema { "$schema": "http://json-schema.org/draft-07/schema#", "title": "RawConfiguration", - "description": "The parsed connector configuration.", - "oneOf": [ - { - "description": "Initial configuration, just enough to connect to a database and elaborate a full 'Configuration'.", - "type": "object", - "required": [ - "connectionSettings", - "version" - ], - "properties": { - "version": { - "type": "string", - "enum": [ - "3" - ] - }, - "$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" - } - ] + "description": "Initial configuration, just enough to connect to a database and elaborate a full 'Configuration'.", + "type": "object", + "required": [ + "connectionSettings" + ], + "properties": { + "$schema": { + "description": "Jsonschema of the configuration format.", + "default": null, + "type": [ + "string", + "null" + ] + }, + "connectionSettings": { + "description": "Database connection settings.", + "allOf": [ + { + "$ref": "#/definitions/DatabaseConnectionSettings" } - } + ] }, - { - "description": "Initial configuration, just enough to connect to a database and elaborate a full 'Configuration'.", - "type": "object", - "required": [ - "connectionSettings", - "version" - ], - "properties": { - "version": { - "type": "string", - "enum": [ - "4" - ] - }, - "$schema": { - "description": "Jsonschema of the configuration format.", - "default": null, - "type": [ - "string", - "null" - ] - }, - "connectionSettings": { - "description": "Database connection settings.", - "allOf": [ - { - "$ref": "#/definitions/DatabaseConnectionSettings2" - } - ] - }, - "metadata": { - "description": "Connector metadata.", - "default": { - "tables": {}, - "scalarTypes": {}, - "compositeTypes": {}, - "nativeQueries": {} + "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" }, - "allOf": [ - { - "$ref": "#/definitions/Metadata2" - } - ] - }, - "introspectionOptions": { - "description": "Database introspection options.", - "default": { - "excludedSchemas": [ - "information_schema", - "pg_catalog", - "tiger", - "crdb_internal", - "columnar", - "columnar_internal" - ], - "unqualifiedSchemasForTables": [ - "public" - ], - "unqualifiedSchemasForTypesAndProcedures": [ - "public", - "pg_catalog", - "tiger" - ], - "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" - ] + { + "operatorName": "<=", + "exposedName": "_lte", + "operatorKind": "custom" }, - "allOf": [ - { - "$ref": "#/definitions/IntrospectionOptions2" - } - ] + { + "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" }, - "mutationsVersion": { - "description": "Which version of the generated mutation procedures to include in the schema response", - "default": null, - "anyOf": [ - { - "$ref": "#/definitions/MutationsVersion2" - }, - { - "type": "null" - } - ] + { + "type": "null" } - } + ] } - ], + }, "definitions": { "DatabaseConnectionSettings": { "description": "Database connection settings.", @@ -1800,1040 +1469,6 @@ expression: schema "v1", "veryExperimentalWip" ] - }, - "DatabaseConnectionSettings2": { - "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, - "connectionLifetime": 600 - }, - "allOf": [ - { - "$ref": "#/definitions/PoolSettings" - } - ] - }, - "isolationLevel": { - "description": "Query isolation level.", - "default": "ReadCommitted", - "allOf": [ - { - "$ref": "#/definitions/IsolationLevel" - } - ] - } - } - }, - "Metadata2": { - "description": "Metadata information.", - "type": "object", - "properties": { - "tables": { - "default": {}, - "allOf": [ - { - "$ref": "#/definitions/TablesInfo2" - } - ] - }, - "scalarTypes": { - "default": {}, - "allOf": [ - { - "$ref": "#/definitions/ScalarTypes" - } - ] - }, - "compositeTypes": { - "default": {}, - "allOf": [ - { - "$ref": "#/definitions/CompositeTypes2" - } - ] - }, - "nativeQueries": { - "default": {}, - "allOf": [ - { - "$ref": "#/definitions/NativeQueries2" - } - ] - } - } - }, - "TablesInfo2": { - "description": "Mapping from a \"table\" name to its information.", - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/TableInfo2" - } - }, - "TableInfo2": { - "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/ColumnInfo2" - } - }, - "uniquenessConstraints": { - "default": {}, - "allOf": [ - { - "$ref": "#/definitions/UniquenessConstraints2" - } - ] - }, - "foreignRelations": { - "default": {}, - "allOf": [ - { - "$ref": "#/definitions/ForeignRelations2" - } - ] - }, - "description": { - "default": null, - "type": [ - "string", - "null" - ] - } - } - }, - "ColumnInfo2": { - "description": "Information about a database column.", - "type": "object", - "required": [ - "name", - "type" - ], - "properties": { - "name": { - "type": "string" - }, - "type": { - "$ref": "#/definitions/Type2" - }, - "nullable": { - "default": "nullable", - "allOf": [ - { - "$ref": "#/definitions/Nullable2" - } - ] - }, - "hasDefault": { - "$ref": "#/definitions/HasDefault2" - }, - "isIdentity": { - "$ref": "#/definitions/IsIdentity2" - }, - "isGenerated": { - "$ref": "#/definitions/IsGenerated2" - }, - "description": { - "default": null, - "type": [ - "string", - "null" - ] - } - } - }, - "Type2": { - "description": "The type of values that a column, field, or argument may take.", - "oneOf": [ - { - "type": "object", - "required": [ - "scalarType" - ], - "properties": { - "scalarType": { - "$ref": "#/definitions/ScalarTypeName" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "compositeType" - ], - "properties": { - "compositeType": { - "$ref": "#/definitions/CompositeTypeName" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "arrayType" - ], - "properties": { - "arrayType": { - "$ref": "#/definitions/Type2" - } - }, - "additionalProperties": false - } - ] - }, - "ScalarTypeName": { - "description": "A name of a Scalar Type, as it appears in the NDC scheme.", - "type": "string" - }, - "CompositeTypeName": { - "description": "The name of a Composite Type, as it appears in the NDC schema", - "type": "string" - }, - "Nullable2": { - "description": "Can this column contain null values", - "type": "string", - "enum": [ - "nullable", - "nonNullable" - ] - }, - "HasDefault2": { - "description": "Does this column have a default value.", - "type": "string", - "enum": [ - "noDefault", - "hasDefault" - ] - }, - "IsIdentity2": { - "description": "Is this column an identity column.", - "type": "string", - "enum": [ - "notIdentity", - "identityByDefault", - "identityAlways" - ] - }, - "IsGenerated2": { - "description": "Is this column a generated column.", - "type": "string", - "enum": [ - "notGenerated", - "stored" - ] - }, - "UniquenessConstraints2": { - "description": "A mapping from the name of a unique constraint to its value.", - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/UniquenessConstraint2" - } - }, - "UniquenessConstraint2": { - "description": "The set of columns that make up a uniqueness constraint.", - "type": "array", - "items": { - "type": "string" - }, - "uniqueItems": true - }, - "ForeignRelations2": { - "description": "A mapping from the name of a foreign key constraint to its value.", - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/ForeignRelation2" - } - }, - "ForeignRelation2": { - "description": "A foreign key constraint.", - "type": "object", - "required": [ - "columnMapping", - "foreignTable" - ], - "properties": { - "foreignSchema": { - "type": [ - "string", - "null" - ] - }, - "foreignTable": { - "type": "string" - }, - "columnMapping": { - "type": "object", - "additionalProperties": { - "type": "string" - } - } - } - }, - "ScalarTypes": { - "description": "Map of all known/occurring scalar types.", - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/ScalarType2" - } - }, - "ScalarType2": { - "description": "Information about a scalar type. A scalar type is completely characterized by its name and the operations you can do on it.", - "type": "object", - "required": [ - "aggregateFunctions", - "comparisonOperators", - "schemaName", - "typeName" - ], - "properties": { - "typeName": { - "type": "string" - }, - "schemaName": { - "type": "string" - }, - "description": { - "type": [ - "string", - "null" - ] - }, - "aggregateFunctions": { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/AggregateFunction2" - } - }, - "comparisonOperators": { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/ComparisonOperator2" - } - }, - "typeRepresentation": { - "anyOf": [ - { - "$ref": "#/definitions/TypeRepresentation2" - }, - { - "type": "null" - } - ] - } - } - }, - "AggregateFunction2": { - "type": "object", - "required": [ - "returnType" - ], - "properties": { - "returnType": { - "$ref": "#/definitions/ScalarTypeName" - } - } - }, - "ComparisonOperator2": { - "description": "Represents a postgres binary comparison operator", - "type": "object", - "required": [ - "argumentType", - "operatorKind", - "operatorName" - ], - "properties": { - "operatorName": { - "type": "string" - }, - "operatorKind": { - "$ref": "#/definitions/OperatorKind2" - }, - "argumentType": { - "$ref": "#/definitions/ScalarTypeName" - }, - "isInfix": { - "default": true, - "type": "boolean" - } - } - }, - "OperatorKind2": { - "description": "Is it a built-in operator, or a custom operator.", - "type": "string", - "enum": [ - "equal", - "in", - "custom" - ] - }, - "TypeRepresentation2": { - "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 - } - ] - }, - "CompositeTypes2": { - "description": "Map of all known composite types.", - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/CompositeType2" - } - }, - "CompositeType2": { - "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", - "schemaName", - "typeName" - ], - "properties": { - "typeName": { - "type": "string" - }, - "schemaName": { - "type": "string" - }, - "fields": { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/FieldInfo2" - } - }, - "description": { - "default": null, - "type": [ - "string", - "null" - ] - } - } - }, - "FieldInfo2": { - "description": "Information about a composite type field.", - "type": "object", - "required": [ - "fieldName", - "type" - ], - "properties": { - "fieldName": { - "type": "string" - }, - "type": { - "$ref": "#/definitions/Type2" - }, - "description": { - "default": null, - "type": [ - "string", - "null" - ] - } - } - }, - "NativeQueries2": { - "description": "Metadata information of native queries.", - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/NativeQueryInfo2" - } - }, - "NativeQueryInfo2": { - "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/ReadOnlyColumnInfo2" - } - }, - "arguments": { - "description": "Names and types of arguments that can be passed to this Native Query", - "default": {}, - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/ReadOnlyColumnInfo2" - } - }, - "description": { - "default": null, - "type": [ - "string", - "null" - ] - }, - "isProcedure": { - "description": "True if this native query mutates the database", - "type": "boolean" - } - } - }, - "ReadOnlyColumnInfo2": { - "description": "Information about a native query column.", - "type": "object", - "required": [ - "name", - "type" - ], - "properties": { - "name": { - "type": "string" - }, - "type": { - "$ref": "#/definitions/Type2" - }, - "nullable": { - "default": "nullable", - "allOf": [ - { - "$ref": "#/definitions/Nullable2" - } - ] - }, - "description": { - "default": null, - "type": [ - "string", - "null" - ] - } - } - }, - "IntrospectionOptions2": { - "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" - ], - "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/ComparisonOperatorMapping2" - } - }, - "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" - } - } - } - }, - "ComparisonOperatorMapping2": { - "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/OperatorKind2" - } - ] - } - } - }, - "MutationsVersion2": { - "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 index 26f5c8416..dd02025cf 100644 --- 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 @@ -4,1778 +4,315 @@ expression: generated_schema_json --- { "$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema", - "title": "RawConfiguration", - "description": "The parsed connector configuration.", - "oneOf": [ - { - "description": "Initial configuration, just enough to connect to a database and elaborate a full 'Configuration'.", - "type": "object", - "required": [ - "connectionSettings", - "version" - ], - "properties": { - "version": { - "type": "string", - "enum": [ - "3" - ] - }, - "$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 - } - } - }, - { - "description": "Initial configuration, just enough to connect to a database and elaborate a full 'Configuration'.", - "type": "object", - "required": [ - "connectionSettings", - "version" - ], - "properties": { - "version": { - "type": "string", - "enum": [ - "4" - ] - }, - "$schema": { - "description": "Jsonschema of the configuration format.", - "default": null, - "type": "string", - "nullable": true - }, - "connectionSettings": { - "description": "Database connection settings.", - "allOf": [ - { - "$ref": "#/components/schemas/DatabaseConnectionSettings2" - } - ] - }, - "metadata": { - "description": "Connector metadata.", - "default": { - "tables": {}, - "scalarTypes": {}, - "compositeTypes": {}, - "nativeQueries": {} - }, - "allOf": [ - { - "$ref": "#/components/schemas/Metadata2" - } - ] - }, - "introspectionOptions": { - "description": "Database introspection options.", - "default": { - "excludedSchemas": [ - "information_schema", - "pg_catalog", - "tiger", - "crdb_internal", - "columnar", - "columnar_internal" - ], - "unqualifiedSchemasForTables": [ - "public" - ], - "unqualifiedSchemasForTypesAndProcedures": [ - "public", - "pg_catalog", - "tiger" - ], - "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/IntrospectionOptions2" - } - ] - }, - "mutationsVersion": { - "description": "Which version of the generated mutation procedures to include in the schema response", - "default": null, - "allOf": [ - { - "$ref": "#/components/schemas/MutationsVersion2" - } - ], - "nullable": true - } - } - } - ], - "definitions": { - "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, - "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 - }, - "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" - } + "title": "ParsedConfiguration", + "description": "Initial configuration, just enough to connect to a database and elaborate a full 'Configuration'.", + "type": "object", + "required": [ + "connectionSettings" + ], + "properties": { + "$schema": { + "description": "Jsonschema of the configuration format.", + "default": null, + "type": "string", + "nullable": true + }, + "connectionSettings": { + "description": "Database connection settings.", + "allOf": [ + { + "$ref": "#/components/schemas/DatabaseConnectionSettings" } - } + ] }, - "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" - } - ] + "metadata": { + "description": "Connector metadata.", + "default": { + "tables": {}, + "scalarTypes": {}, + "compositeTypes": {}, + "nativeQueries": {} + }, + "allOf": [ + { + "$ref": "#/components/schemas/Metadata" } - } + ] }, - "MutationsVersion": { - "description": "Which version of the generated mutations will be included in the schema", - "type": "string", - "enum": [ - "v1", - "veryExperimentalWip" + "introspectionOptions": { + "description": "Database introspection options.", + "default": { + "excludedSchemas": [ + "information_schema", + "pg_catalog", + "tiger", + "crdb_internal", + "columnar", + "columnar_internal" + ], + "unqualifiedSchemasForTables": [ + "public" + ], + "unqualifiedSchemasForTypesAndProcedures": [ + "public", + "pg_catalog", + "tiger" + ], + "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" + } ] }, - "DatabaseConnectionSettings2": { + "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": { + "DatabaseConnectionSettings": { "description": "Database connection settings.", "type": "object", "required": [ @@ -1815,7 +352,94 @@ expression: generated_schema_json } } }, - "Metadata2": { + "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 + }, + "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": { @@ -1823,7 +447,7 @@ expression: generated_schema_json "default": {}, "allOf": [ { - "$ref": "#/components/schemas/TablesInfo2" + "$ref": "#/components/schemas/TablesInfo" } ] }, @@ -1839,7 +463,7 @@ expression: generated_schema_json "default": {}, "allOf": [ { - "$ref": "#/components/schemas/CompositeTypes2" + "$ref": "#/components/schemas/CompositeTypes" } ] }, @@ -1847,20 +471,20 @@ expression: generated_schema_json "default": {}, "allOf": [ { - "$ref": "#/components/schemas/NativeQueries2" + "$ref": "#/components/schemas/NativeQueries" } ] } } }, - "TablesInfo2": { + "TablesInfo": { "description": "Mapping from a \"table\" name to its information.", "type": "object", "additionalProperties": { - "$ref": "#/components/schemas/TableInfo2" + "$ref": "#/components/schemas/TableInfo" } }, - "TableInfo2": { + "TableInfo": { "description": "Information about a database table (or any other kind of relation).", "type": "object", "required": [ @@ -1878,14 +502,14 @@ expression: generated_schema_json "columns": { "type": "object", "additionalProperties": { - "$ref": "#/components/schemas/ColumnInfo2" + "$ref": "#/components/schemas/ColumnInfo" } }, "uniquenessConstraints": { "default": {}, "allOf": [ { - "$ref": "#/components/schemas/UniquenessConstraints2" + "$ref": "#/components/schemas/UniquenessConstraints" } ] }, @@ -1893,7 +517,7 @@ expression: generated_schema_json "default": {}, "allOf": [ { - "$ref": "#/components/schemas/ForeignRelations2" + "$ref": "#/components/schemas/ForeignRelations" } ] }, @@ -1904,7 +528,7 @@ expression: generated_schema_json } } }, - "ColumnInfo2": { + "ColumnInfo": { "description": "Information about a database column.", "type": "object", "required": [ @@ -1916,24 +540,24 @@ expression: generated_schema_json "type": "string" }, "type": { - "$ref": "#/components/schemas/Type2" + "$ref": "#/components/schemas/Type" }, "nullable": { "default": "nullable", "allOf": [ { - "$ref": "#/components/schemas/Nullable2" + "$ref": "#/components/schemas/Nullable" } ] }, "hasDefault": { - "$ref": "#/components/schemas/HasDefault2" + "$ref": "#/components/schemas/HasDefault" }, "isIdentity": { - "$ref": "#/components/schemas/IsIdentity2" + "$ref": "#/components/schemas/IsIdentity" }, "isGenerated": { - "$ref": "#/components/schemas/IsGenerated2" + "$ref": "#/components/schemas/IsGenerated" }, "description": { "default": null, @@ -1942,7 +566,7 @@ expression: generated_schema_json } } }, - "Type2": { + "Type": { "description": "The type of values that a column, field, or argument may take.", "oneOf": [ { @@ -1976,7 +600,7 @@ expression: generated_schema_json ], "properties": { "arrayType": { - "$ref": "#/components/schemas/Type2" + "$ref": "#/components/schemas/Type" } }, "additionalProperties": false @@ -1991,7 +615,7 @@ expression: generated_schema_json "description": "The name of a Composite Type, as it appears in the NDC schema", "type": "string" }, - "Nullable2": { + "Nullable": { "description": "Can this column contain null values", "type": "string", "enum": [ @@ -1999,7 +623,7 @@ expression: generated_schema_json "nonNullable" ] }, - "HasDefault2": { + "HasDefault": { "description": "Does this column have a default value.", "type": "string", "enum": [ @@ -2007,7 +631,7 @@ expression: generated_schema_json "hasDefault" ] }, - "IsIdentity2": { + "IsIdentity": { "description": "Is this column an identity column.", "type": "string", "enum": [ @@ -2016,7 +640,7 @@ expression: generated_schema_json "identityAlways" ] }, - "IsGenerated2": { + "IsGenerated": { "description": "Is this column a generated column.", "type": "string", "enum": [ @@ -2024,14 +648,14 @@ expression: generated_schema_json "stored" ] }, - "UniquenessConstraints2": { + "UniquenessConstraints": { "description": "A mapping from the name of a unique constraint to its value.", "type": "object", "additionalProperties": { - "$ref": "#/components/schemas/UniquenessConstraint2" + "$ref": "#/components/schemas/UniquenessConstraint" } }, - "UniquenessConstraint2": { + "UniquenessConstraint": { "description": "The set of columns that make up a uniqueness constraint.", "type": "array", "items": { @@ -2039,14 +663,14 @@ expression: generated_schema_json }, "uniqueItems": true }, - "ForeignRelations2": { + "ForeignRelations": { "description": "A mapping from the name of a foreign key constraint to its value.", "type": "object", "additionalProperties": { - "$ref": "#/components/schemas/ForeignRelation2" + "$ref": "#/components/schemas/ForeignRelation" } }, - "ForeignRelation2": { + "ForeignRelation": { "description": "A foreign key constraint.", "type": "object", "required": [ @@ -2073,10 +697,10 @@ expression: generated_schema_json "description": "Map of all known/occurring scalar types.", "type": "object", "additionalProperties": { - "$ref": "#/components/schemas/ScalarType2" + "$ref": "#/components/schemas/ScalarType" } }, - "ScalarType2": { + "ScalarType": { "description": "Information about a scalar type. A scalar type is completely characterized by its name and the operations you can do on it.", "type": "object", "required": [ @@ -2099,26 +723,26 @@ expression: generated_schema_json "aggregateFunctions": { "type": "object", "additionalProperties": { - "$ref": "#/components/schemas/AggregateFunction2" + "$ref": "#/components/schemas/AggregateFunction" } }, "comparisonOperators": { "type": "object", "additionalProperties": { - "$ref": "#/components/schemas/ComparisonOperator2" + "$ref": "#/components/schemas/ComparisonOperator" } }, "typeRepresentation": { "allOf": [ { - "$ref": "#/components/schemas/TypeRepresentation2" + "$ref": "#/components/schemas/TypeRepresentation" } ], "nullable": true } } }, - "AggregateFunction2": { + "AggregateFunction": { "type": "object", "required": [ "returnType" @@ -2129,7 +753,7 @@ expression: generated_schema_json } } }, - "ComparisonOperator2": { + "ComparisonOperator": { "description": "Represents a postgres binary comparison operator", "type": "object", "required": [ @@ -2142,7 +766,7 @@ expression: generated_schema_json "type": "string" }, "operatorKind": { - "$ref": "#/components/schemas/OperatorKind2" + "$ref": "#/components/schemas/OperatorKind" }, "argumentType": { "$ref": "#/components/schemas/ScalarTypeName" @@ -2153,7 +777,7 @@ expression: generated_schema_json } } }, - "OperatorKind2": { + "OperatorKind": { "description": "Is it a built-in operator, or a custom operator.", "type": "string", "enum": [ @@ -2162,7 +786,7 @@ expression: generated_schema_json "custom" ] }, - "TypeRepresentation2": { + "TypeRepresentation": { "description": "Type representation of a scalar type.", "oneOf": [ { @@ -2330,14 +954,14 @@ expression: generated_schema_json } ] }, - "CompositeTypes2": { + "CompositeTypes": { "description": "Map of all known composite types.", "type": "object", "additionalProperties": { - "$ref": "#/components/schemas/CompositeType2" + "$ref": "#/components/schemas/CompositeType" } }, - "CompositeType2": { + "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": [ @@ -2355,7 +979,7 @@ expression: generated_schema_json "fields": { "type": "object", "additionalProperties": { - "$ref": "#/components/schemas/FieldInfo2" + "$ref": "#/components/schemas/FieldInfo" } }, "description": { @@ -2365,7 +989,7 @@ expression: generated_schema_json } } }, - "FieldInfo2": { + "FieldInfo": { "description": "Information about a composite type field.", "type": "object", "required": [ @@ -2377,7 +1001,7 @@ expression: generated_schema_json "type": "string" }, "type": { - "$ref": "#/components/schemas/Type2" + "$ref": "#/components/schemas/Type" }, "description": { "default": null, @@ -2386,14 +1010,14 @@ expression: generated_schema_json } } }, - "NativeQueries2": { + "NativeQueries": { "description": "Metadata information of native queries.", "type": "object", "additionalProperties": { - "$ref": "#/components/schemas/NativeQueryInfo2" + "$ref": "#/components/schemas/NativeQueryInfo" } }, - "NativeQueryInfo2": { + "NativeQueryInfo": { "description": "Information about a Native Query", "type": "object", "required": [ @@ -2413,7 +1037,7 @@ expression: generated_schema_json "description": "Columns returned by the Native Query", "type": "object", "additionalProperties": { - "$ref": "#/components/schemas/ReadOnlyColumnInfo2" + "$ref": "#/components/schemas/ReadOnlyColumnInfo" } }, "arguments": { @@ -2421,7 +1045,7 @@ expression: generated_schema_json "default": {}, "type": "object", "additionalProperties": { - "$ref": "#/components/schemas/ReadOnlyColumnInfo2" + "$ref": "#/components/schemas/ReadOnlyColumnInfo" } }, "description": { @@ -2435,7 +1059,48 @@ expression: generated_schema_json } } }, - "ReadOnlyColumnInfo2": { + "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": [ @@ -2447,13 +1112,13 @@ expression: generated_schema_json "type": "string" }, "type": { - "$ref": "#/components/schemas/Type2" + "$ref": "#/components/schemas/Type" }, "nullable": { "default": "nullable", "allOf": [ { - "$ref": "#/components/schemas/Nullable2" + "$ref": "#/components/schemas/Nullable" } ] }, @@ -2464,7 +1129,7 @@ expression: generated_schema_json } } }, - "IntrospectionOptions2": { + "IntrospectionOptions": { "description": "Options which only influence how the configuration is updated.", "type": "object", "properties": { @@ -2616,7 +1281,7 @@ expression: generated_schema_json ], "type": "array", "items": { - "$ref": "#/components/schemas/ComparisonOperatorMapping2" + "$ref": "#/components/schemas/ComparisonOperatorMapping" } }, "introspectPrefixFunctionComparisonOperators": { @@ -2756,7 +1421,7 @@ expression: generated_schema_json } } }, - "ComparisonOperatorMapping2": { + "ComparisonOperatorMapping": { "description": "Define the names that comparison operators will be exposed as by the automatic introspection.", "type": "object", "required": [ @@ -2777,13 +1442,13 @@ expression: generated_schema_json "description": "Equal, In or Custom.", "allOf": [ { - "$ref": "#/components/schemas/OperatorKind2" + "$ref": "#/components/schemas/OperatorKind" } ] } } }, - "MutationsVersion2": { + "MutationsVersion": { "description": "Which version of the generated mutations will be included in the schema", "type": "string", "enum": [ From d8bb648379e674a80e7b1b30e37d20c823f60b81 Mon Sep 17 00:00:00 2001 From: Philip Lykke Carlsen Date: Fri, 3 May 2024 15:44:19 +0200 Subject: [PATCH 08/18] wip --- Cargo.lock | 40 -- crates/cli/Cargo.toml | 2 - crates/configuration/src/configuration.rs | 9 +- crates/configuration/src/error.rs | 26 +- .../src/version3/metadata/native_queries.rs | 16 +- crates/configuration/src/version3/mod.rs | 9 + .../src/version4/metadata/native_queries.rs | 16 +- crates/configuration/src/version4/mod.rs | 60 ++- .../src/version4/upgrade_from_v3.rs | 5 +- crates/documentation/openapi/src/generator.rs | 2 +- ...ation_tests__get_configuration_schema.snap | 12 +- ...tests__get_rawconfiguration_v3_schema.snap | 12 +- ...v3_initial_configuration_is_unchanged.snap | 1 + ..._openapi__up_to_date_generated_schema.snap | 432 +++++++++--------- crates/tests/tests-common/Cargo.toml | 1 - .../common_tests/configuration_v3_tests.rs | 6 +- 16 files changed, 341 insertions(+), 308 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b1840e9ab..8757c7bd5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -463,15 +463,6 @@ version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" -[[package]] -name = "copy_dir" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "543d1dd138ef086e2ff05e3a48cf9da045da2033d16f8538fd76b86cd49b2ca3" -dependencies = [ - "walkdir", -] - [[package]] name = "core-foundation" version = "0.9.4" @@ -1466,9 +1457,7 @@ dependencies = [ "clap", "insta", "ndc-postgres-configuration", - "schemars", "serde", - "serde_json", "serde_yaml", "tempfile", "thiserror", @@ -2406,15 +2395,6 @@ dependencies = [ "safe-regex-compiler", ] -[[package]] -name = "same-file" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" -dependencies = [ - "winapi-util", -] - [[package]] name = "schannel" version = "0.1.23" @@ -3067,7 +3047,6 @@ dependencies = [ "anyhow", "axum", "axum-test-helper", - "copy_dir", "env_logger", "hyper", "jsonschema", @@ -3583,16 +3562,6 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" -[[package]] -name = "walkdir" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" -dependencies = [ - "same-file", - "winapi-util", -] - [[package]] name = "want" version = "0.3.1" @@ -3746,15 +3715,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" -[[package]] -name = "winapi-util" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" -dependencies = [ - "winapi", -] - [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index 5a37cf2a7..0e46b87c9 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -12,9 +12,7 @@ ndc-postgres-configuration = { path = "../configuration" } anyhow = "1.0.82" clap = { version = "4.5.4", features = ["derive", "env"] } -schemars = { version = "0.8.17", features = ["smol_str", "preserve_order"] } serde = { version = "1.0.199", features = ["derive"] } -serde_json = { version = "1.0.116", features = ["raw_value"] } serde_yaml = "0.9.34" thiserror = "1.0.59" tokio = { version = "1.37.0", features = ["full"] } diff --git a/crates/configuration/src/configuration.rs b/crates/configuration/src/configuration.rs index 1d8696089..4b20799cb 100644 --- a/crates/configuration/src/configuration.rs +++ b/crates/configuration/src/configuration.rs @@ -6,7 +6,8 @@ use query_engine_metadata::metadata; use crate::environment::Environment; use crate::error::{ - MakeRuntimeConfigurationError, ParseConfigurationError, WriteParsedConfigurationError, + MakeRuntimeConfigurationError, MultiError, ParseConfigurationError, + WriteParsedConfigurationError, }; use crate::values::{IsolationLevel, PoolSettings}; use crate::version3; @@ -68,9 +69,9 @@ pub async fn parse_configuration( // Try parsing each supported version in turn match version4::parse_configuration(configuration_dir.as_ref()).await { Err(v4_err) => match version3::parse_configuration(configuration_dir.as_ref()).await { - Err(v3_err) => Err(ParseConfigurationError::UnableToParseAnyVersions(vec![ - v3_err, v4_err, - ])), + Err(v3_err) => Err(ParseConfigurationError::UnableToParseAnyVersions( + MultiError(vec![Box::new(v4_err), Box::new(v3_err)]), + )), Ok(config) => Ok(ParsedConfiguration::Version3(config)), }, Ok(config) => Ok(ParsedConfiguration::Version4(config)), diff --git a/crates/configuration/src/error.rs b/crates/configuration/src/error.rs index d2227495f..2c024a662 100644 --- a/crates/configuration/src/error.rs +++ b/crates/configuration/src/error.rs @@ -1,5 +1,7 @@ //! Errors that can be thrown when processing configuration. +use std::fmt::Display; + /// The errors that can be thrown when processing configuration. /// /// This is effectively a copy of the `ParseError` enum in the `ndc-sdk` crate. However, we don't @@ -26,8 +28,22 @@ pub enum ParseConfigurationError { #[error("Did not find expected version tag: \"{0}\"")] DidNotFindExpectedVersionTag(String), - #[error("Unable to parse any configuration versions: TODO")] - UnableToParseAnyVersions(Vec), + #[error("Unable to parse any configuration versions: {0}")] + UnableToParseAnyVersions(MultiError), +} + +#[derive(Debug)] +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 { + " * ".fmt(f)?; + err.fmt(f)?; + "\n".fmt(f)?; + } + Ok(()) + } } #[derive(Debug, thiserror::Error)] @@ -37,6 +53,12 @@ pub enum WriteParsedConfigurationError { #[error("I/O error: {0}")] IoError(#[from] std::io::Error), + + #[error("Trying to write file \"{file}\" outside destination dir \"{dir}\"")] + WritingOutsideDestinationDir { + dir: std::path::PathBuf, + file: std::path::PathBuf, + }, } #[derive(Debug, thiserror::Error)] diff --git a/crates/configuration/src/version3/metadata/native_queries.rs b/crates/configuration/src/version3/metadata/native_queries.rs index 4545cf13b..1bacaacd2 100644 --- a/crates/configuration/src/version3/metadata/native_queries.rs +++ b/crates/configuration/src/version3/metadata/native_queries.rs @@ -158,7 +158,7 @@ impl NativeQuerySqlEither { NativeQuerySqlEither::NativeQuerySql(value) => Ok(value.clone()), NativeQuerySqlEither::NativeQuerySqlExternal(external) => match external { NativeQuerySqlExternal::File { file } => { - parse_native_query_from_file(absolute_configuration_directory.join(file)) + parse_native_query_from_file(absolute_configuration_directory, file) } NativeQuerySqlExternal::Inline { inline } | NativeQuerySqlExternal::InlineUntagged(inline) => Ok(NativeQuerySql::Inline { @@ -244,13 +244,19 @@ impl JsonSchema for NativeQueryParts { // Parsing /// Read a file a parse it into native query parts. -pub fn parse_native_query_from_file(file: std::path::PathBuf) -> Result { - let contents: String = match fs::read_to_string(&file) { +pub fn parse_native_query_from_file( + absolute_configuration_directory: &std::path::Path, + file: &std::path::Path, +) -> Result { + let contents: String = match fs::read_to_string(absolute_configuration_directory.join(file)) { Ok(ok) => Ok(ok), - Err(err) => Err(format!("{}: {}", &file.display(), err)), + Err(err) => Err(format!("{}: {}", file.display(), err)), }?; let sql = parse_native_query(&contents); - Ok(NativeQuerySql::FromFile { file, sql }) + Ok(NativeQuerySql::FromFile { + file: file.to_path_buf(), + sql, + }) } /// Parse a native query into parts where variables have the syntax `{{}}`. diff --git a/crates/configuration/src/version3/mod.rs b/crates/configuration/src/version3/mod.rs index 6f00efdd7..ea2934a6f 100644 --- a/crates/configuration/src/version3/mod.rs +++ b/crates/configuration/src/version3/mod.rs @@ -33,6 +33,7 @@ const CONFIGURATION_QUERY: &str = include_str!("version3.sql"); #[derive(Clone, PartialEq, Eq, Debug, Deserialize, Serialize, JsonSchema)] #[serde(rename_all = "camelCase")] pub struct RawConfiguration { + pub version: Version, /// Jsonschema of the configuration format. #[serde(rename = "$schema")] #[serde(default)] @@ -50,9 +51,16 @@ pub struct RawConfiguration { pub mutations_version: Option, } +#[derive(Clone, PartialEq, Eq, Debug, Deserialize, Serialize, JsonSchema)] +pub enum Version { + #[serde(rename = "3")] + This, +} + impl RawConfiguration { pub fn empty() -> Self { Self { + version: Version::This, schema: Some(CONFIGURATION_JSONSCHEMA_FILENAME.to_string()), connection_settings: connection_settings::DatabaseConnectionSettings::empty(), metadata: metadata::Metadata::default(), @@ -187,6 +195,7 @@ pub async fn introspect( filter_type_representations(&scalar_types, type_representations); Ok(RawConfiguration { + version: Version::This, schema: args.schema, connection_settings: args.connection_settings, metadata: metadata::Metadata { diff --git a/crates/configuration/src/version4/metadata/native_queries.rs b/crates/configuration/src/version4/metadata/native_queries.rs index f7042705d..2630e11c8 100644 --- a/crates/configuration/src/version4/metadata/native_queries.rs +++ b/crates/configuration/src/version4/metadata/native_queries.rs @@ -158,7 +158,7 @@ impl NativeQuerySqlEither { NativeQuerySqlEither::NativeQuerySql(value) => Ok(value.clone()), NativeQuerySqlEither::NativeQuerySqlExternal(external) => match external { NativeQuerySqlExternal::File { file } => { - parse_native_query_from_file(absolute_configuration_directory.join(file)) + parse_native_query_from_file(absolute_configuration_directory, file) } NativeQuerySqlExternal::Inline { inline } | NativeQuerySqlExternal::InlineUntagged(inline) => Ok(NativeQuerySql::Inline { @@ -240,13 +240,19 @@ impl JsonSchema for NativeQueryParts { // Parsing /// Read a file a parse it into native query parts. -pub fn parse_native_query_from_file(file: std::path::PathBuf) -> Result { - let contents: String = match fs::read_to_string(&file) { +pub fn parse_native_query_from_file( + absolute_configuration_directory: &std::path::Path, + file: &std::path::Path, +) -> Result { + let contents: String = match fs::read_to_string(absolute_configuration_directory.join(file)) { Ok(ok) => Ok(ok), - Err(err) => Err(format!("{}: {}", &file.display(), err)), + Err(err) => Err(format!("{}: {}", file.display(), err)), }?; let sql = parse_native_query(&contents); - Ok(NativeQuerySql::FromFile { file, sql }) + Ok(NativeQuerySql::FromFile { + file: file.to_path_buf(), + sql, + }) } /// Parse a native query into parts where variables have the syntax `{{}}`. diff --git a/crates/configuration/src/version4/mod.rs b/crates/configuration/src/version4/mod.rs index 7796d3826..4fe432e54 100644 --- a/crates/configuration/src/version4/mod.rs +++ b/crates/configuration/src/version4/mod.rs @@ -35,6 +35,7 @@ const CONFIGURATION_QUERY: &str = include_str!("introspection.sql"); #[derive(Clone, PartialEq, Eq, Debug, Deserialize, Serialize, JsonSchema)] #[serde(rename_all = "camelCase")] pub struct ParsedConfiguration { + pub version: Version, /// Jsonschema of the configuration format. #[serde(rename = "$schema")] #[serde(default)] @@ -52,9 +53,16 @@ pub struct ParsedConfiguration { pub mutations_version: Option, } +#[derive(Clone, PartialEq, Eq, Debug, Deserialize, Serialize, JsonSchema)] +pub enum Version { + #[serde(rename = "4")] + This, +} + impl ParsedConfiguration { pub fn empty() -> Self { Self { + version: Version::This, schema: Some(CONFIGURATION_JSONSCHEMA_FILENAME.to_string()), connection_settings: connection_settings::DatabaseConnectionSettings::empty(), metadata: metadata::Metadata::default(), @@ -166,6 +174,7 @@ pub async fn introspect( // ); // Ok(ParsedConfiguration { + version: Version::This, schema: args.schema, connection_settings: args.connection_settings, metadata: metadata::Metadata { @@ -423,36 +432,14 @@ pub async fn parse_configuration( err )) })?; - let configuration_json_value = - serde_json::to_value(configuration_file_contents).map_err(|error| { - ParseConfigurationError::ParseError { - file_path: configuration_file.clone(), - line: error.line(), - column: error.column(), - message: error.to_string(), - } - })?; - - let version_tag = configuration_json_value - .as_object() - .and_then(|o| o.get("version")) - .and_then(|v| v.as_str()); - match version_tag { - Some("4") => {} - _ => Err(ParseConfigurationError::DidNotFindExpectedVersionTag( - "4".to_string(), - ))?, - } - let mut parsed_config: ParsedConfiguration = serde_json::from_value(configuration_json_value) - .map_err(|error| { - ParseConfigurationError::ParseError { + let mut parsed_config: ParsedConfiguration = serde_json::from_str(&configuration_file_contents) + .map_err(|error| ParseConfigurationError::ParseError { file_path: configuration_file.clone(), line: error.line(), column: error.column(), message: error.to_string(), - } - })?; + })?; // look for native query sql file references and read from disk. for native_query_sql in parsed_config.metadata.native_queries.0.values_mut() { native_query_sql.sql = metadata::NativeQuerySqlEither::NativeQuerySql( @@ -482,6 +469,29 @@ pub async fn write_parsed_configuration( ) .await?; + // look for native query sql file references and read from disk. + for native_query_sql in parsed_config.metadata.native_queries.0.values() { + if let metadata::NativeQuerySqlEither::NativeQuerySql( + metadata::NativeQuerySql::FromFile { file, sql }, + ) = &native_query_sql.sql + { + if file.is_absolute() || file.starts_with("..") { + Err( + WriteParsedConfigurationError::WritingOutsideDestinationDir { + dir: out_dir.as_ref().to_owned(), + file: file.clone(), + }, + )?; + }; + + let native_query_file = out_dir.as_ref().to_owned().join(file); + if let Some(native_query_sql_dir) = native_query_file.parent() { + fs::create_dir_all(native_query_sql_dir).await?; + }; + fs::write(native_query_file, String::from(sql.clone())).await?; + }; + } + // create the jsonschema file let configuration_jsonschema_file_path = out_dir .as_ref() diff --git a/crates/configuration/src/version4/upgrade_from_v3.rs b/crates/configuration/src/version4/upgrade_from_v3.rs index 325890fe7..8a5f33a29 100644 --- a/crates/configuration/src/version4/upgrade_from_v3.rs +++ b/crates/configuration/src/version4/upgrade_from_v3.rs @@ -4,14 +4,16 @@ use std::collections::BTreeMap; use std::collections::BTreeSet; use crate::version3; +use crate::version4; use crate::version4::comparison; use crate::version4::connection_settings; use crate::version4::metadata; use crate::version4::options; use crate::version4::ParsedConfiguration; -pub fn upgrade_from_v3(v: version3::RawConfiguration) -> crate::version4::ParsedConfiguration { +pub fn upgrade_from_v3(v: version3::RawConfiguration) -> version4::ParsedConfiguration { let version3::RawConfiguration { + version: _, schema, connection_settings, metadata, @@ -20,6 +22,7 @@ pub fn upgrade_from_v3(v: version3::RawConfiguration) -> crate::version4::Parsed } = v; ParsedConfiguration { + version: version4::Version::This, schema, connection_settings: upgrade_connection_settings(connection_settings), metadata: upgrade_metadata(metadata), diff --git a/crates/documentation/openapi/src/generator.rs b/crates/documentation/openapi/src/generator.rs index 4e2fa8325..645dd0bba 100644 --- a/crates/documentation/openapi/src/generator.rs +++ b/crates/documentation/openapi/src/generator.rs @@ -4,5 +4,5 @@ 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::() + .into_root_schema_for::() } diff --git a/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__configuration_tests__get_configuration_schema.snap b/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__configuration_tests__get_configuration_schema.snap index 293bdf7e9..75dfb71d2 100644 --- a/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__configuration_tests__get_configuration_schema.snap +++ b/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__configuration_tests__get_configuration_schema.snap @@ -8,9 +8,13 @@ expression: schema "description": "Initial configuration, just enough to connect to a database and elaborate a full 'Configuration'.", "type": "object", "required": [ - "connectionSettings" + "connectionSettings", + "version" ], "properties": { + "version": { + "$ref": "#/definitions/Version" + }, "$schema": { "description": "Jsonschema of the configuration format.", "default": null, @@ -320,6 +324,12 @@ expression: schema } }, "definitions": { + "Version": { + "type": "string", + "enum": [ + "3" + ] + }, "DatabaseConnectionSettings": { "description": "Database connection settings.", "type": "object", 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 index 293bdf7e9..75dfb71d2 100644 --- 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 @@ -8,9 +8,13 @@ expression: schema "description": "Initial configuration, just enough to connect to a database and elaborate a full 'Configuration'.", "type": "object", "required": [ - "connectionSettings" + "connectionSettings", + "version" ], "properties": { + "version": { + "$ref": "#/definitions/Version" + }, "$schema": { "description": "Jsonschema of the configuration format.", "default": null, @@ -320,6 +324,12 @@ expression: schema } }, "definitions": { + "Version": { + "type": "string", + "enum": [ + "3" + ] + }, "DatabaseConnectionSettings": { "description": "Database connection settings.", "type": "object", 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/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__configuration_tests__postgres_current_only_configure_v3_initial_configuration_is_unchanged.snap index efc690ba6..87a5009c7 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/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__configuration_tests__postgres_current_only_configure_v3_initial_configuration_is_unchanged.snap @@ -3,6 +3,7 @@ source: crates/tests/databases-tests/src/postgres/configuration_tests.rs expression: default_configuration --- { + "version": "3", "$schema": "schema.json", "connectionSettings": { "connectionUri": { 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 index dd02025cf..7c4e646e2 100644 --- 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 @@ -4,13 +4,17 @@ expression: generated_schema_json --- { "$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema", - "title": "ParsedConfiguration", + "title": "RawConfiguration", "description": "Initial configuration, just enough to connect to a database and elaborate a full 'Configuration'.", "type": "object", "required": [ - "connectionSettings" + "connectionSettings", + "version" ], "properties": { + "version": { + "$ref": "#/components/schemas/Version" + }, "$schema": { "description": "Jsonschema of the configuration format.", "default": null, @@ -29,9 +33,11 @@ expression: generated_schema_json "description": "Connector metadata.", "default": { "tables": {}, - "scalarTypes": {}, "compositeTypes": {}, - "nativeQueries": {} + "nativeQueries": {}, + "aggregateFunctions": {}, + "comparisonOperators": {}, + "typeRepresentations": {} }, "allOf": [ { @@ -56,7 +62,9 @@ expression: generated_schema_json "unqualifiedSchemasForTypesAndProcedures": [ "public", "pg_catalog", - "tiger" + "tiger", + "auth", + "pgsodium" ], "comparisonOperatorMapping": [ { @@ -312,6 +320,12 @@ expression: generated_schema_json } }, "definitions": { + "Version": { + "type": "string", + "enum": [ + "3" + ] + }, "DatabaseConnectionSettings": { "description": "Database connection settings.", "type": "object", @@ -451,27 +465,43 @@ expression: generated_schema_json } ] }, - "scalarTypes": { + "compositeTypes": { "default": {}, "allOf": [ { - "$ref": "#/components/schemas/ScalarTypes" + "$ref": "#/components/schemas/CompositeTypes" } ] }, - "compositeTypes": { + "nativeQueries": { "default": {}, "allOf": [ { - "$ref": "#/components/schemas/CompositeTypes" + "$ref": "#/components/schemas/NativeQueries" } ] }, - "nativeQueries": { + "aggregateFunctions": { "default": {}, "allOf": [ { - "$ref": "#/components/schemas/NativeQueries" + "$ref": "#/components/schemas/AggregateFunctions" + } + ] + }, + "comparisonOperators": { + "default": {}, + "allOf": [ + { + "$ref": "#/components/schemas/ComparisonOperators" + } + ] + }, + "typeRepresentations": { + "default": {}, + "allOf": [ + { + "$ref": "#/components/schemas/TypeRepresentations" } ] } @@ -576,7 +606,7 @@ expression: generated_schema_json ], "properties": { "scalarType": { - "$ref": "#/components/schemas/ScalarTypeName" + "$ref": "#/components/schemas/ScalarType" } }, "additionalProperties": false @@ -588,7 +618,7 @@ expression: generated_schema_json ], "properties": { "compositeType": { - "$ref": "#/components/schemas/CompositeTypeName" + "type": "string" } }, "additionalProperties": false @@ -607,12 +637,8 @@ expression: generated_schema_json } ] }, - "ScalarTypeName": { - "description": "A name of a Scalar Type, as it appears in the NDC scheme.", - "type": "string" - }, - "CompositeTypeName": { - "description": "The name of a Composite Type, as it appears in the NDC schema", + "ScalarType": { + "description": "A Scalar Type.", "type": "string" }, "Nullable": { @@ -693,55 +719,187 @@ expression: generated_schema_json } } }, - "ScalarTypes": { - "description": "Map of all known/occurring scalar types.", + "CompositeTypes": { + "description": "Map of all known composite types.", "type": "object", "additionalProperties": { - "$ref": "#/components/schemas/ScalarType" + "$ref": "#/components/schemas/CompositeType" } }, - "ScalarType": { - "description": "Information about a scalar type. A scalar type is completely characterized by its name and the operations you can do on it.", + "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": [ - "aggregateFunctions", - "comparisonOperators", - "schemaName", - "typeName" + "fields", + "name" ], "properties": { - "typeName": { + "name": { "type": "string" }, - "schemaName": { + "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" + } + ] }, - "aggregateFunctions": { + "columns": { + "description": "Columns returned by the Native Query", "type": "object", "additionalProperties": { - "$ref": "#/components/schemas/AggregateFunction" + "$ref": "#/components/schemas/ReadOnlyColumnInfo" } }, - "comparisonOperators": { + "arguments": { + "description": "Names and types of arguments that can be passed to this Native Query", + "default": {}, "type": "object", "additionalProperties": { - "$ref": "#/components/schemas/ComparisonOperator" + "$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" + } } }, - "typeRepresentation": { + { + "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/TypeRepresentation" + "$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": [ @@ -749,7 +907,17 @@ expression: generated_schema_json ], "properties": { "returnType": { - "$ref": "#/components/schemas/ScalarTypeName" + "$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" } } }, @@ -769,7 +937,7 @@ expression: generated_schema_json "$ref": "#/components/schemas/OperatorKind" }, "argumentType": { - "$ref": "#/components/schemas/ScalarTypeName" + "$ref": "#/components/schemas/ScalarType" }, "isInfix": { "default": true, @@ -786,6 +954,13 @@ expression: generated_schema_json "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": [ @@ -954,181 +1129,6 @@ expression: generated_schema_json } ] }, - "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", - "schemaName", - "typeName" - ], - "properties": { - "typeName": { - "type": "string" - }, - "schemaName": { - "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": [ - "fieldName", - "type" - ], - "properties": { - "fieldName": { - "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 - } - } - }, "IntrospectionOptions": { "description": "Options which only influence how the configuration is updated.", "type": "object", @@ -1163,7 +1163,9 @@ expression: generated_schema_json "default": [ "public", "pg_catalog", - "tiger" + "tiger", + "auth", + "pgsodium" ], "type": "array", "items": { diff --git a/crates/tests/tests-common/Cargo.toml b/crates/tests/tests-common/Cargo.toml index 44199a7a9..8fc7ab874 100644 --- a/crates/tests/tests-common/Cargo.toml +++ b/crates/tests/tests-common/Cargo.toml @@ -34,4 +34,3 @@ tokio = { version = "1.37.0", features = ["full"] } tokio-postgres = "0.7.10" tracing = "0.1.40" uuid = {version = "1.8.0", features = [ "v4", "fast-rng", "macro-diagnostics" ]} -copy_dir = "0.1.3" 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 index 2961b23d8..cebbb3009 100644 --- a/crates/tests/tests-common/src/common_tests/configuration_v3_tests.rs +++ b/crates/tests/tests-common/src/common_tests/configuration_v3_tests.rs @@ -75,11 +75,7 @@ async fn read_configuration( let contents = fs::read_to_string(absolute_configuration_directory.join("configuration.json")).await?; - let mut multi_version: serde_json::Value = serde_json::from_str(&contents)?; - - // We assume the stored NDC metadata file to be in the newest version, so to be able to make - // assertions on its serialization behavior we remove the version discriminator field. - multi_version.as_object_mut().unwrap().remove("version"); + let multi_version: serde_json::Value = serde_json::from_str(&contents)?; Ok(multi_version) } From 47372773610bc013ee3caec3c1a2d25ac214a9a8 Mon Sep 17 00:00:00 2001 From: Philip Lykke Carlsen Date: Fri, 3 May 2024 15:54:11 +0200 Subject: [PATCH 09/18] fix tests --- crates/configuration/src/version3/mod.rs | 23 +++++++++++++++++++++++ crates/configuration/src/version4/mod.rs | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/crates/configuration/src/version3/mod.rs b/crates/configuration/src/version3/mod.rs index ea2934a6f..c612c0ae0 100644 --- a/crates/configuration/src/version3/mod.rs +++ b/crates/configuration/src/version3/mod.rs @@ -581,6 +581,29 @@ pub async fn write_parsed_configuration( ) .await?; + // look for native query sql file references and write them to disk. + for native_query_sql in parsed_config.metadata.native_queries.0.values() { + if let metadata::NativeQuerySqlEither::NativeQuerySql( + metadata::NativeQuerySql::FromFile { file, sql }, + ) = &native_query_sql.sql + { + if file.is_absolute() || file.starts_with("..") { + Err( + WriteParsedConfigurationError::WritingOutsideDestinationDir { + dir: out_dir.as_ref().to_owned(), + file: file.clone(), + }, + )?; + }; + + let native_query_file = out_dir.as_ref().to_owned().join(file); + if let Some(native_query_sql_dir) = native_query_file.parent() { + fs::create_dir_all(native_query_sql_dir).await?; + }; + fs::write(native_query_file, String::from(sql.clone())).await?; + }; + } + // create the jsonschema file let configuration_jsonschema_file_path = out_dir .as_ref() diff --git a/crates/configuration/src/version4/mod.rs b/crates/configuration/src/version4/mod.rs index 4fe432e54..cb9837547 100644 --- a/crates/configuration/src/version4/mod.rs +++ b/crates/configuration/src/version4/mod.rs @@ -469,7 +469,7 @@ pub async fn write_parsed_configuration( ) .await?; - // look for native query sql file references and read from disk. + // look for native query sql file references and write them to disk. for native_query_sql in parsed_config.metadata.native_queries.0.values() { if let metadata::NativeQuerySqlEither::NativeQuerySql( metadata::NativeQuerySql::FromFile { file, sql }, From cebde4f2d6e90e454f79a37c781dadacd8dca88e Mon Sep 17 00:00:00 2001 From: Philip Lykke Carlsen Date: Fri, 3 May 2024 17:56:43 +0200 Subject: [PATCH 10/18] fixes after merge --- ...ation_tests__get_configuration_schema.snap | 2073 ----------------- ..._openapi__up_to_date_generated_schema.snap | 2037 ---------------- 2 files changed, 4110 deletions(-) diff --git a/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__configuration_tests__get_configuration_schema.snap b/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__configuration_tests__get_configuration_schema.snap index 9bae4b494..4f0b82c75 100644 --- a/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__configuration_tests__get_configuration_schema.snap +++ b/crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__configuration_tests__get_configuration_schema.snap @@ -1490,2079 +1490,6 @@ expression: schema "v1", "veryExperimentalWip" ] -<<<<<<< HEAD -||||||| 61908626 - }, - "DatabaseConnectionSettings2": { - "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, - "connectionLifetime": 600 - }, - "allOf": [ - { - "$ref": "#/definitions/PoolSettings" - } - ] - }, - "isolationLevel": { - "description": "Query isolation level.", - "default": "ReadCommitted", - "allOf": [ - { - "$ref": "#/definitions/IsolationLevel" - } - ] - } - } - }, - "Metadata2": { - "description": "Metadata information.", - "type": "object", - "properties": { - "tables": { - "default": {}, - "allOf": [ - { - "$ref": "#/definitions/TablesInfo2" - } - ] - }, - "scalarTypes": { - "default": {}, - "allOf": [ - { - "$ref": "#/definitions/ScalarTypes" - } - ] - }, - "compositeTypes": { - "default": {}, - "allOf": [ - { - "$ref": "#/definitions/CompositeTypes2" - } - ] - }, - "nativeQueries": { - "default": {}, - "allOf": [ - { - "$ref": "#/definitions/NativeQueries2" - } - ] - } - } - }, - "TablesInfo2": { - "description": "Mapping from a \"table\" name to its information.", - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/TableInfo2" - } - }, - "TableInfo2": { - "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/ColumnInfo2" - } - }, - "uniquenessConstraints": { - "default": {}, - "allOf": [ - { - "$ref": "#/definitions/UniquenessConstraints2" - } - ] - }, - "foreignRelations": { - "default": {}, - "allOf": [ - { - "$ref": "#/definitions/ForeignRelations2" - } - ] - }, - "description": { - "default": null, - "type": [ - "string", - "null" - ] - } - } - }, - "ColumnInfo2": { - "description": "Information about a database column.", - "type": "object", - "required": [ - "name", - "type" - ], - "properties": { - "name": { - "type": "string" - }, - "type": { - "$ref": "#/definitions/Type2" - }, - "nullable": { - "default": "nullable", - "allOf": [ - { - "$ref": "#/definitions/Nullable2" - } - ] - }, - "hasDefault": { - "$ref": "#/definitions/HasDefault2" - }, - "isIdentity": { - "$ref": "#/definitions/IsIdentity2" - }, - "isGenerated": { - "$ref": "#/definitions/IsGenerated2" - }, - "description": { - "default": null, - "type": [ - "string", - "null" - ] - } - } - }, - "Type2": { - "description": "The type of values that a column, field, or argument may take.", - "oneOf": [ - { - "type": "object", - "required": [ - "scalarType" - ], - "properties": { - "scalarType": { - "$ref": "#/definitions/ScalarTypeName" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "compositeType" - ], - "properties": { - "compositeType": { - "$ref": "#/definitions/CompositeTypeName" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "arrayType" - ], - "properties": { - "arrayType": { - "$ref": "#/definitions/Type2" - } - }, - "additionalProperties": false - } - ] - }, - "ScalarTypeName": { - "description": "A name of a Scalar Type, as it appears in the NDC scheme.", - "type": "string" - }, - "CompositeTypeName": { - "description": "The name of a Composite Type, as it appears in the NDC schema", - "type": "string" - }, - "Nullable2": { - "description": "Can this column contain null values", - "type": "string", - "enum": [ - "nullable", - "nonNullable" - ] - }, - "HasDefault2": { - "description": "Does this column have a default value.", - "type": "string", - "enum": [ - "noDefault", - "hasDefault" - ] - }, - "IsIdentity2": { - "description": "Is this column an identity column.", - "type": "string", - "enum": [ - "notIdentity", - "identityByDefault", - "identityAlways" - ] - }, - "IsGenerated2": { - "description": "Is this column a generated column.", - "type": "string", - "enum": [ - "notGenerated", - "stored" - ] - }, - "UniquenessConstraints2": { - "description": "A mapping from the name of a unique constraint to its value.", - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/UniquenessConstraint2" - } - }, - "UniquenessConstraint2": { - "description": "The set of columns that make up a uniqueness constraint.", - "type": "array", - "items": { - "type": "string" - }, - "uniqueItems": true - }, - "ForeignRelations2": { - "description": "A mapping from the name of a foreign key constraint to its value.", - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/ForeignRelation2" - } - }, - "ForeignRelation2": { - "description": "A foreign key constraint.", - "type": "object", - "required": [ - "columnMapping", - "foreignTable" - ], - "properties": { - "foreignSchema": { - "type": [ - "string", - "null" - ] - }, - "foreignTable": { - "type": "string" - }, - "columnMapping": { - "type": "object", - "additionalProperties": { - "type": "string" - } - } - } - }, - "ScalarTypes": { - "description": "Map of all known/occurring scalar types.", - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/ScalarType2" - } - }, - "ScalarType2": { - "description": "Information about a scalar type. A scalar type is completely characterized by its name and the operations you can do on it.", - "type": "object", - "required": [ - "aggregateFunctions", - "comparisonOperators", - "schemaName", - "typeName" - ], - "properties": { - "typeName": { - "type": "string" - }, - "schemaName": { - "type": "string" - }, - "description": { - "type": [ - "string", - "null" - ] - }, - "aggregateFunctions": { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/AggregateFunction2" - } - }, - "comparisonOperators": { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/ComparisonOperator2" - } - }, - "typeRepresentation": { - "anyOf": [ - { - "$ref": "#/definitions/TypeRepresentation2" - }, - { - "type": "null" - } - ] - } - } - }, - "AggregateFunction2": { - "type": "object", - "required": [ - "returnType" - ], - "properties": { - "returnType": { - "$ref": "#/definitions/ScalarTypeName" - } - } - }, - "ComparisonOperator2": { - "description": "Represents a postgres binary comparison operator", - "type": "object", - "required": [ - "argumentType", - "operatorKind", - "operatorName" - ], - "properties": { - "operatorName": { - "type": "string" - }, - "operatorKind": { - "$ref": "#/definitions/OperatorKind2" - }, - "argumentType": { - "$ref": "#/definitions/ScalarTypeName" - }, - "isInfix": { - "default": true, - "type": "boolean" - } - } - }, - "OperatorKind2": { - "description": "Is it a built-in operator, or a custom operator.", - "type": "string", - "enum": [ - "equal", - "in", - "custom" - ] - }, - "TypeRepresentation2": { - "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 - } - ] - }, - "CompositeTypes2": { - "description": "Map of all known composite types.", - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/CompositeType2" - } - }, - "CompositeType2": { - "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", - "schemaName", - "typeName" - ], - "properties": { - "typeName": { - "type": "string" - }, - "schemaName": { - "type": "string" - }, - "fields": { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/FieldInfo2" - } - }, - "description": { - "default": null, - "type": [ - "string", - "null" - ] - } - } - }, - "FieldInfo2": { - "description": "Information about a composite type field.", - "type": "object", - "required": [ - "fieldName", - "type" - ], - "properties": { - "fieldName": { - "type": "string" - }, - "type": { - "$ref": "#/definitions/Type2" - }, - "description": { - "default": null, - "type": [ - "string", - "null" - ] - } - } - }, - "NativeQueries2": { - "description": "Metadata information of native queries.", - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/NativeQueryInfo2" - } - }, - "NativeQueryInfo2": { - "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/ReadOnlyColumnInfo2" - } - }, - "arguments": { - "description": "Names and types of arguments that can be passed to this Native Query", - "default": {}, - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/ReadOnlyColumnInfo2" - } - }, - "description": { - "default": null, - "type": [ - "string", - "null" - ] - }, - "isProcedure": { - "description": "True if this native query mutates the database", - "type": "boolean" - } - } - }, - "ReadOnlyColumnInfo2": { - "description": "Information about a native query column.", - "type": "object", - "required": [ - "name", - "type" - ], - "properties": { - "name": { - "type": "string" - }, - "type": { - "$ref": "#/definitions/Type2" - }, - "nullable": { - "default": "nullable", - "allOf": [ - { - "$ref": "#/definitions/Nullable2" - } - ] - }, - "description": { - "default": null, - "type": [ - "string", - "null" - ] - } - } - }, - "IntrospectionOptions2": { - "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" - ], - "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/ComparisonOperatorMapping2" - } - }, - "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" - } - } - } - }, - "ComparisonOperatorMapping2": { - "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/OperatorKind2" - } - ] - } - } - }, - "MutationsVersion2": { - "description": "Which version of the generated mutations will be included in the schema", - "type": "string", - "enum": [ - "v1", - "veryExperimentalWip" - ] -======= - }, - "DatabaseConnectionSettings2": { - "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" - } - ] - } - } - }, - "Metadata2": { - "description": "Metadata information.", - "type": "object", - "properties": { - "tables": { - "default": {}, - "allOf": [ - { - "$ref": "#/definitions/TablesInfo2" - } - ] - }, - "scalarTypes": { - "default": {}, - "allOf": [ - { - "$ref": "#/definitions/ScalarTypes" - } - ] - }, - "compositeTypes": { - "default": {}, - "allOf": [ - { - "$ref": "#/definitions/CompositeTypes2" - } - ] - }, - "nativeQueries": { - "default": {}, - "allOf": [ - { - "$ref": "#/definitions/NativeQueries2" - } - ] - } - } - }, - "TablesInfo2": { - "description": "Mapping from a \"table\" name to its information.", - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/TableInfo2" - } - }, - "TableInfo2": { - "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/ColumnInfo2" - } - }, - "uniquenessConstraints": { - "default": {}, - "allOf": [ - { - "$ref": "#/definitions/UniquenessConstraints2" - } - ] - }, - "foreignRelations": { - "default": {}, - "allOf": [ - { - "$ref": "#/definitions/ForeignRelations2" - } - ] - }, - "description": { - "default": null, - "type": [ - "string", - "null" - ] - } - } - }, - "ColumnInfo2": { - "description": "Information about a database column.", - "type": "object", - "required": [ - "name", - "type" - ], - "properties": { - "name": { - "type": "string" - }, - "type": { - "$ref": "#/definitions/Type2" - }, - "nullable": { - "default": "nullable", - "allOf": [ - { - "$ref": "#/definitions/Nullable2" - } - ] - }, - "hasDefault": { - "$ref": "#/definitions/HasDefault2" - }, - "isIdentity": { - "$ref": "#/definitions/IsIdentity2" - }, - "isGenerated": { - "$ref": "#/definitions/IsGenerated2" - }, - "description": { - "default": null, - "type": [ - "string", - "null" - ] - } - } - }, - "Type2": { - "description": "The type of values that a column, field, or argument may take.", - "oneOf": [ - { - "type": "object", - "required": [ - "scalarType" - ], - "properties": { - "scalarType": { - "$ref": "#/definitions/ScalarTypeName" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "compositeType" - ], - "properties": { - "compositeType": { - "$ref": "#/definitions/CompositeTypeName" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "arrayType" - ], - "properties": { - "arrayType": { - "$ref": "#/definitions/Type2" - } - }, - "additionalProperties": false - } - ] - }, - "ScalarTypeName": { - "description": "A name of a Scalar Type, as it appears in the NDC scheme.", - "type": "string" - }, - "CompositeTypeName": { - "description": "The name of a Composite Type, as it appears in the NDC schema", - "type": "string" - }, - "Nullable2": { - "description": "Can this column contain null values", - "type": "string", - "enum": [ - "nullable", - "nonNullable" - ] - }, - "HasDefault2": { - "description": "Does this column have a default value.", - "type": "string", - "enum": [ - "noDefault", - "hasDefault" - ] - }, - "IsIdentity2": { - "description": "Is this column an identity column.", - "type": "string", - "enum": [ - "notIdentity", - "identityByDefault", - "identityAlways" - ] - }, - "IsGenerated2": { - "description": "Is this column a generated column.", - "type": "string", - "enum": [ - "notGenerated", - "stored" - ] - }, - "UniquenessConstraints2": { - "description": "A mapping from the name of a unique constraint to its value.", - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/UniquenessConstraint2" - } - }, - "UniquenessConstraint2": { - "description": "The set of columns that make up a uniqueness constraint.", - "type": "array", - "items": { - "type": "string" - }, - "uniqueItems": true - }, - "ForeignRelations2": { - "description": "A mapping from the name of a foreign key constraint to its value.", - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/ForeignRelation2" - } - }, - "ForeignRelation2": { - "description": "A foreign key constraint.", - "type": "object", - "required": [ - "columnMapping", - "foreignTable" - ], - "properties": { - "foreignSchema": { - "type": [ - "string", - "null" - ] - }, - "foreignTable": { - "type": "string" - }, - "columnMapping": { - "type": "object", - "additionalProperties": { - "type": "string" - } - } - } - }, - "ScalarTypes": { - "description": "Map of all known/occurring scalar types.", - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/ScalarType2" - } - }, - "ScalarType2": { - "description": "Information about a scalar type. A scalar type is completely characterized by its name and the operations you can do on it.", - "type": "object", - "required": [ - "aggregateFunctions", - "comparisonOperators", - "schemaName", - "typeName" - ], - "properties": { - "typeName": { - "type": "string" - }, - "schemaName": { - "type": "string" - }, - "description": { - "type": [ - "string", - "null" - ] - }, - "aggregateFunctions": { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/AggregateFunction2" - } - }, - "comparisonOperators": { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/ComparisonOperator2" - } - }, - "typeRepresentation": { - "anyOf": [ - { - "$ref": "#/definitions/TypeRepresentation2" - }, - { - "type": "null" - } - ] - } - } - }, - "AggregateFunction2": { - "type": "object", - "required": [ - "returnType" - ], - "properties": { - "returnType": { - "$ref": "#/definitions/ScalarTypeName" - } - } - }, - "ComparisonOperator2": { - "description": "Represents a postgres binary comparison operator", - "type": "object", - "required": [ - "argumentType", - "operatorKind", - "operatorName" - ], - "properties": { - "operatorName": { - "type": "string" - }, - "operatorKind": { - "$ref": "#/definitions/OperatorKind2" - }, - "argumentType": { - "$ref": "#/definitions/ScalarTypeName" - }, - "isInfix": { - "default": true, - "type": "boolean" - } - } - }, - "OperatorKind2": { - "description": "Is it a built-in operator, or a custom operator.", - "type": "string", - "enum": [ - "equal", - "in", - "custom" - ] - }, - "TypeRepresentation2": { - "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 - } - ] - }, - "CompositeTypes2": { - "description": "Map of all known composite types.", - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/CompositeType2" - } - }, - "CompositeType2": { - "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", - "schemaName", - "typeName" - ], - "properties": { - "typeName": { - "type": "string" - }, - "schemaName": { - "type": "string" - }, - "fields": { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/FieldInfo2" - } - }, - "description": { - "default": null, - "type": [ - "string", - "null" - ] - } - } - }, - "FieldInfo2": { - "description": "Information about a composite type field.", - "type": "object", - "required": [ - "fieldName", - "type" - ], - "properties": { - "fieldName": { - "type": "string" - }, - "type": { - "$ref": "#/definitions/Type2" - }, - "description": { - "default": null, - "type": [ - "string", - "null" - ] - } - } - }, - "NativeQueries2": { - "description": "Metadata information of native queries.", - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/NativeQueryInfo2" - } - }, - "NativeQueryInfo2": { - "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/ReadOnlyColumnInfo2" - } - }, - "arguments": { - "description": "Names and types of arguments that can be passed to this Native Query", - "default": {}, - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/ReadOnlyColumnInfo2" - } - }, - "description": { - "default": null, - "type": [ - "string", - "null" - ] - }, - "isProcedure": { - "description": "True if this native query mutates the database", - "type": "boolean" - } - } - }, - "ReadOnlyColumnInfo2": { - "description": "Information about a native query column.", - "type": "object", - "required": [ - "name", - "type" - ], - "properties": { - "name": { - "type": "string" - }, - "type": { - "$ref": "#/definitions/Type2" - }, - "nullable": { - "default": "nullable", - "allOf": [ - { - "$ref": "#/definitions/Nullable2" - } - ] - }, - "description": { - "default": null, - "type": [ - "string", - "null" - ] - } - } - }, - "IntrospectionOptions2": { - "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" - ], - "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/ComparisonOperatorMapping2" - } - }, - "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" - } - } - } - }, - "ComparisonOperatorMapping2": { - "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/OperatorKind2" - } - ] - } - } - }, - "MutationsVersion2": { - "description": "Which version of the generated mutations will be included in the schema", - "type": "string", - "enum": [ - "v1", - "veryExperimentalWip" - ] ->>>>>>> origin/main } } } 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 index 19e7489db..1ec7d954e 100644 --- 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 @@ -1466,2043 +1466,6 @@ expression: generated_schema_json "v1", "veryExperimentalWip" ] -<<<<<<< HEAD -||||||| 61908626 - }, - "DatabaseConnectionSettings2": { - "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, - "connectionLifetime": 600 - }, - "allOf": [ - { - "$ref": "#/components/schemas/PoolSettings" - } - ] - }, - "isolationLevel": { - "description": "Query isolation level.", - "default": "ReadCommitted", - "allOf": [ - { - "$ref": "#/components/schemas/IsolationLevel" - } - ] - } - } - }, - "Metadata2": { - "description": "Metadata information.", - "type": "object", - "properties": { - "tables": { - "default": {}, - "allOf": [ - { - "$ref": "#/components/schemas/TablesInfo2" - } - ] - }, - "scalarTypes": { - "default": {}, - "allOf": [ - { - "$ref": "#/components/schemas/ScalarTypes" - } - ] - }, - "compositeTypes": { - "default": {}, - "allOf": [ - { - "$ref": "#/components/schemas/CompositeTypes2" - } - ] - }, - "nativeQueries": { - "default": {}, - "allOf": [ - { - "$ref": "#/components/schemas/NativeQueries2" - } - ] - } - } - }, - "TablesInfo2": { - "description": "Mapping from a \"table\" name to its information.", - "type": "object", - "additionalProperties": { - "$ref": "#/components/schemas/TableInfo2" - } - }, - "TableInfo2": { - "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/ColumnInfo2" - } - }, - "uniquenessConstraints": { - "default": {}, - "allOf": [ - { - "$ref": "#/components/schemas/UniquenessConstraints2" - } - ] - }, - "foreignRelations": { - "default": {}, - "allOf": [ - { - "$ref": "#/components/schemas/ForeignRelations2" - } - ] - }, - "description": { - "default": null, - "type": "string", - "nullable": true - } - } - }, - "ColumnInfo2": { - "description": "Information about a database column.", - "type": "object", - "required": [ - "name", - "type" - ], - "properties": { - "name": { - "type": "string" - }, - "type": { - "$ref": "#/components/schemas/Type2" - }, - "nullable": { - "default": "nullable", - "allOf": [ - { - "$ref": "#/components/schemas/Nullable2" - } - ] - }, - "hasDefault": { - "$ref": "#/components/schemas/HasDefault2" - }, - "isIdentity": { - "$ref": "#/components/schemas/IsIdentity2" - }, - "isGenerated": { - "$ref": "#/components/schemas/IsGenerated2" - }, - "description": { - "default": null, - "type": "string", - "nullable": true - } - } - }, - "Type2": { - "description": "The type of values that a column, field, or argument may take.", - "oneOf": [ - { - "type": "object", - "required": [ - "scalarType" - ], - "properties": { - "scalarType": { - "$ref": "#/components/schemas/ScalarTypeName" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "compositeType" - ], - "properties": { - "compositeType": { - "$ref": "#/components/schemas/CompositeTypeName" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "arrayType" - ], - "properties": { - "arrayType": { - "$ref": "#/components/schemas/Type2" - } - }, - "additionalProperties": false - } - ] - }, - "ScalarTypeName": { - "description": "A name of a Scalar Type, as it appears in the NDC scheme.", - "type": "string" - }, - "CompositeTypeName": { - "description": "The name of a Composite Type, as it appears in the NDC schema", - "type": "string" - }, - "Nullable2": { - "description": "Can this column contain null values", - "type": "string", - "enum": [ - "nullable", - "nonNullable" - ] - }, - "HasDefault2": { - "description": "Does this column have a default value.", - "type": "string", - "enum": [ - "noDefault", - "hasDefault" - ] - }, - "IsIdentity2": { - "description": "Is this column an identity column.", - "type": "string", - "enum": [ - "notIdentity", - "identityByDefault", - "identityAlways" - ] - }, - "IsGenerated2": { - "description": "Is this column a generated column.", - "type": "string", - "enum": [ - "notGenerated", - "stored" - ] - }, - "UniquenessConstraints2": { - "description": "A mapping from the name of a unique constraint to its value.", - "type": "object", - "additionalProperties": { - "$ref": "#/components/schemas/UniquenessConstraint2" - } - }, - "UniquenessConstraint2": { - "description": "The set of columns that make up a uniqueness constraint.", - "type": "array", - "items": { - "type": "string" - }, - "uniqueItems": true - }, - "ForeignRelations2": { - "description": "A mapping from the name of a foreign key constraint to its value.", - "type": "object", - "additionalProperties": { - "$ref": "#/components/schemas/ForeignRelation2" - } - }, - "ForeignRelation2": { - "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" - } - } - } - }, - "ScalarTypes": { - "description": "Map of all known/occurring scalar types.", - "type": "object", - "additionalProperties": { - "$ref": "#/components/schemas/ScalarType2" - } - }, - "ScalarType2": { - "description": "Information about a scalar type. A scalar type is completely characterized by its name and the operations you can do on it.", - "type": "object", - "required": [ - "aggregateFunctions", - "comparisonOperators", - "schemaName", - "typeName" - ], - "properties": { - "typeName": { - "type": "string" - }, - "schemaName": { - "type": "string" - }, - "description": { - "type": "string", - "nullable": true - }, - "aggregateFunctions": { - "type": "object", - "additionalProperties": { - "$ref": "#/components/schemas/AggregateFunction2" - } - }, - "comparisonOperators": { - "type": "object", - "additionalProperties": { - "$ref": "#/components/schemas/ComparisonOperator2" - } - }, - "typeRepresentation": { - "allOf": [ - { - "$ref": "#/components/schemas/TypeRepresentation2" - } - ], - "nullable": true - } - } - }, - "AggregateFunction2": { - "type": "object", - "required": [ - "returnType" - ], - "properties": { - "returnType": { - "$ref": "#/components/schemas/ScalarTypeName" - } - } - }, - "ComparisonOperator2": { - "description": "Represents a postgres binary comparison operator", - "type": "object", - "required": [ - "argumentType", - "operatorKind", - "operatorName" - ], - "properties": { - "operatorName": { - "type": "string" - }, - "operatorKind": { - "$ref": "#/components/schemas/OperatorKind2" - }, - "argumentType": { - "$ref": "#/components/schemas/ScalarTypeName" - }, - "isInfix": { - "default": true, - "type": "boolean" - } - } - }, - "OperatorKind2": { - "description": "Is it a built-in operator, or a custom operator.", - "type": "string", - "enum": [ - "equal", - "in", - "custom" - ] - }, - "TypeRepresentation2": { - "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 - } - ] - }, - "CompositeTypes2": { - "description": "Map of all known composite types.", - "type": "object", - "additionalProperties": { - "$ref": "#/components/schemas/CompositeType2" - } - }, - "CompositeType2": { - "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", - "schemaName", - "typeName" - ], - "properties": { - "typeName": { - "type": "string" - }, - "schemaName": { - "type": "string" - }, - "fields": { - "type": "object", - "additionalProperties": { - "$ref": "#/components/schemas/FieldInfo2" - } - }, - "description": { - "default": null, - "type": "string", - "nullable": true - } - } - }, - "FieldInfo2": { - "description": "Information about a composite type field.", - "type": "object", - "required": [ - "fieldName", - "type" - ], - "properties": { - "fieldName": { - "type": "string" - }, - "type": { - "$ref": "#/components/schemas/Type2" - }, - "description": { - "default": null, - "type": "string", - "nullable": true - } - } - }, - "NativeQueries2": { - "description": "Metadata information of native queries.", - "type": "object", - "additionalProperties": { - "$ref": "#/components/schemas/NativeQueryInfo2" - } - }, - "NativeQueryInfo2": { - "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/ReadOnlyColumnInfo2" - } - }, - "arguments": { - "description": "Names and types of arguments that can be passed to this Native Query", - "default": {}, - "type": "object", - "additionalProperties": { - "$ref": "#/components/schemas/ReadOnlyColumnInfo2" - } - }, - "description": { - "default": null, - "type": "string", - "nullable": true - }, - "isProcedure": { - "description": "True if this native query mutates the database", - "type": "boolean" - } - } - }, - "ReadOnlyColumnInfo2": { - "description": "Information about a native query column.", - "type": "object", - "required": [ - "name", - "type" - ], - "properties": { - "name": { - "type": "string" - }, - "type": { - "$ref": "#/components/schemas/Type2" - }, - "nullable": { - "default": "nullable", - "allOf": [ - { - "$ref": "#/components/schemas/Nullable2" - } - ] - }, - "description": { - "default": null, - "type": "string", - "nullable": true - } - } - }, - "IntrospectionOptions2": { - "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" - ], - "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/ComparisonOperatorMapping2" - } - }, - "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" - } - } - } - }, - "ComparisonOperatorMapping2": { - "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/OperatorKind2" - } - ] - } - } - }, - "MutationsVersion2": { - "description": "Which version of the generated mutations will be included in the schema", - "type": "string", - "enum": [ - "v1", - "veryExperimentalWip" - ] -======= - }, - "DatabaseConnectionSettings2": { - "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" - } - ] - } - } - }, - "Metadata2": { - "description": "Metadata information.", - "type": "object", - "properties": { - "tables": { - "default": {}, - "allOf": [ - { - "$ref": "#/components/schemas/TablesInfo2" - } - ] - }, - "scalarTypes": { - "default": {}, - "allOf": [ - { - "$ref": "#/components/schemas/ScalarTypes" - } - ] - }, - "compositeTypes": { - "default": {}, - "allOf": [ - { - "$ref": "#/components/schemas/CompositeTypes2" - } - ] - }, - "nativeQueries": { - "default": {}, - "allOf": [ - { - "$ref": "#/components/schemas/NativeQueries2" - } - ] - } - } - }, - "TablesInfo2": { - "description": "Mapping from a \"table\" name to its information.", - "type": "object", - "additionalProperties": { - "$ref": "#/components/schemas/TableInfo2" - } - }, - "TableInfo2": { - "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/ColumnInfo2" - } - }, - "uniquenessConstraints": { - "default": {}, - "allOf": [ - { - "$ref": "#/components/schemas/UniquenessConstraints2" - } - ] - }, - "foreignRelations": { - "default": {}, - "allOf": [ - { - "$ref": "#/components/schemas/ForeignRelations2" - } - ] - }, - "description": { - "default": null, - "type": "string", - "nullable": true - } - } - }, - "ColumnInfo2": { - "description": "Information about a database column.", - "type": "object", - "required": [ - "name", - "type" - ], - "properties": { - "name": { - "type": "string" - }, - "type": { - "$ref": "#/components/schemas/Type2" - }, - "nullable": { - "default": "nullable", - "allOf": [ - { - "$ref": "#/components/schemas/Nullable2" - } - ] - }, - "hasDefault": { - "$ref": "#/components/schemas/HasDefault2" - }, - "isIdentity": { - "$ref": "#/components/schemas/IsIdentity2" - }, - "isGenerated": { - "$ref": "#/components/schemas/IsGenerated2" - }, - "description": { - "default": null, - "type": "string", - "nullable": true - } - } - }, - "Type2": { - "description": "The type of values that a column, field, or argument may take.", - "oneOf": [ - { - "type": "object", - "required": [ - "scalarType" - ], - "properties": { - "scalarType": { - "$ref": "#/components/schemas/ScalarTypeName" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "compositeType" - ], - "properties": { - "compositeType": { - "$ref": "#/components/schemas/CompositeTypeName" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "arrayType" - ], - "properties": { - "arrayType": { - "$ref": "#/components/schemas/Type2" - } - }, - "additionalProperties": false - } - ] - }, - "ScalarTypeName": { - "description": "A name of a Scalar Type, as it appears in the NDC scheme.", - "type": "string" - }, - "CompositeTypeName": { - "description": "The name of a Composite Type, as it appears in the NDC schema", - "type": "string" - }, - "Nullable2": { - "description": "Can this column contain null values", - "type": "string", - "enum": [ - "nullable", - "nonNullable" - ] - }, - "HasDefault2": { - "description": "Does this column have a default value.", - "type": "string", - "enum": [ - "noDefault", - "hasDefault" - ] - }, - "IsIdentity2": { - "description": "Is this column an identity column.", - "type": "string", - "enum": [ - "notIdentity", - "identityByDefault", - "identityAlways" - ] - }, - "IsGenerated2": { - "description": "Is this column a generated column.", - "type": "string", - "enum": [ - "notGenerated", - "stored" - ] - }, - "UniquenessConstraints2": { - "description": "A mapping from the name of a unique constraint to its value.", - "type": "object", - "additionalProperties": { - "$ref": "#/components/schemas/UniquenessConstraint2" - } - }, - "UniquenessConstraint2": { - "description": "The set of columns that make up a uniqueness constraint.", - "type": "array", - "items": { - "type": "string" - }, - "uniqueItems": true - }, - "ForeignRelations2": { - "description": "A mapping from the name of a foreign key constraint to its value.", - "type": "object", - "additionalProperties": { - "$ref": "#/components/schemas/ForeignRelation2" - } - }, - "ForeignRelation2": { - "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" - } - } - } - }, - "ScalarTypes": { - "description": "Map of all known/occurring scalar types.", - "type": "object", - "additionalProperties": { - "$ref": "#/components/schemas/ScalarType2" - } - }, - "ScalarType2": { - "description": "Information about a scalar type. A scalar type is completely characterized by its name and the operations you can do on it.", - "type": "object", - "required": [ - "aggregateFunctions", - "comparisonOperators", - "schemaName", - "typeName" - ], - "properties": { - "typeName": { - "type": "string" - }, - "schemaName": { - "type": "string" - }, - "description": { - "type": "string", - "nullable": true - }, - "aggregateFunctions": { - "type": "object", - "additionalProperties": { - "$ref": "#/components/schemas/AggregateFunction2" - } - }, - "comparisonOperators": { - "type": "object", - "additionalProperties": { - "$ref": "#/components/schemas/ComparisonOperator2" - } - }, - "typeRepresentation": { - "allOf": [ - { - "$ref": "#/components/schemas/TypeRepresentation2" - } - ], - "nullable": true - } - } - }, - "AggregateFunction2": { - "type": "object", - "required": [ - "returnType" - ], - "properties": { - "returnType": { - "$ref": "#/components/schemas/ScalarTypeName" - } - } - }, - "ComparisonOperator2": { - "description": "Represents a postgres binary comparison operator", - "type": "object", - "required": [ - "argumentType", - "operatorKind", - "operatorName" - ], - "properties": { - "operatorName": { - "type": "string" - }, - "operatorKind": { - "$ref": "#/components/schemas/OperatorKind2" - }, - "argumentType": { - "$ref": "#/components/schemas/ScalarTypeName" - }, - "isInfix": { - "default": true, - "type": "boolean" - } - } - }, - "OperatorKind2": { - "description": "Is it a built-in operator, or a custom operator.", - "type": "string", - "enum": [ - "equal", - "in", - "custom" - ] - }, - "TypeRepresentation2": { - "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 - } - ] - }, - "CompositeTypes2": { - "description": "Map of all known composite types.", - "type": "object", - "additionalProperties": { - "$ref": "#/components/schemas/CompositeType2" - } - }, - "CompositeType2": { - "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", - "schemaName", - "typeName" - ], - "properties": { - "typeName": { - "type": "string" - }, - "schemaName": { - "type": "string" - }, - "fields": { - "type": "object", - "additionalProperties": { - "$ref": "#/components/schemas/FieldInfo2" - } - }, - "description": { - "default": null, - "type": "string", - "nullable": true - } - } - }, - "FieldInfo2": { - "description": "Information about a composite type field.", - "type": "object", - "required": [ - "fieldName", - "type" - ], - "properties": { - "fieldName": { - "type": "string" - }, - "type": { - "$ref": "#/components/schemas/Type2" - }, - "description": { - "default": null, - "type": "string", - "nullable": true - } - } - }, - "NativeQueries2": { - "description": "Metadata information of native queries.", - "type": "object", - "additionalProperties": { - "$ref": "#/components/schemas/NativeQueryInfo2" - } - }, - "NativeQueryInfo2": { - "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/ReadOnlyColumnInfo2" - } - }, - "arguments": { - "description": "Names and types of arguments that can be passed to this Native Query", - "default": {}, - "type": "object", - "additionalProperties": { - "$ref": "#/components/schemas/ReadOnlyColumnInfo2" - } - }, - "description": { - "default": null, - "type": "string", - "nullable": true - }, - "isProcedure": { - "description": "True if this native query mutates the database", - "type": "boolean" - } - } - }, - "ReadOnlyColumnInfo2": { - "description": "Information about a native query column.", - "type": "object", - "required": [ - "name", - "type" - ], - "properties": { - "name": { - "type": "string" - }, - "type": { - "$ref": "#/components/schemas/Type2" - }, - "nullable": { - "default": "nullable", - "allOf": [ - { - "$ref": "#/components/schemas/Nullable2" - } - ] - }, - "description": { - "default": null, - "type": "string", - "nullable": true - } - } - }, - "IntrospectionOptions2": { - "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" - ], - "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/ComparisonOperatorMapping2" - } - }, - "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" - } - } - } - }, - "ComparisonOperatorMapping2": { - "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/OperatorKind2" - } - ] - } - } - }, - "MutationsVersion2": { - "description": "Which version of the generated mutations will be included in the schema", - "type": "string", - "enum": [ - "v1", - "veryExperimentalWip" - ] ->>>>>>> origin/main } } } From 9a226131cb7f5eb30bbc96b67681ac25c1304a78 Mon Sep 17 00:00:00 2001 From: Philip Lykke Carlsen Date: Tue, 7 May 2024 12:02:12 +0200 Subject: [PATCH 11/18] Rename tables.json -> configuration.json --- .../aggregate_count_albums/{tables.json => configuration.json} | 0 .../aggregate_distinct_albums/{tables.json => configuration.json} | 0 .../aggregate_function_albums/{tables.json => configuration.json} | 0 .../dup_array_relationship/{tables.json => configuration.json} | 0 .../mutations/simple/{tables.json => configuration.json} | 0 .../mutations/v1_insert/{tables.json => configuration.json} | 0 .../select_artist/{tables.json => configuration.json} | 0 .../select_artist_by_id/{tables.json => configuration.json} | 0 .../select_artist_by_name/{tables.json => configuration.json} | 0 .../{tables.json => configuration.json} | 0 .../{tables.json => configuration.json} | 0 .../nested_aggregates/{tables.json => configuration.json} | 0 .../{tables.json => configuration.json} | 0 .../{tables.json => configuration.json} | 0 .../goldenfiles/no_fields/{tables.json => configuration.json} | 0 .../select_array_column/{tables.json => configuration.json} | 0 .../{tables.json => configuration.json} | 0 .../{tables.json => configuration.json} | 0 .../select_array_variable/{tables.json => configuration.json} | 0 .../{tables.json => configuration.json} | 0 .../{tables.json => configuration.json} | 0 .../{tables.json => configuration.json} | 0 .../{tables.json => configuration.json} | 0 .../{tables.json => configuration.json} | 0 .../{tables.json => configuration.json} | 0 .../{tables.json => configuration.json} | 0 .../{tables.json => configuration.json} | 0 .../{tables.json => configuration.json} | 0 .../{tables.json => configuration.json} | 0 .../select_where_in_variable/{tables.json => configuration.json} | 0 .../select_where_not_null/{tables.json => configuration.json} | 0 .../{tables.json => configuration.json} | 0 .../{tables.json => configuration.json} | 0 .../select_where_string/{tables.json => configuration.json} | 0 .../{tables.json => configuration.json} | 0 .../select_with_limit/{tables.json => configuration.json} | 0 .../simple_array_relationship/{tables.json => configuration.json} | 0 .../{tables.json => configuration.json} | 0 .../{tables.json => configuration.json} | 0 .../{tables.json => configuration.json} | 0 .../{tables.json => configuration.json} | 0 .../{tables.json => configuration.json} | 0 .../{tables.json => configuration.json} | 0 .../{tables.json => configuration.json} | 0 .../{tables.json => configuration.json} | 0 .../{tables.json => configuration.json} | 0 .../{tables.json => configuration.json} | 0 .../{tables.json => configuration.json} | 0 .../{tables.json => configuration.json} | 0 49 files changed, 0 insertions(+), 0 deletions(-) rename crates/query-engine/translation/tests/goldenfiles/aggregate_count_albums/{tables.json => configuration.json} (100%) rename crates/query-engine/translation/tests/goldenfiles/aggregate_distinct_albums/{tables.json => configuration.json} (100%) rename crates/query-engine/translation/tests/goldenfiles/aggregate_function_albums/{tables.json => configuration.json} (100%) rename crates/query-engine/translation/tests/goldenfiles/dup_array_relationship/{tables.json => configuration.json} (100%) rename crates/query-engine/translation/tests/goldenfiles/mutations/simple/{tables.json => configuration.json} (100%) rename crates/query-engine/translation/tests/goldenfiles/mutations/v1_insert/{tables.json => configuration.json} (100%) rename crates/query-engine/translation/tests/goldenfiles/native_queries/select_artist/{tables.json => configuration.json} (100%) rename crates/query-engine/translation/tests/goldenfiles/native_queries/select_artist_by_id/{tables.json => configuration.json} (100%) rename crates/query-engine/translation/tests/goldenfiles/native_queries/select_artist_by_name/{tables.json => configuration.json} (100%) rename crates/query-engine/translation/tests/goldenfiles/native_queries/select_artist_with_album_by_title/{tables.json => configuration.json} (100%) rename crates/query-engine/translation/tests/goldenfiles/native_queries/select_artist_with_album_by_title_relationship_arguments/{tables.json => configuration.json} (100%) rename crates/query-engine/translation/tests/goldenfiles/nested_aggregates/{tables.json => configuration.json} (100%) rename crates/query-engine/translation/tests/goldenfiles/nested_array_relationships/{tables.json => configuration.json} (100%) rename crates/query-engine/translation/tests/goldenfiles/nested_recursive_relationship/{tables.json => configuration.json} (100%) rename crates/query-engine/translation/tests/goldenfiles/no_fields/{tables.json => configuration.json} (100%) rename crates/query-engine/translation/tests/goldenfiles/select_array_column/{tables.json => configuration.json} (100%) rename crates/query-engine/translation/tests/goldenfiles/select_array_column_nested_types/{tables.json => configuration.json} (100%) rename crates/query-engine/translation/tests/goldenfiles/select_array_column_reverse/{tables.json => configuration.json} (100%) rename crates/query-engine/translation/tests/goldenfiles/select_array_variable/{tables.json => configuration.json} (100%) rename crates/query-engine/translation/tests/goldenfiles/select_array_variable_nested_types/{tables.json => configuration.json} (100%) rename crates/query-engine/translation/tests/goldenfiles/select_composite_column_complex/{tables.json => configuration.json} (100%) rename crates/query-engine/translation/tests/goldenfiles/select_composite_column_simple/{tables.json => configuration.json} (100%) rename crates/query-engine/translation/tests/goldenfiles/select_composite_variable_complex/{tables.json => configuration.json} (100%) rename crates/query-engine/translation/tests/goldenfiles/select_composite_variable_simple/{tables.json => configuration.json} (100%) rename crates/query-engine/translation/tests/goldenfiles/select_nested_column_complex/{tables.json => configuration.json} (100%) rename crates/query-engine/translation/tests/goldenfiles/select_nested_column_simple/{tables.json => configuration.json} (100%) rename crates/query-engine/translation/tests/goldenfiles/select_track_order_by_artist_id_and_album_title/{tables.json => configuration.json} (100%) rename crates/query-engine/translation/tests/goldenfiles/select_where_album_id_equals_self_nested_object_relationship/{tables.json => configuration.json} (100%) rename crates/query-engine/translation/tests/goldenfiles/select_where_array_relationship/{tables.json => configuration.json} (100%) rename crates/query-engine/translation/tests/goldenfiles/select_where_in_variable/{tables.json => configuration.json} (100%) rename crates/query-engine/translation/tests/goldenfiles/select_where_not_null/{tables.json => configuration.json} (100%) rename crates/query-engine/translation/tests/goldenfiles/select_where_prefix_function/{tables.json => configuration.json} (100%) rename crates/query-engine/translation/tests/goldenfiles/select_where_related_exists/{tables.json => configuration.json} (100%) rename crates/query-engine/translation/tests/goldenfiles/select_where_string/{tables.json => configuration.json} (100%) rename crates/query-engine/translation/tests/goldenfiles/select_where_unrelated_exists/{tables.json => configuration.json} (100%) rename crates/query-engine/translation/tests/goldenfiles/select_with_limit/{tables.json => configuration.json} (100%) rename crates/query-engine/translation/tests/goldenfiles/simple_array_relationship/{tables.json => configuration.json} (100%) rename crates/query-engine/translation/tests/goldenfiles/simple_object_relationship/{tables.json => configuration.json} (100%) rename crates/query-engine/translation/tests/goldenfiles/sorting_by_nested_relationship_column/{tables.json => configuration.json} (100%) rename crates/query-engine/translation/tests/goldenfiles/sorting_by_nested_relationship_column_with_predicate/{tables.json => configuration.json} (100%) rename crates/query-engine/translation/tests/goldenfiles/sorting_by_nested_relationship_count/{tables.json => configuration.json} (100%) rename crates/query-engine/translation/tests/goldenfiles/sorting_by_no_relationship_aggregate/{tables.json => configuration.json} (100%) rename crates/query-engine/translation/tests/goldenfiles/sorting_by_recursive_relationship_column/{tables.json => configuration.json} (100%) rename crates/query-engine/translation/tests/goldenfiles/sorting_by_relationship_column/{tables.json => configuration.json} (100%) rename crates/query-engine/translation/tests/goldenfiles/sorting_by_relationship_count/{tables.json => configuration.json} (100%) rename crates/query-engine/translation/tests/goldenfiles/sorting_by_relationship_count_with_predicate/{tables.json => configuration.json} (100%) rename crates/query-engine/translation/tests/goldenfiles/values/select_types_on_comparisons/{tables.json => configuration.json} (100%) rename crates/query-engine/translation/tests/goldenfiles/values/select_types_on_native_queries/{tables.json => configuration.json} (100%) rename crates/query-engine/translation/tests/goldenfiles/very_nested_recursive_relationship/{tables.json => configuration.json} (100%) diff --git a/crates/query-engine/translation/tests/goldenfiles/aggregate_count_albums/tables.json b/crates/query-engine/translation/tests/goldenfiles/aggregate_count_albums/configuration.json similarity index 100% rename from crates/query-engine/translation/tests/goldenfiles/aggregate_count_albums/tables.json rename to crates/query-engine/translation/tests/goldenfiles/aggregate_count_albums/configuration.json diff --git a/crates/query-engine/translation/tests/goldenfiles/aggregate_distinct_albums/tables.json b/crates/query-engine/translation/tests/goldenfiles/aggregate_distinct_albums/configuration.json similarity index 100% rename from crates/query-engine/translation/tests/goldenfiles/aggregate_distinct_albums/tables.json rename to crates/query-engine/translation/tests/goldenfiles/aggregate_distinct_albums/configuration.json diff --git a/crates/query-engine/translation/tests/goldenfiles/aggregate_function_albums/tables.json b/crates/query-engine/translation/tests/goldenfiles/aggregate_function_albums/configuration.json similarity index 100% rename from crates/query-engine/translation/tests/goldenfiles/aggregate_function_albums/tables.json rename to crates/query-engine/translation/tests/goldenfiles/aggregate_function_albums/configuration.json diff --git a/crates/query-engine/translation/tests/goldenfiles/dup_array_relationship/tables.json b/crates/query-engine/translation/tests/goldenfiles/dup_array_relationship/configuration.json similarity index 100% rename from crates/query-engine/translation/tests/goldenfiles/dup_array_relationship/tables.json rename to crates/query-engine/translation/tests/goldenfiles/dup_array_relationship/configuration.json diff --git a/crates/query-engine/translation/tests/goldenfiles/mutations/simple/tables.json b/crates/query-engine/translation/tests/goldenfiles/mutations/simple/configuration.json similarity index 100% rename from crates/query-engine/translation/tests/goldenfiles/mutations/simple/tables.json rename to crates/query-engine/translation/tests/goldenfiles/mutations/simple/configuration.json diff --git a/crates/query-engine/translation/tests/goldenfiles/mutations/v1_insert/tables.json b/crates/query-engine/translation/tests/goldenfiles/mutations/v1_insert/configuration.json similarity index 100% rename from crates/query-engine/translation/tests/goldenfiles/mutations/v1_insert/tables.json rename to crates/query-engine/translation/tests/goldenfiles/mutations/v1_insert/configuration.json 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/configuration.json similarity index 100% rename from crates/query-engine/translation/tests/goldenfiles/native_queries/select_artist/tables.json rename to crates/query-engine/translation/tests/goldenfiles/native_queries/select_artist/configuration.json 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/configuration.json similarity index 100% rename from crates/query-engine/translation/tests/goldenfiles/native_queries/select_artist_by_id/tables.json rename to crates/query-engine/translation/tests/goldenfiles/native_queries/select_artist_by_id/configuration.json 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/configuration.json similarity index 100% rename from crates/query-engine/translation/tests/goldenfiles/native_queries/select_artist_by_name/tables.json rename to crates/query-engine/translation/tests/goldenfiles/native_queries/select_artist_by_name/configuration.json 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/configuration.json similarity index 100% rename from crates/query-engine/translation/tests/goldenfiles/native_queries/select_artist_with_album_by_title/tables.json rename to crates/query-engine/translation/tests/goldenfiles/native_queries/select_artist_with_album_by_title/configuration.json 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/configuration.json similarity index 100% rename from crates/query-engine/translation/tests/goldenfiles/native_queries/select_artist_with_album_by_title_relationship_arguments/tables.json rename to crates/query-engine/translation/tests/goldenfiles/native_queries/select_artist_with_album_by_title_relationship_arguments/configuration.json diff --git a/crates/query-engine/translation/tests/goldenfiles/nested_aggregates/tables.json b/crates/query-engine/translation/tests/goldenfiles/nested_aggregates/configuration.json similarity index 100% rename from crates/query-engine/translation/tests/goldenfiles/nested_aggregates/tables.json rename to crates/query-engine/translation/tests/goldenfiles/nested_aggregates/configuration.json diff --git a/crates/query-engine/translation/tests/goldenfiles/nested_array_relationships/tables.json b/crates/query-engine/translation/tests/goldenfiles/nested_array_relationships/configuration.json similarity index 100% rename from crates/query-engine/translation/tests/goldenfiles/nested_array_relationships/tables.json rename to crates/query-engine/translation/tests/goldenfiles/nested_array_relationships/configuration.json diff --git a/crates/query-engine/translation/tests/goldenfiles/nested_recursive_relationship/tables.json b/crates/query-engine/translation/tests/goldenfiles/nested_recursive_relationship/configuration.json similarity index 100% rename from crates/query-engine/translation/tests/goldenfiles/nested_recursive_relationship/tables.json rename to crates/query-engine/translation/tests/goldenfiles/nested_recursive_relationship/configuration.json diff --git a/crates/query-engine/translation/tests/goldenfiles/no_fields/tables.json b/crates/query-engine/translation/tests/goldenfiles/no_fields/configuration.json similarity index 100% rename from crates/query-engine/translation/tests/goldenfiles/no_fields/tables.json rename to crates/query-engine/translation/tests/goldenfiles/no_fields/configuration.json diff --git a/crates/query-engine/translation/tests/goldenfiles/select_array_column/tables.json b/crates/query-engine/translation/tests/goldenfiles/select_array_column/configuration.json similarity index 100% rename from crates/query-engine/translation/tests/goldenfiles/select_array_column/tables.json rename to crates/query-engine/translation/tests/goldenfiles/select_array_column/configuration.json 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/configuration.json similarity index 100% rename from crates/query-engine/translation/tests/goldenfiles/select_array_column_nested_types/tables.json rename to crates/query-engine/translation/tests/goldenfiles/select_array_column_nested_types/configuration.json 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/configuration.json similarity index 100% rename from crates/query-engine/translation/tests/goldenfiles/select_array_column_reverse/tables.json rename to crates/query-engine/translation/tests/goldenfiles/select_array_column_reverse/configuration.json diff --git a/crates/query-engine/translation/tests/goldenfiles/select_array_variable/tables.json b/crates/query-engine/translation/tests/goldenfiles/select_array_variable/configuration.json similarity index 100% rename from crates/query-engine/translation/tests/goldenfiles/select_array_variable/tables.json rename to crates/query-engine/translation/tests/goldenfiles/select_array_variable/configuration.json 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/configuration.json similarity index 100% rename from crates/query-engine/translation/tests/goldenfiles/select_array_variable_nested_types/tables.json rename to crates/query-engine/translation/tests/goldenfiles/select_array_variable_nested_types/configuration.json 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/configuration.json similarity index 100% rename from crates/query-engine/translation/tests/goldenfiles/select_composite_column_complex/tables.json rename to crates/query-engine/translation/tests/goldenfiles/select_composite_column_complex/configuration.json 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/configuration.json similarity index 100% rename from crates/query-engine/translation/tests/goldenfiles/select_composite_column_simple/tables.json rename to crates/query-engine/translation/tests/goldenfiles/select_composite_column_simple/configuration.json 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/configuration.json similarity index 100% rename from crates/query-engine/translation/tests/goldenfiles/select_composite_variable_complex/tables.json rename to crates/query-engine/translation/tests/goldenfiles/select_composite_variable_complex/configuration.json 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/configuration.json similarity index 100% rename from crates/query-engine/translation/tests/goldenfiles/select_composite_variable_simple/tables.json rename to crates/query-engine/translation/tests/goldenfiles/select_composite_variable_simple/configuration.json 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/configuration.json similarity index 100% rename from crates/query-engine/translation/tests/goldenfiles/select_nested_column_complex/tables.json rename to crates/query-engine/translation/tests/goldenfiles/select_nested_column_complex/configuration.json 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/configuration.json similarity index 100% rename from crates/query-engine/translation/tests/goldenfiles/select_nested_column_simple/tables.json rename to crates/query-engine/translation/tests/goldenfiles/select_nested_column_simple/configuration.json 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/configuration.json similarity index 100% rename from crates/query-engine/translation/tests/goldenfiles/select_track_order_by_artist_id_and_album_title/tables.json rename to crates/query-engine/translation/tests/goldenfiles/select_track_order_by_artist_id_and_album_title/configuration.json 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/configuration.json similarity index 100% rename from crates/query-engine/translation/tests/goldenfiles/select_where_album_id_equals_self_nested_object_relationship/tables.json rename to crates/query-engine/translation/tests/goldenfiles/select_where_album_id_equals_self_nested_object_relationship/configuration.json 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/configuration.json similarity index 100% rename from crates/query-engine/translation/tests/goldenfiles/select_where_array_relationship/tables.json rename to crates/query-engine/translation/tests/goldenfiles/select_where_array_relationship/configuration.json 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/configuration.json similarity index 100% rename from crates/query-engine/translation/tests/goldenfiles/select_where_in_variable/tables.json rename to crates/query-engine/translation/tests/goldenfiles/select_where_in_variable/configuration.json 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/configuration.json similarity index 100% rename from crates/query-engine/translation/tests/goldenfiles/select_where_not_null/tables.json rename to crates/query-engine/translation/tests/goldenfiles/select_where_not_null/configuration.json 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/configuration.json similarity index 100% rename from crates/query-engine/translation/tests/goldenfiles/select_where_prefix_function/tables.json rename to crates/query-engine/translation/tests/goldenfiles/select_where_prefix_function/configuration.json 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/configuration.json similarity index 100% rename from crates/query-engine/translation/tests/goldenfiles/select_where_related_exists/tables.json rename to crates/query-engine/translation/tests/goldenfiles/select_where_related_exists/configuration.json diff --git a/crates/query-engine/translation/tests/goldenfiles/select_where_string/tables.json b/crates/query-engine/translation/tests/goldenfiles/select_where_string/configuration.json similarity index 100% rename from crates/query-engine/translation/tests/goldenfiles/select_where_string/tables.json rename to crates/query-engine/translation/tests/goldenfiles/select_where_string/configuration.json 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/configuration.json similarity index 100% rename from crates/query-engine/translation/tests/goldenfiles/select_where_unrelated_exists/tables.json rename to crates/query-engine/translation/tests/goldenfiles/select_where_unrelated_exists/configuration.json diff --git a/crates/query-engine/translation/tests/goldenfiles/select_with_limit/tables.json b/crates/query-engine/translation/tests/goldenfiles/select_with_limit/configuration.json similarity index 100% rename from crates/query-engine/translation/tests/goldenfiles/select_with_limit/tables.json rename to crates/query-engine/translation/tests/goldenfiles/select_with_limit/configuration.json diff --git a/crates/query-engine/translation/tests/goldenfiles/simple_array_relationship/tables.json b/crates/query-engine/translation/tests/goldenfiles/simple_array_relationship/configuration.json similarity index 100% rename from crates/query-engine/translation/tests/goldenfiles/simple_array_relationship/tables.json rename to crates/query-engine/translation/tests/goldenfiles/simple_array_relationship/configuration.json diff --git a/crates/query-engine/translation/tests/goldenfiles/simple_object_relationship/tables.json b/crates/query-engine/translation/tests/goldenfiles/simple_object_relationship/configuration.json similarity index 100% rename from crates/query-engine/translation/tests/goldenfiles/simple_object_relationship/tables.json rename to crates/query-engine/translation/tests/goldenfiles/simple_object_relationship/configuration.json 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/configuration.json similarity index 100% rename from crates/query-engine/translation/tests/goldenfiles/sorting_by_nested_relationship_column/tables.json rename to crates/query-engine/translation/tests/goldenfiles/sorting_by_nested_relationship_column/configuration.json 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/configuration.json similarity index 100% rename from crates/query-engine/translation/tests/goldenfiles/sorting_by_nested_relationship_column_with_predicate/tables.json rename to crates/query-engine/translation/tests/goldenfiles/sorting_by_nested_relationship_column_with_predicate/configuration.json 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/configuration.json similarity index 100% rename from crates/query-engine/translation/tests/goldenfiles/sorting_by_nested_relationship_count/tables.json rename to crates/query-engine/translation/tests/goldenfiles/sorting_by_nested_relationship_count/configuration.json 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/configuration.json similarity index 100% rename from crates/query-engine/translation/tests/goldenfiles/sorting_by_no_relationship_aggregate/tables.json rename to crates/query-engine/translation/tests/goldenfiles/sorting_by_no_relationship_aggregate/configuration.json 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/configuration.json similarity index 100% rename from crates/query-engine/translation/tests/goldenfiles/sorting_by_recursive_relationship_column/tables.json rename to crates/query-engine/translation/tests/goldenfiles/sorting_by_recursive_relationship_column/configuration.json 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/configuration.json similarity index 100% rename from crates/query-engine/translation/tests/goldenfiles/sorting_by_relationship_column/tables.json rename to crates/query-engine/translation/tests/goldenfiles/sorting_by_relationship_column/configuration.json 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/configuration.json similarity index 100% rename from crates/query-engine/translation/tests/goldenfiles/sorting_by_relationship_count/tables.json rename to crates/query-engine/translation/tests/goldenfiles/sorting_by_relationship_count/configuration.json 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/configuration.json similarity index 100% rename from crates/query-engine/translation/tests/goldenfiles/sorting_by_relationship_count_with_predicate/tables.json rename to crates/query-engine/translation/tests/goldenfiles/sorting_by_relationship_count_with_predicate/configuration.json 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/configuration.json similarity index 100% rename from crates/query-engine/translation/tests/goldenfiles/values/select_types_on_comparisons/tables.json rename to crates/query-engine/translation/tests/goldenfiles/values/select_types_on_comparisons/configuration.json 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/configuration.json similarity index 100% rename from crates/query-engine/translation/tests/goldenfiles/values/select_types_on_native_queries/tables.json rename to crates/query-engine/translation/tests/goldenfiles/values/select_types_on_native_queries/configuration.json 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/configuration.json similarity index 100% rename from crates/query-engine/translation/tests/goldenfiles/very_nested_recursive_relationship/tables.json rename to crates/query-engine/translation/tests/goldenfiles/very_nested_recursive_relationship/configuration.json From 12069a6daa0c46ee4db83e9141df0e1481f09d01 Mon Sep 17 00:00:00 2001 From: Philip Lykke Carlsen Date: Tue, 7 May 2024 12:54:51 +0200 Subject: [PATCH 12/18] Patching up test configurations --- .../aggregate_count_albums/configuration.json | 45 +-- .../configuration.json | 45 +-- .../configuration.json | 45 +-- .../dup_array_relationship/configuration.json | 77 ++--- .../mutations/simple/configuration.json | 4 + .../mutations/v1_insert/configuration.json | 33 ++- .../select_artist/configuration.json | 4 + .../select_artist_by_id/configuration.json | 4 + .../select_artist_by_name/configuration.json | 4 + .../configuration.json | 4 + .../configuration.json | 4 + .../nested_aggregates/configuration.json | 121 ++++---- .../configuration.json | 121 ++++---- .../configuration.json | 77 ++--- .../goldenfiles/no_fields/configuration.json | 43 +-- .../select_array_column/configuration.json | 8 +- .../configuration.json | 4 + .../configuration.json | 4 + .../select_array_variable/configuration.json | 8 +- .../configuration.json | 4 + .../configuration.json | 4 + .../configuration.json | 4 + .../configuration.json | 4 + .../configuration.json | 4 + .../configuration.json | 4 + .../configuration.json | 4 + .../configuration.json | 121 ++++---- .../configuration.json | 265 +++++++++--------- .../configuration.json | 91 +++--- .../configuration.json | 4 + .../select_where_not_null/configuration.json | 33 ++- .../configuration.json | 31 +- .../configuration.json | 91 +++--- .../select_where_string/configuration.json | 43 +-- .../configuration.json | 91 +++--- .../select_with_limit/configuration.json | 21 +- .../configuration.json | 77 ++--- .../configuration.json | 77 ++--- .../configuration.json | 121 ++++---- .../configuration.json | 139 ++++----- .../configuration.json | 121 ++++---- .../configuration.json | 47 ++-- .../configuration.json | 89 +++--- .../configuration.json | 77 ++--- .../configuration.json | 77 ++--- .../configuration.json | 139 ++++----- .../configuration.json | 83 +++--- .../configuration.json | 4 + .../configuration.json | 77 ++--- 49 files changed, 1389 insertions(+), 1213 deletions(-) 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 index 0bceb228a..3d4963b51 100644 --- a/crates/query-engine/translation/tests/goldenfiles/aggregate_count_albums/configuration.json +++ b/crates/query-engine/translation/tests/goldenfiles/aggregate_count_albums/configuration.json @@ -1,25 +1,28 @@ { - "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" + "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/configuration.json b/crates/query-engine/translation/tests/goldenfiles/aggregate_distinct_albums/configuration.json index 0bceb228a..3d4963b51 100644 --- a/crates/query-engine/translation/tests/goldenfiles/aggregate_distinct_albums/configuration.json +++ b/crates/query-engine/translation/tests/goldenfiles/aggregate_distinct_albums/configuration.json @@ -1,25 +1,28 @@ { - "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" + "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/configuration.json b/crates/query-engine/translation/tests/goldenfiles/aggregate_function_albums/configuration.json index 0bceb228a..3d4963b51 100644 --- a/crates/query-engine/translation/tests/goldenfiles/aggregate_function_albums/configuration.json +++ b/crates/query-engine/translation/tests/goldenfiles/aggregate_function_albums/configuration.json @@ -1,25 +1,28 @@ { - "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" + "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/dup_array_relationship/configuration.json b/crates/query-engine/translation/tests/goldenfiles/dup_array_relationship/configuration.json index 1b79f596e..668c8d63d 100644 --- a/crates/query-engine/translation/tests/goldenfiles/dup_array_relationship/configuration.json +++ b/crates/query-engine/translation/tests/goldenfiles/dup_array_relationship/configuration.json @@ -1,43 +1,46 @@ { - "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" + "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" + }, + "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 index 12cab1982..fe9b48bfc 100644 --- a/crates/query-engine/translation/tests/goldenfiles/mutations/simple/configuration.json +++ b/crates/query-engine/translation/tests/goldenfiles/mutations/simple/configuration.json @@ -25,5 +25,9 @@ } } } + }, + "version": "3", + "metadata": { + "tables": null } } 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 index 743abbac6..ff2ad5fb6 100644 --- a/crates/query-engine/translation/tests/goldenfiles/mutations/v1_insert/configuration.json +++ b/crates/query-engine/translation/tests/goldenfiles/mutations/v1_insert/configuration.json @@ -1,19 +1,22 @@ { - "tables": { - "Artist": { - "schemaName": "public", - "tableName": "Artist", - "columns": { - "id": { - "name": "ArtistId", - "type": { - "scalarType": "int4" - } - }, - "name": { - "name": "Name", - "type": { - "scalarType": "varchar" + "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/native_queries/select_artist/configuration.json b/crates/query-engine/translation/tests/goldenfiles/native_queries/select_artist/configuration.json index 91820870b..1df5e0756 100644 --- 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 @@ -17,5 +17,9 @@ } } } + }, + "version": "3", + "metadata": { + "tables": null } } 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 index bef3b6e7b..42b3c54f9 100644 --- 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 @@ -25,5 +25,9 @@ } } } + }, + "version": "3", + "metadata": { + "tables": null } } 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 index caac0aaf3..9b974fbfc 100644 --- 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 @@ -25,5 +25,9 @@ } } } + }, + "version": "3", + "metadata": { + "tables": null } } 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 index 7e0f88b1b..f08d174e3 100644 --- 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 @@ -49,5 +49,9 @@ } } } + }, + "version": "3", + "metadata": { + "tables": null } } 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 index 9c5915d89..3398871bd 100644 --- 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 @@ -55,5 +55,9 @@ } } } + }, + "version": "3", + "metadata": { + "tables": null } } diff --git a/crates/query-engine/translation/tests/goldenfiles/nested_aggregates/configuration.json b/crates/query-engine/translation/tests/goldenfiles/nested_aggregates/configuration.json index 17d9782e2..3c20fa37d 100644 --- a/crates/query-engine/translation/tests/goldenfiles/nested_aggregates/configuration.json +++ b/crates/query-engine/translation/tests/goldenfiles/nested_aggregates/configuration.json @@ -1,67 +1,70 @@ { - "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" + "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" + }, + "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" + }, + "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 index 17d9782e2..3c20fa37d 100644 --- a/crates/query-engine/translation/tests/goldenfiles/nested_array_relationships/configuration.json +++ b/crates/query-engine/translation/tests/goldenfiles/nested_array_relationships/configuration.json @@ -1,67 +1,70 @@ { - "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" + "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" + }, + "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" + }, + "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 index 1b79f596e..668c8d63d 100644 --- a/crates/query-engine/translation/tests/goldenfiles/nested_recursive_relationship/configuration.json +++ b/crates/query-engine/translation/tests/goldenfiles/nested_recursive_relationship/configuration.json @@ -1,43 +1,46 @@ { - "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" + "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" + }, + "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 index f9eeb8c9f..ed4aff175 100644 --- a/crates/query-engine/translation/tests/goldenfiles/no_fields/configuration.json +++ b/crates/query-engine/translation/tests/goldenfiles/no_fields/configuration.json @@ -1,24 +1,4 @@ { - "tables": { - "Album": { - "schemaName": "public", - "tableName": "Album", - "columns": { - "Id": { - "name": "AlbumId", - "type": { - "scalarType": "int4" - } - }, - "Title": { - "name": "Title", - "type": { - "scalarType": "varchar" - } - } - } - } - }, "comparisonOperators": { "varchar": { "_eq": { @@ -39,5 +19,28 @@ "operatorKind": "equal" } } + }, + "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_array_column/configuration.json b/crates/query-engine/translation/tests/goldenfiles/select_array_column/configuration.json index 800e6586c..e5f656a3b 100644 --- a/crates/query-engine/translation/tests/goldenfiles/select_array_column/configuration.json +++ b/crates/query-engine/translation/tests/goldenfiles/select_array_column/configuration.json @@ -6,7 +6,9 @@ "series": { "name": "series", "type": { - "arrayType": { "scalarType": "int4" } + "arrayType": { + "scalarType": "int4" + } }, "nullable": "nullable", "description": null @@ -30,5 +32,9 @@ }, "description": "A native query used to test support for arrays" } + }, + "version": "3", + "metadata": { + "tables": null } } 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 index c79e8ba2e..bd99ae7fe 100644 --- 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 @@ -82,5 +82,9 @@ }, "description": "A native query used to test support array-valued variables" } + }, + "version": "3", + "metadata": { + "tables": null } } 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 index e38cfa791..6bc4c4a2b 100644 --- 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 @@ -28,5 +28,9 @@ }, "description": "A native query used to test support for arrays as inputs" } + }, + "version": "3", + "metadata": { + "tables": null } } 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 index be18f3610..32892b675 100644 --- a/crates/query-engine/translation/tests/goldenfiles/select_array_variable/configuration.json +++ b/crates/query-engine/translation/tests/goldenfiles/select_array_variable/configuration.json @@ -16,12 +16,18 @@ "array_argument": { "name": "array_argument", "type": { - "arrayType": { "scalarType": "text" } + "arrayType": { + "scalarType": "text" + } }, "nullable": "nullable" } }, "description": "A native query used to test support array-valued variables" } + }, + "version": "3", + "metadata": { + "tables": null } } 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 index 98a3479d8..9bb8f4af4 100644 --- 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 @@ -82,5 +82,9 @@ }, "description": "A native query used to test support array-valued variables" } + }, + "version": "3", + "metadata": { + "tables": null } } 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 index f850bd854..d0a47e734 100644 --- 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 @@ -83,5 +83,9 @@ }, "description": "A native query used to test support for composite types" } + }, + "version": "3", + "metadata": { + "tables": null } } 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 index 75969cc11..999eb5505 100644 --- 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 @@ -43,5 +43,9 @@ }, "description": "A native query used to test support for composite types" } + }, + "version": "3", + "metadata": { + "tables": null } } 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 index f850bd854..d0a47e734 100644 --- 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 @@ -83,5 +83,9 @@ }, "description": "A native query used to test support for composite types" } + }, + "version": "3", + "metadata": { + "tables": null } } 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 index 75969cc11..999eb5505 100644 --- 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 @@ -43,5 +43,9 @@ }, "description": "A native query used to test support for composite types" } + }, + "version": "3", + "metadata": { + "tables": null } } 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 index 8f95888f8..ec69e7ee1 100644 --- 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 @@ -92,5 +92,9 @@ }, "description": "A native query used to test support for composite types" } + }, + "version": "3", + "metadata": { + "tables": null } } 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 index 75969cc11..999eb5505 100644 --- 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 @@ -43,5 +43,9 @@ }, "description": "A native query used to test support for composite types" } + }, + "version": "3", + "metadata": { + "tables": null } } 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 index 17d9782e2..3c20fa37d 100644 --- 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 @@ -1,67 +1,70 @@ { - "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" + "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" + }, + "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" + }, + "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 index 315bfe4a2..9c8e21955 100644 --- 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 @@ -1,147 +1,156 @@ { - "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" - } - } + "comparisonOperators": { + "int4": { + "_gt": { + "operatorName": ">", + "argumentType": "int4", + "operatorKind": "custom" } }, - "Artist": { - "schemaName": "public", - "tableName": "Artist", - "columns": { - "ArtistId": { - "name": "ArtistId", - "type": { - "scalarType": "int4" + "varchar": { + "_eq": { + "operatorName": "=", + "argumentType": "varchar", + "operatorKind": "equal" + } + } + }, + "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" + } } }, - "Name": { - "name": "Name", - "type": { - "scalarType": "varchar" + "uniquenessConstraints": { + "PK_Album": [ + "AlbumId" + ] + }, + "foreignRelations": { + "FK_AlbumArtistId": { + "foreignTable": "Album", + "columnMapping": { + "ArtistId": "ArtistId" + } } } }, - "uniquenessConstraints": { - "PK_Artist": ["ArtistId"] - }, - "foreignRelations": {} - }, - "Track": { - "schemaName": "public", - "tableName": "Track", - "columns": { - "AlbumId": { - "name": "AlbumId", - "type": { - "scalarType": "varchar" - } - }, - "Bytes": { - "name": "Bytes", - "type": { - "scalarType": "varchar" + "Artist": { + "schemaName": "public", + "tableName": "Artist", + "columns": { + "ArtistId": { + "name": "ArtistId", + "type": { + "scalarType": "int4" + } + }, + "Name": { + "name": "Name", + "type": { + "scalarType": "varchar" + } } }, - "Composer": { - "name": "Composer", - "type": { - "scalarType": "varchar" - } - }, - "GenreId": { - "name": "GenreId", - "type": { - "scalarType": "int4" - } - }, - "MediaTypeId": { - "name": "MediaTypeId", - "type": { - "scalarType": "int4" - } + "uniquenessConstraints": { + "PK_Artist": [ + "ArtistId" + ] }, - "Milliseconds": { - "name": "Milliseconds", - "type": { - "scalarType": "int4" + "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" + } } }, - "Name": { - "name": "Name", - "type": { - "scalarType": "varchar" - } + "uniquenessConstraints": { + "PK_Track": [ + "TrackId" + ] }, - "TrackId": { - "name": "TrackId", - "type": { - "scalarType": "int4" - } - }, - "UnitPrice": { - "name": "UnitPrice", - "type": { - "scalarType": "float4" + "foreignRelations": { + "FK_TrackAlbumId": { + "foreignTable": "Track", + "columnMapping": { + "AlbumId": "AlbumId" + } } } - }, - "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 index 6bdfd7b15..ff73f38fc 100644 --- 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 @@ -1,48 +1,4 @@ { - "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": { @@ -51,5 +7,52 @@ "operatorKind": "custom" } } + }, + "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" + } + } + } + } + } } } 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 index a8faba64a..3e94aa7ce 100644 --- 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 @@ -51,5 +51,9 @@ "operatorKind": "in" } } + }, + "version": "3", + "metadata": { + "tables": null } } 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 index 1ea8d5a64..dc9f39a50 100644 --- 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 @@ -1,19 +1,22 @@ { - "tables": { - "Album": { - "schemaName": "public", - "tableName": "Album", - "columns": { - "Id": { - "name": "AlbumId", - "type": { - "scalarType": "int4" - } - }, - "Title": { - "name": "Title", - "type": { - "scalarType": "varchar" + "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_prefix_function/configuration.json b/crates/query-engine/translation/tests/goldenfiles/select_where_prefix_function/configuration.json index 8365283d5..71b732dee 100644 --- 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 @@ -1,18 +1,4 @@ { - "tables": { - "Album": { - "schemaName": "public", - "tableName": "Album", - "columns": { - "Id": { - "name": "AlbumId", - "type": { - "scalarType": "int4" - } - } - } - } - }, "comparisonOperators": { "varchar": { "_eq": { @@ -44,5 +30,22 @@ "isInfix": false } } + }, + "version": "3", + "metadata": { + "tables": { + "Album": { + "schemaName": "public", + "tableName": "Album", + "columns": { + "Id": { + "name": "AlbumId", + "type": { + "scalarType": "int4" + } + } + } + } + } } } 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 index 3bacca490..6c9a9f235 100644 --- 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 @@ -1,48 +1,4 @@ { - "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": { @@ -51,5 +7,52 @@ "operatorKind": "custom" } } + }, + "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" + } + } + } + } + } } } 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 index d43939850..c8630437d 100644 --- a/crates/query-engine/translation/tests/goldenfiles/select_where_string/configuration.json +++ b/crates/query-engine/translation/tests/goldenfiles/select_where_string/configuration.json @@ -1,24 +1,4 @@ { - "tables": { - "Album": { - "schemaName": "public", - "tableName": "Album", - "columns": { - "Id": { - "name": "AlbumId", - "type": { - "scalarType": "int4" - } - }, - "Title": { - "name": "Title", - "type": { - "scalarType": "varchar" - } - } - } - } - }, "comparisonOperators": { "varchar": { "_in": { @@ -27,5 +7,28 @@ "operatorKind": "in" } } + }, + "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_unrelated_exists/configuration.json b/crates/query-engine/translation/tests/goldenfiles/select_where_unrelated_exists/configuration.json index 7488c9437..6978224fe 100644 --- 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 @@ -1,48 +1,4 @@ { - "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": { @@ -58,5 +14,52 @@ "operatorKind": "equal" } } + }, + "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" + } + } + } + } + } } } 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 index a1a57a93c..e7f298935 100644 --- a/crates/query-engine/translation/tests/goldenfiles/select_with_limit/configuration.json +++ b/crates/query-engine/translation/tests/goldenfiles/select_with_limit/configuration.json @@ -1,13 +1,16 @@ { - "tables": { - "Album": { - "schemaName": "public", - "tableName": "Album", - "columns": { - "Title": { - "name": "Title", - "type": { - "scalarType": "varchar" + "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/simple_array_relationship/configuration.json b/crates/query-engine/translation/tests/goldenfiles/simple_array_relationship/configuration.json index 1b79f596e..668c8d63d 100644 --- a/crates/query-engine/translation/tests/goldenfiles/simple_array_relationship/configuration.json +++ b/crates/query-engine/translation/tests/goldenfiles/simple_array_relationship/configuration.json @@ -1,43 +1,46 @@ { - "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" + "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" + }, + "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 index 1b79f596e..668c8d63d 100644 --- a/crates/query-engine/translation/tests/goldenfiles/simple_object_relationship/configuration.json +++ b/crates/query-engine/translation/tests/goldenfiles/simple_object_relationship/configuration.json @@ -1,43 +1,46 @@ { - "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" + "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" + }, + "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 index ff978405d..b7211bda1 100644 --- 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 @@ -1,67 +1,70 @@ { - "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" + "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" + }, + "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" + }, + "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 index 9b6737d31..497a70523 100644 --- 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 @@ -1,72 +1,4 @@ { - "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": { @@ -92,5 +24,76 @@ "operatorKind": "in" } } + }, + "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_count/configuration.json b/crates/query-engine/translation/tests/goldenfiles/sorting_by_nested_relationship_count/configuration.json index 17d9782e2..3c20fa37d 100644 --- 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 @@ -1,67 +1,70 @@ { - "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" + "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" + }, + "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" + }, + "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 index c6bcd5912..b90043914 100644 --- 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 @@ -1,27 +1,30 @@ { - "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" + "version": "3", + "metadata": { + "tables": { + "Album": { + "schemaName": "public", + "tableName": "Album", + "columns": { + "AlbumId": { + "name": "AlbumId", + "type": { + "scalarType": "int4" + } }, - "nullable": "nullable" + "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 index d9b0f2df5..5bdf75433 100644 --- 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 @@ -1,49 +1,52 @@ { - "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" + "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" + }, + "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 index 1b79f596e..668c8d63d 100644 --- 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 @@ -1,43 +1,46 @@ { - "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" + "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" + }, + "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 index 1b79f596e..668c8d63d 100644 --- 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 @@ -1,43 +1,46 @@ { - "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" + "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" + }, + "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 index 758695d1f..81c99efea 100644 --- 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 @@ -1,72 +1,4 @@ { - "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": { @@ -75,5 +7,76 @@ "operatorKind": "custom" } } + }, + "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" + } + } + } + } + } } } 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 index 2b5f21815..370c6839e 100644 --- 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 @@ -1,44 +1,4 @@ { - "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": { @@ -76,5 +36,48 @@ "argumentType": "timestamptz" } } + }, + "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": {} + } + } } } 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 index 615db6b1c..eafd121a5 100644 --- 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 @@ -67,5 +67,9 @@ } } } + }, + "version": "3", + "metadata": { + "tables": null } } 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 index 1b79f596e..668c8d63d 100644 --- 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 @@ -1,43 +1,46 @@ { - "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" + "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" + }, + "Artist": { + "schemaName": "public", + "tableName": "Artist", + "columns": { + "ArtistId": { + "name": "ArtistId", + "type": { + "scalarType": "int4" + } + }, + "Name": { + "name": "Name", + "type": { + "scalarType": "varchar" + } } } } From 8f8bcb3e2f7baf9b7f6560bb30695195c3c3460f Mon Sep 17 00:00:00 2001 From: Philip Lykke Carlsen Date: Tue, 7 May 2024 13:31:43 +0200 Subject: [PATCH 13/18] Patching up test configurations --- .../mutations/simple/configuration.json | 47 +++-- .../select_artist/configuration.json | 35 ++-- .../select_artist_by_id/configuration.json | 47 +++-- .../select_artist_by_name/configuration.json | 47 +++-- .../configuration.json | 89 +++++---- .../configuration.json | 101 +++++----- .../goldenfiles/no_fields/configuration.json | 42 ++--- .../select_array_column/configuration.json | 65 ++++--- .../configuration.json | 139 +++++++------- .../configuration.json | 61 +++--- .../select_array_variable/configuration.json | 55 +++--- .../configuration.json | 139 +++++++------- .../configuration.json | 147 ++++++++------- .../configuration.json | 81 ++++---- .../configuration.json | 147 ++++++++------- .../configuration.json | 81 ++++---- .../configuration.json | 173 +++++++++--------- .../configuration.json | 81 ++++---- .../configuration.json | 32 ++-- .../configuration.json | 18 +- .../configuration.json | 95 +++++----- .../configuration.json | 64 +++---- .../configuration.json | 18 +- .../select_where_string/configuration.json | 18 +- .../configuration.json | 32 ++-- .../configuration.json | 52 +++--- .../configuration.json | 18 +- .../configuration.json | 76 ++++---- .../configuration.json | 131 +++++++------ 29 files changed, 1056 insertions(+), 1075 deletions(-) diff --git a/crates/query-engine/translation/tests/goldenfiles/mutations/simple/configuration.json b/crates/query-engine/translation/tests/goldenfiles/mutations/simple/configuration.json index fe9b48bfc..a7adbbf20 100644 --- a/crates/query-engine/translation/tests/goldenfiles/mutations/simple/configuration.json +++ b/crates/query-engine/translation/tests/goldenfiles/mutations/simple/configuration.json @@ -1,33 +1,32 @@ { - "nativeQueries": { - "delete_playlist_track": { - "sql": "DELETE FROM public.\"PlaylistTrack\" WHERE \"TrackId\" = {{track_id}} RETURNING *", - "columns": { - "PlaylistId": { - "name": "PlaylistId", - "type": { - "scalarType": "int4" + "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" + } } }, - "TrackId": { - "name": "TrackId", - "type": { - "scalarType": "int4" - } - } - }, - "arguments": { - "track_id": { - "name": "track_id", - "type": { - "scalarType": "int4" + "arguments": { + "track_id": { + "name": "track_id", + "type": { + "scalarType": "int4" + } } } } } - }, - "version": "3", - "metadata": { - "tables": null } } 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 index 1df5e0756..5847e8a66 100644 --- 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 @@ -1,25 +1,24 @@ { - "nativeQueries": { - "artist": { - "sql": "SELECT * FROM public.\"Artist\"", - "columns": { - "ArtistId": { - "name": "ArtistId", - "type": { - "scalarType": "int4" - } - }, - "Name": { - "name": "Name", - "type": { - "scalarType": "varchar" + "version": "3", + "metadata": { + "nativeQueries": { + "artist": { + "sql": "SELECT * FROM public.\"Artist\"", + "columns": { + "ArtistId": { + "name": "ArtistId", + "type": { + "scalarType": "int4" + } + }, + "Name": { + "name": "Name", + "type": { + "scalarType": "varchar" + } } } } } - }, - "version": "3", - "metadata": { - "tables": null } } 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 index 42b3c54f9..8123a4f76 100644 --- 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 @@ -1,33 +1,32 @@ { - "nativeQueries": { - "artist_by_id": { - "sql": "SELECT * FROM public.\"Artist\" WHERE \"ArtistId\" = {{id}}", - "columns": { - "ArtistId": { - "name": "ArtistId", - "type": { - "scalarType": "int4" + "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" + } } }, - "Name": { - "name": "Name", - "type": { - "scalarType": "varchar" - } - } - }, - "arguments": { - "id": { - "name": "id", - "type": { - "scalarType": "int4" + "arguments": { + "id": { + "name": "id", + "type": { + "scalarType": "int4" + } } } } } - }, - "version": "3", - "metadata": { - "tables": null } } 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 index 9b974fbfc..47c49aab8 100644 --- 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 @@ -1,33 +1,32 @@ { - "nativeQueries": { - "artist_by_name": { - "sql": "SELECT * FROM public.\"Artist\" WHERE \"Name\" = {{name}}", - "columns": { - "ArtistId": { - "name": "ArtistId", - "type": { - "scalarType": "int4" + "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" + } } }, - "Name": { - "name": "Name", - "type": { - "scalarType": "varchar" - } - } - }, - "arguments": { - "name": { - "name": "name", - "type": { - "scalarType": "varchar" + "arguments": { + "name": { + "name": "name", + "type": { + "scalarType": "varchar" + } } } } } - }, - "version": "3", - "metadata": { - "tables": null } } 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 index f08d174e3..35df0abce 100644 --- 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 @@ -1,57 +1,56 @@ { - "nativeQueries": { - "artist": { - "sql": "SELECT * FROM public.\"Artist\"", - "columns": { - "ArtistId": { - "name": "ArtistId", - "type": { - "scalarType": "int4" + "version": "3", + "metadata": { + "nativeQueries": { + "artist": { + "sql": "SELECT * FROM public.\"Artist\"", + "columns": { + "ArtistId": { + "name": "ArtistId", + "type": { + "scalarType": "int4" + } + }, + "Name": { + "name": "Name", + "type": { + "scalarType": "varchar" + } } }, - "Name": { - "name": "Name", - "type": { - "scalarType": "varchar" - } - } + "arguments": {} }, - "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" + "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" + } } }, - "ArtistId": { - "name": "ArtistId", - "type": { - "scalarType": "int4" - } - } - }, - "arguments": { - "title": { - "name": "title", - "type": { - "scalarType": "varchar" + "arguments": { + "title": { + "name": "title", + "type": { + "scalarType": "varchar" + } } } } } - }, - "version": "3", - "metadata": { - "tables": null } } 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 index 3398871bd..61e928292 100644 --- 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 @@ -1,63 +1,62 @@ { - "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" + "version": "3", + "metadata": { + "nativeQueries": { + "artist": { + "sql": "SELECT * FROM public.\"Artist\"", + "columns": { + "ArtistId": { + "name": "ArtistId", + "type": { + "scalarType": "int4" + } + }, + "Name": { + "name": "Name", + "type": { + "scalarType": "varchar" + } } }, - "ArtistId": { - "name": "ArtistId", - "type": { - "scalarType": "int4" - } - } + "arguments": {} }, - "arguments": { - "id": { - "name": "id", - "type": { - "scalarType": "int4" + "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" + } } }, - "title": { - "name": "title", - "type": { - "scalarType": "varchar" + "arguments": { + "id": { + "name": "id", + "type": { + "scalarType": "int4" + } + }, + "title": { + "name": "title", + "type": { + "scalarType": "varchar" + } } } } } - }, - "version": "3", - "metadata": { - "tables": null } } diff --git a/crates/query-engine/translation/tests/goldenfiles/no_fields/configuration.json b/crates/query-engine/translation/tests/goldenfiles/no_fields/configuration.json index ed4aff175..95392d8d6 100644 --- a/crates/query-engine/translation/tests/goldenfiles/no_fields/configuration.json +++ b/crates/query-engine/translation/tests/goldenfiles/no_fields/configuration.json @@ -1,25 +1,4 @@ { - "comparisonOperators": { - "varchar": { - "_eq": { - "operatorName": "=", - "argumentType": "varchar", - "operatorKind": "equal" - }, - "_in": { - "operatorName": "IN", - "argumentType": "varchar", - "operatorKind": "in" - } - }, - "int4": { - "_eq": { - "operatorName": "=", - "argumentType": "int4", - "operatorKind": "equal" - } - } - }, "version": "3", "metadata": { "tables": { @@ -41,6 +20,27 @@ } } } + }, + "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 index e5f656a3b..521a29057 100644 --- a/crates/query-engine/translation/tests/goldenfiles/select_array_column/configuration.json +++ b/crates/query-engine/translation/tests/goldenfiles/select_array_column/configuration.json @@ -1,40 +1,39 @@ { - "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": { + "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", - "description": null - } - }, - "arguments": { - "from": { - "name": "from", - "type": { - "scalarType": "int4" + }, + "nullable": "nullable" }, - "nullable": "nullable" + "to": { + "name": "to", + "type": { + "scalarType": "int4" + }, + "nullable": "nullable" + } }, - "to": { - "name": "to", - "type": { - "scalarType": "int4" - }, - "nullable": "nullable" - } - }, - "description": "A native query used to test support for arrays" + "description": "A native query used to test support for arrays" + } } - }, - "version": "3", - "metadata": { - "tables": null } } 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 index bd99ae7fe..e4dbc3afb 100644 --- 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 @@ -1,90 +1,89 @@ { - "compositeTypes": { - "person_name": { - "name": "person_name", - "fields": { - "first_name": { - "name": "first_name", - "type": { - "scalarType": "text" + "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 } }, - "last_name": { - "name": "last_name", - "type": { - "scalarType": "text" + "arguments": { + "organizations": { + "name": "organizations", + "type": { + "arrayType": { + "compositeType": "organization" + } + }, + "nullable": "nullable" } - } + }, + "description": "A native query used to test support array-valued variables" } }, - "committee": { - "name": "committee", - "fields": { - "name": { - "name": "name", - "type": { - "scalarType": "text" - } - }, - "members": { - "name": "members", - "type": { - "arrayType": { + "compositeTypes": { + "person_name": { + "name": "person_name", + "fields": { + "first_name": { + "name": "first_name", + "type": { "scalarType": "text" } - } - } - } - }, - "organization": { - "name": "organization", - "fields": { - "name": { - "name": "name", - "type": { - "scalarType": "text" - } - }, - "members": { - "name": "committees", - "type": { - "arrayType": { - "compositeType": "committee" + }, + "last_name": { + "name": "last_name", + "type": { + "scalarType": "text" } } } - } - } - }, - "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" + }, + "committee": { + "name": "committee", + "fields": { + "name": { + "name": "name", + "type": { + "scalarType": "text" + } }, - "nullable": "nullable", - "description": null + "members": { + "name": "members", + "type": { + "arrayType": { + "scalarType": "text" + } + } + } } }, - "arguments": { - "organizations": { - "name": "organizations", - "type": { - "arrayType": { - "compositeType": "organization" + "organization": { + "name": "organization", + "fields": { + "name": { + "name": "name", + "type": { + "scalarType": "text" } }, - "nullable": "nullable" + "members": { + "name": "committees", + "type": { + "arrayType": { + "compositeType": "committee" + } + } + } } - }, - "description": "A native query used to test support array-valued variables" + } } - }, - "version": "3", - "metadata": { - "tables": null } } 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 index 6bc4c4a2b..d48120d41 100644 --- 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 @@ -1,36 +1,35 @@ { - "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" - } - }, "version": "3", "metadata": { - "tables": null + "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 index 32892b675..060ecaa7e 100644 --- a/crates/query-engine/translation/tests/goldenfiles/select_array_variable/configuration.json +++ b/crates/query-engine/translation/tests/goldenfiles/select_array_variable/configuration.json @@ -1,33 +1,32 @@ { - "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" - } - }, "version": "3", "metadata": { - "tables": null + "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 index 9bb8f4af4..66ff22a60 100644 --- 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 @@ -1,90 +1,89 @@ { - "compositeTypes": { - "person_name": { - "name": "person_name", - "fields": { - "first_name": { - "name": "first_name", - "type": { - "scalarType": "text" + "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 } }, - "last_name": { - "name": "last_name", - "type": { - "scalarType": "text" + "arguments": { + "organizations": { + "name": "organizations", + "type": { + "arrayType": { + "compositeType": "organization" + } + }, + "nullable": "nullable" } - } + }, + "description": "A native query used to test support array-valued variables" } }, - "committee": { - "name": "committee", - "fields": { - "name": { - "name": "name", - "type": { - "scalarType": "text" - } - }, - "members": { - "name": "members", - "type": { - "arrayType": { + "compositeTypes": { + "person_name": { + "name": "person_name", + "fields": { + "first_name": { + "name": "first_name", + "type": { "scalarType": "text" } - } - } - } - }, - "organization": { - "name": "organization", - "fields": { - "name": { - "name": "name", - "type": { - "scalarType": "text" - } - }, - "members": { - "name": "committees", - "type": { - "arrayType": { - "compositeType": "committee" + }, + "last_name": { + "name": "last_name", + "type": { + "scalarType": "text" } } } - } - } - }, - "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" + }, + "committee": { + "name": "committee", + "fields": { + "name": { + "name": "name", + "type": { + "scalarType": "text" + } }, - "nullable": "nullable", - "description": null + "members": { + "name": "members", + "type": { + "arrayType": { + "scalarType": "text" + } + } + } } }, - "arguments": { - "organizations": { - "name": "organizations", - "type": { - "arrayType": { - "compositeType": "organization" + "organization": { + "name": "organization", + "fields": { + "name": { + "name": "name", + "type": { + "scalarType": "text" } }, - "nullable": "nullable" + "members": { + "name": "committees", + "type": { + "arrayType": { + "compositeType": "committee" + } + } + } } - }, - "description": "A native query used to test support array-valued variables" + } } - }, - "version": "3", - "metadata": { - "tables": null } } 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 index d0a47e734..26a6b1ebc 100644 --- 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 @@ -1,91 +1,90 @@ { - "compositeTypes": { - "person": { - "name": "person", - "fields": { - "name": { - "name": "name", - "type": { - "compositeType": "person_name" + "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 } }, - "address": { - "name": "address", - "type": { - "compositeType": "person_address" - } - } - } - }, - "person_name": { - "name": "person_name", - "fields": { - "first_name": { - "name": "first_name", - "type": { - "scalarType": "text" + "arguments": { + "name": { + "name": "name", + "type": { + "compositeType": "person_name" + }, + "nullable": "nullable" + }, + "address": { + "name": "address", + "type": { + "compositeType": "person_address" + }, + "nullable": "nullable" } }, - "last_name": { - "name": "last_name", - "type": { - "scalarType": "text" - } - } + "description": "A native query used to test support for composite types" } }, - "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" + "compositeTypes": { + "person": { + "name": "person", + "fields": { + "name": { + "name": "name", + "type": { + "compositeType": "person_name" + } + }, + "address": { + "name": "address", + "type": { + "compositeType": "person_address" + } } } - } - } - }, - "nativeQueries": { - "make_person": { - "sql": "SELECT ROW({{name}}, {{address}})::person as result", - "columns": { - "result": { - "name": "result", - "type": { - "compositeType": "person" + }, + "person_name": { + "name": "person_name", + "fields": { + "first_name": { + "name": "first_name", + "type": { + "scalarType": "text" + } }, - "nullable": "nullable", - "description": null + "last_name": { + "name": "last_name", + "type": { + "scalarType": "text" + } + } } }, - "arguments": { - "name": { - "name": "name", - "type": { - "compositeType": "person_name" - }, - "nullable": "nullable" - }, - "address": { - "name": "address", - "type": { - "compositeType": "person_address" + "person_address": { + "name": "person_address", + "fields": { + "address_line_1": { + "name": "address_line_1", + "type": { + "scalarType": "text" + } }, - "nullable": "nullable" + "address_line_2": { + "name": "address_line_2", + "type": { + "scalarType": "text" + } + } } - }, - "description": "A native query used to test support for composite types" + } } - }, - "version": "3", - "metadata": { - "tables": null } } 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 index 999eb5505..d4dc7dfdf 100644 --- 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 @@ -1,51 +1,50 @@ { - "compositeTypes": { - "person_address": { - "name": "person_address", - "fields": { - "address_line_1": { - "name": "address_line_1", - "type": { - "scalarType": "text" + "version": "3", + "metadata": { + "nativeQueries": { + "address_identity_function": { + "sql": "SELECT {{address}} as result", + "columns": { + "result": { + "name": "result", + "type": { + "compositeType": "person_address" + }, + "nullable": "nullable", + "description": null } }, - "address_line_2": { - "name": "address_line_2", - "type": { - "scalarType": "text" + "arguments": { + "address": { + "name": "address", + "type": { + "compositeType": "person_address" + }, + "nullable": "nullable", + "description": null } - } + }, + "description": "A native query used to test support for composite types" } - } - }, - "nativeQueries": { - "address_identity_function": { - "sql": "SELECT {{address}} as result", - "columns": { - "result": { - "name": "result", - "type": { - "compositeType": "person_address" + }, + "compositeTypes": { + "person_address": { + "name": "person_address", + "fields": { + "address_line_1": { + "name": "address_line_1", + "type": { + "scalarType": "text" + } }, - "nullable": "nullable", - "description": null - } - }, - "arguments": { - "address": { - "name": "address", - "type": { - "compositeType": "person_address" - }, - "nullable": "nullable", - "description": null + "address_line_2": { + "name": "address_line_2", + "type": { + "scalarType": "text" + } + } } - }, - "description": "A native query used to test support for composite types" + } } - }, - "version": "3", - "metadata": { - "tables": null } } 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 index d0a47e734..26a6b1ebc 100644 --- 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 @@ -1,91 +1,90 @@ { - "compositeTypes": { - "person": { - "name": "person", - "fields": { - "name": { - "name": "name", - "type": { - "compositeType": "person_name" + "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 } }, - "address": { - "name": "address", - "type": { - "compositeType": "person_address" - } - } - } - }, - "person_name": { - "name": "person_name", - "fields": { - "first_name": { - "name": "first_name", - "type": { - "scalarType": "text" + "arguments": { + "name": { + "name": "name", + "type": { + "compositeType": "person_name" + }, + "nullable": "nullable" + }, + "address": { + "name": "address", + "type": { + "compositeType": "person_address" + }, + "nullable": "nullable" } }, - "last_name": { - "name": "last_name", - "type": { - "scalarType": "text" - } - } + "description": "A native query used to test support for composite types" } }, - "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" + "compositeTypes": { + "person": { + "name": "person", + "fields": { + "name": { + "name": "name", + "type": { + "compositeType": "person_name" + } + }, + "address": { + "name": "address", + "type": { + "compositeType": "person_address" + } } } - } - } - }, - "nativeQueries": { - "make_person": { - "sql": "SELECT ROW({{name}}, {{address}})::person as result", - "columns": { - "result": { - "name": "result", - "type": { - "compositeType": "person" + }, + "person_name": { + "name": "person_name", + "fields": { + "first_name": { + "name": "first_name", + "type": { + "scalarType": "text" + } }, - "nullable": "nullable", - "description": null + "last_name": { + "name": "last_name", + "type": { + "scalarType": "text" + } + } } }, - "arguments": { - "name": { - "name": "name", - "type": { - "compositeType": "person_name" - }, - "nullable": "nullable" - }, - "address": { - "name": "address", - "type": { - "compositeType": "person_address" + "person_address": { + "name": "person_address", + "fields": { + "address_line_1": { + "name": "address_line_1", + "type": { + "scalarType": "text" + } }, - "nullable": "nullable" + "address_line_2": { + "name": "address_line_2", + "type": { + "scalarType": "text" + } + } } - }, - "description": "A native query used to test support for composite types" + } } - }, - "version": "3", - "metadata": { - "tables": null } } 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 index 999eb5505..d4dc7dfdf 100644 --- 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 @@ -1,51 +1,50 @@ { - "compositeTypes": { - "person_address": { - "name": "person_address", - "fields": { - "address_line_1": { - "name": "address_line_1", - "type": { - "scalarType": "text" + "version": "3", + "metadata": { + "nativeQueries": { + "address_identity_function": { + "sql": "SELECT {{address}} as result", + "columns": { + "result": { + "name": "result", + "type": { + "compositeType": "person_address" + }, + "nullable": "nullable", + "description": null } }, - "address_line_2": { - "name": "address_line_2", - "type": { - "scalarType": "text" + "arguments": { + "address": { + "name": "address", + "type": { + "compositeType": "person_address" + }, + "nullable": "nullable", + "description": null } - } + }, + "description": "A native query used to test support for composite types" } - } - }, - "nativeQueries": { - "address_identity_function": { - "sql": "SELECT {{address}} as result", - "columns": { - "result": { - "name": "result", - "type": { - "compositeType": "person_address" + }, + "compositeTypes": { + "person_address": { + "name": "person_address", + "fields": { + "address_line_1": { + "name": "address_line_1", + "type": { + "scalarType": "text" + } }, - "nullable": "nullable", - "description": null - } - }, - "arguments": { - "address": { - "name": "address", - "type": { - "compositeType": "person_address" - }, - "nullable": "nullable", - "description": null + "address_line_2": { + "name": "address_line_2", + "type": { + "scalarType": "text" + } + } } - }, - "description": "A native query used to test support for composite types" + } } - }, - "version": "3", - "metadata": { - "tables": null } } 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 index ec69e7ee1..a4bf7a669 100644 --- 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 @@ -1,100 +1,99 @@ { - "compositeTypes": { - "committee": { - "name": "committee", - "fields": { - "members": { - "name": "members", - "type": { - "arrayType": { - "compositeType": "person_name" - } - }, - "description": null + "version": "3", + "metadata": { + "nativeQueries": { + "organization_identity_function": { + "sql": { + "inline": "SELECT {{organization}} as result_the_column" }, - "name": { - "name": "name", - "type": { - "scalarType": "text" - }, - "description": null - } - }, - "description": null - }, - "organization": { - "name": "organization", - "fields": { - "committees": { - "name": "committees", - "type": { - "arrayType": { - "compositeType": "committee" - } - }, - "description": null + "columns": { + "result_the_field": { + "name": "result_the_column", + "type": { + "compositeType": "organization" + }, + "nullable": "nullable", + "description": null + } }, - "name": { - "name": "name", - "type": { - "scalarType": "text" - }, - "description": null - } - }, - "description": null + "arguments": { + "organization": { + "name": "organization", + "type": { + "compositeType": "organization" + }, + "nullable": "nullable", + "description": null + } + }, + "description": "A native query used to test support for composite types" + } }, - "person_name": { - "name": "person_name", - "fields": { - "first_name": { - "name": "first_name", - "type": { - "scalarType": "text" + "compositeTypes": { + "committee": { + "name": "committee", + "fields": { + "members": { + "name": "members", + "type": { + "arrayType": { + "compositeType": "person_name" + } + }, + "description": null }, - "description": "The first name of a person" + "name": { + "name": "name", + "type": { + "scalarType": "text" + }, + "description": null + } }, - "last_name": { - "name": "last_name", - "type": { - "scalarType": "text" - }, - "description": "The last name of a person" - } + "description": null }, - "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" + "organization": { + "name": "organization", + "fields": { + "committees": { + "name": "committees", + "type": { + "arrayType": { + "compositeType": "committee" + } + }, + "description": null }, - "nullable": "nullable", - "description": null - } + "name": { + "name": "name", + "type": { + "scalarType": "text" + }, + "description": null + } + }, + "description": null }, - "arguments": { - "organization": { - "name": "organization", - "type": { - "compositeType": "organization" + "person_name": { + "name": "person_name", + "fields": { + "first_name": { + "name": "first_name", + "type": { + "scalarType": "text" + }, + "description": "The first name of a person" }, - "nullable": "nullable", - "description": null - } - }, - "description": "A native query used to test support for composite types" + "last_name": { + "name": "last_name", + "type": { + "scalarType": "text" + }, + "description": "The last name of a person" + } + }, + "description": "The name of a person, obviously" + } } - }, - "version": "3", - "metadata": { - "tables": null } } 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 index 999eb5505..d4dc7dfdf 100644 --- 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 @@ -1,51 +1,50 @@ { - "compositeTypes": { - "person_address": { - "name": "person_address", - "fields": { - "address_line_1": { - "name": "address_line_1", - "type": { - "scalarType": "text" + "version": "3", + "metadata": { + "nativeQueries": { + "address_identity_function": { + "sql": "SELECT {{address}} as result", + "columns": { + "result": { + "name": "result", + "type": { + "compositeType": "person_address" + }, + "nullable": "nullable", + "description": null } }, - "address_line_2": { - "name": "address_line_2", - "type": { - "scalarType": "text" + "arguments": { + "address": { + "name": "address", + "type": { + "compositeType": "person_address" + }, + "nullable": "nullable", + "description": null } - } + }, + "description": "A native query used to test support for composite types" } - } - }, - "nativeQueries": { - "address_identity_function": { - "sql": "SELECT {{address}} as result", - "columns": { - "result": { - "name": "result", - "type": { - "compositeType": "person_address" + }, + "compositeTypes": { + "person_address": { + "name": "person_address", + "fields": { + "address_line_1": { + "name": "address_line_1", + "type": { + "scalarType": "text" + } }, - "nullable": "nullable", - "description": null - } - }, - "arguments": { - "address": { - "name": "address", - "type": { - "compositeType": "person_address" - }, - "nullable": "nullable", - "description": null + "address_line_2": { + "name": "address_line_2", + "type": { + "scalarType": "text" + } + } } - }, - "description": "A native query used to test support for composite types" + } } - }, - "version": "3", - "metadata": { - "tables": null } } 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 index 9c8e21955..3f94e5c1b 100644 --- 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 @@ -1,20 +1,4 @@ { - "comparisonOperators": { - "int4": { - "_gt": { - "operatorName": ">", - "argumentType": "int4", - "operatorKind": "custom" - } - }, - "varchar": { - "_eq": { - "operatorName": "=", - "argumentType": "varchar", - "operatorKind": "equal" - } - } - }, "version": "3", "metadata": { "tables": { @@ -152,6 +136,22 @@ } } } + }, + "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 index ff73f38fc..4926ff84d 100644 --- 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 @@ -1,13 +1,4 @@ { - "comparisonOperators": { - "varchar": { - "_like": { - "operatorName": "LIKE", - "argumentType": "varchar", - "operatorKind": "custom" - } - } - }, "version": "3", "metadata": { "tables": { @@ -53,6 +44,15 @@ } } } + }, + "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 index 3e94aa7ce..444df2d11 100644 --- 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 @@ -1,59 +1,58 @@ { - "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" + "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 }, - "nullable": "nullable", - "description": null + "series": { + "name": "series", + "type": { + "arrayType": { + "scalarType": "int4" + } + }, + "nullable": "nullable", + "description": null + } }, - "series": { - "name": "series", - "type": { - "arrayType": { + "arguments": { + "from": { + "name": "from", + "type": { "scalarType": "int4" - } + }, + "nullable": "nullable", + "description": null }, - "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 + } }, - "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" } - }, - "description": "A native query used to test support for arrays" - } - }, - "comparisonOperators": { - "int4": { - "_in": { - "operatorName": "IN", - "argumentType": "int4", - "operatorKind": "in" } } - }, - "version": "3", - "metadata": { - "tables": null } } 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 index 71b732dee..eae268052 100644 --- 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 @@ -1,36 +1,4 @@ { - "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 - } - } - }, "version": "3", "metadata": { "tables": { @@ -46,6 +14,38 @@ } } } + }, + "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 index 6c9a9f235..0c214137e 100644 --- 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 @@ -1,13 +1,4 @@ { - "comparisonOperators": { - "varchar": { - "_like": { - "operatorName": "LIKE", - "argumentType": "varchar", - "operatorKind": "custom" - } - } - }, "version": "3", "metadata": { "tables": { @@ -53,6 +44,15 @@ } } } + }, + "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 index c8630437d..b3ad96c0e 100644 --- a/crates/query-engine/translation/tests/goldenfiles/select_where_string/configuration.json +++ b/crates/query-engine/translation/tests/goldenfiles/select_where_string/configuration.json @@ -1,13 +1,4 @@ { - "comparisonOperators": { - "varchar": { - "_in": { - "operatorName": "IN", - "argumentType": "varchar", - "operatorKind": "in" - } - } - }, "version": "3", "metadata": { "tables": { @@ -29,6 +20,15 @@ } } } + }, + "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 index 6978224fe..c71ce5eb2 100644 --- 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 @@ -1,20 +1,4 @@ { - "comparisonOperators": { - "varchar": { - "_eq": { - "operatorName": "=", - "argumentType": "varchar", - "operatorKind": "equal" - } - }, - "int4": { - "_eq": { - "operatorName": "=", - "argumentType": "int4", - "operatorKind": "equal" - } - } - }, "version": "3", "metadata": { "tables": { @@ -60,6 +44,22 @@ } } } + }, + "comparisonOperators": { + "varchar": { + "_eq": { + "operatorName": "=", + "argumentType": "varchar", + "operatorKind": "equal" + } + }, + "int4": { + "_eq": { + "operatorName": "=", + "argumentType": "int4", + "operatorKind": "equal" + } + } } } } 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 index 497a70523..47275bbc2 100644 --- 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 @@ -1,30 +1,4 @@ { - "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" - } - } - }, "version": "3", "metadata": { "tables": { @@ -94,6 +68,32 @@ } } } + }, + "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_relationship_count_with_predicate/configuration.json b/crates/query-engine/translation/tests/goldenfiles/sorting_by_relationship_count_with_predicate/configuration.json index 81c99efea..db9fbfb21 100644 --- 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 @@ -1,13 +1,4 @@ { - "comparisonOperators": { - "varchar": { - "_like": { - "operatorName": "LIKE", - "argumentType": "varchar", - "operatorKind": "custom" - } - } - }, "version": "3", "metadata": { "tables": { @@ -77,6 +68,15 @@ } } } + }, + "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 index 370c6839e..4d5e74704 100644 --- 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 @@ -1,42 +1,4 @@ { - "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" - } - } - }, "version": "3", "metadata": { "tables": { @@ -78,6 +40,44 @@ "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 index eafd121a5..c801ee41b 100644 --- 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 @@ -1,75 +1,74 @@ { - "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" + "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" + } } }, - "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" + } } } } } - }, - "version": "3", - "metadata": { - "tables": null } } From ff797aa688294f33bee469d637f032b2542810e3 Mon Sep 17 00:00:00 2001 From: Philip Lykke Carlsen Date: Tue, 7 May 2024 17:50:21 +0200 Subject: [PATCH 14/18] Not a little --- Cargo.lock | 14 +- crates/cli/tests/update_tests.rs | 36 +- crates/configuration/Cargo.toml | 7 +- crates/configuration/src/configuration.rs | 9 + crates/configuration/src/error.rs | 1 + crates/configuration/src/lib.rs | 55 +- crates/configuration/src/tests.rs | 99 ++ crates/configuration/src/version3/mod.rs | 21 +- ...on3__tests__get_configuration_schema.snap} | 16 +- ...e_initial_configuration_is_unchanged.snap} | 4 +- crates/configuration/src/version3/tests.rs | 117 ++ crates/configuration/src/version4/mod.rs | 17 +- .../src/version4/to_runtime_configuration.rs | 2 - crates/documentation/openapi/Cargo.toml | 5 - crates/documentation/openapi/src/generator.rs | 8 - crates/documentation/openapi/src/lib.rs | 1 - crates/documentation/openapi/src/main.rs | 4 +- crates/query-engine/translation/Cargo.toml | 3 + .../translation/src/translation/error.rs | 2 +- .../translation/tests/common/mod.rs | 36 +- .../configuration.json | 12 +- ...ion__v1__delete__tests__delete_to_sql.snap | 2 +- .../query-engine/translation/tests/tests.rs | 382 +++-- crates/tests/databases-tests/Cargo.toml | 3 - .../src/citus/configuration_tests.rs | 27 - crates/tests/databases-tests/src/citus/mod.rs | 1 - .../src/cockroach/configuration_tests.rs | 27 - .../databases-tests/src/cockroach/mod.rs | 1 - ...basic__select_composite_column_simple.snap | 16 - ...sic__select_composite_variable_simple.snap | 26 - .../src/ndc_metadata_snapshot_tests.rs | 23 +- .../src/postgres/configuration_tests.rs | 69 - .../tests/databases-tests/src/postgres/mod.rs | 2 - .../src/postgres/openapi_tests.rs | 10 - ...tests__get_rawconfiguration_v3_schema.snap | 1495 ----------------- ..._openapi__up_to_date_generated_schema.snap | 1471 ---------------- crates/tests/tests-common/Cargo.toml | 3 - .../common_tests/configuration_v3_tests.rs | 81 - .../tests-common/src/common_tests/mod.rs | 1 - crates/tests/tests-common/src/lib.rs | 1 - crates/tests/tests-common/src/router.rs | 3 +- crates/tests/tests-common/src/schemas.rs | 32 - 42 files changed, 595 insertions(+), 3550 deletions(-) create mode 100644 crates/configuration/src/tests.rs rename crates/{tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__configuration_tests__get_configuration_schema.snap => configuration/src/version3/snapshots/ndc_postgres_configuration__version3__tests__get_configuration_schema.snap} (98%) rename crates/{tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__configuration_tests__postgres_current_only_configure_v3_initial_configuration_is_unchanged.snap => configuration/src/version3/snapshots/ndc_postgres_configuration__version3__tests__postgres_current_only_configure_initial_configuration_is_unchanged.snap} (99%) create mode 100644 crates/configuration/src/version3/tests.rs delete mode 100644 crates/documentation/openapi/src/generator.rs delete mode 100644 crates/documentation/openapi/src/lib.rs delete mode 100644 crates/tests/databases-tests/src/citus/configuration_tests.rs delete mode 100644 crates/tests/databases-tests/src/cockroach/configuration_tests.rs delete mode 100644 crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__basic__select_composite_column_simple.snap delete mode 100644 crates/tests/databases-tests/src/cockroach/snapshots/databases_tests__cockroach__query_tests__basic__select_composite_variable_simple.snap delete mode 100644 crates/tests/databases-tests/src/postgres/configuration_tests.rs delete mode 100644 crates/tests/databases-tests/src/postgres/openapi_tests.rs delete mode 100644 crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__configuration_tests__get_rawconfiguration_v3_schema.snap delete mode 100644 crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__openapi_tests__openapi__up_to_date_generated_schema.snap delete mode 100644 crates/tests/tests-common/src/common_tests/configuration_v3_tests.rs delete mode 100644 crates/tests/tests-common/src/schemas.rs diff --git a/Cargo.lock b/Cargo.lock index 8757c7bd5..1ee6656e5 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/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 7e5185af8..83f48ab7b 100644 --- a/crates/configuration/Cargo.toml +++ b/crates/configuration/Cargo.toml @@ -16,5 +16,10 @@ serde = "1.0.199" 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..1cde46179 100644 --- a/crates/configuration/src/configuration.rs +++ b/crates/configuration/src/configuration.rs @@ -12,6 +12,15 @@ use crate::error::{ use crate::values::{IsolationLevel, PoolSettings}; use crate::version3; use crate::version4; +use schemars::{gen::SchemaSettings, schema::RootSchema}; + +pub fn generate_latest_schema() -> RootSchema { + SchemaSettings::openapi3() + .into_generator() + .into_root_schema_for::() +} + +pub const DEFAULT_CONNECTION_URI_VARIABLE: &str = "CONNECTION_URI"; /// The parsed connector configuration. This data type is an enum with cases for each supported /// version. 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..4e9de024d 100644 --- a/crates/configuration/src/lib.rs +++ b/crates/configuration/src/lib.rs @@ -3,12 +3,57 @@ 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..50ba7c64c --- /dev/null +++ b/crates/configuration/src/tests.rs @@ -0,0 +1,99 @@ +//! 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(); +} +// +// #[tokio::test] +// async fn get_latest_schema() { +// let schema = crate::generate_latest_schema(); +// insta::assert_json_snapshot!(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 introspection_is_idempotent( + connection_string: &str, + chinook_ndc_metadata_path: impl AsRef + Sync, +) -> anyhow::Result<()> { + let parsed_configuration = crate::parse_configuration(&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..336513ad6 --- /dev/null +++ b/crates/configuration/src/version3/tests.rs @@ -0,0 +1,117 @@ +//! 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() { + // TODO: have this respect the version-agnostic configuration interface? + 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/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 index 3f94e5c1b..5595c73ac 100644 --- 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 @@ -26,9 +26,7 @@ } }, "uniquenessConstraints": { - "PK_Album": [ - "AlbumId" - ] + "PK_Album": ["AlbumId"] }, "foreignRelations": { "FK_AlbumArtistId": { @@ -57,9 +55,7 @@ } }, "uniquenessConstraints": { - "PK_Artist": [ - "ArtistId" - ] + "PK_Artist": ["ArtistId"] }, "foreignRelations": {} }, @@ -123,9 +119,7 @@ } }, "uniquenessConstraints": { - "PK_Track": [ - "TrackId" - ] + "PK_Track": ["TrackId"] }, "foreignRelations": { "FK_TrackAlbumId": { 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 8fc7ab874..32d97792b 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.199" 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 - }) - ) - } - } -} From db0531b22460c73d07fd88f8555c17b0a3bbeca0 Mon Sep 17 00:00:00 2001 From: Philip Lykke Carlsen Date: Tue, 7 May 2024 18:48:00 +0200 Subject: [PATCH 15/18] a little --- crates/configuration/src/lib.rs | 3 ++- crates/configuration/src/tests.rs | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/crates/configuration/src/lib.rs b/crates/configuration/src/lib.rs index 4e9de024d..a5ee2a29e 100644 --- a/crates/configuration/src/lib.rs +++ b/crates/configuration/src/lib.rs @@ -52,8 +52,9 @@ pub mod common { /// 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("../../"); d.push(ndc_metadata_path); + d } } diff --git a/crates/configuration/src/tests.rs b/crates/configuration/src/tests.rs index 50ba7c64c..fb71705f7 100644 --- a/crates/configuration/src/tests.rs +++ b/crates/configuration/src/tests.rs @@ -71,7 +71,10 @@ pub async fn introspection_is_idempotent( connection_string: &str, chinook_ndc_metadata_path: impl AsRef + Sync, ) -> anyhow::Result<()> { - let parsed_configuration = crate::parse_configuration(&chinook_ndc_metadata_path).await?; + 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(), From 4929d6d4d96af9143601ff2279dd4683fce550e8 Mon Sep 17 00:00:00 2001 From: Philip Lykke Carlsen Date: Wed, 8 May 2024 13:16:33 +0200 Subject: [PATCH 16/18] tidy --- crates/configuration/src/tests.rs | 6 ------ crates/configuration/src/version3/tests.rs | 1 - 2 files changed, 7 deletions(-) diff --git a/crates/configuration/src/tests.rs b/crates/configuration/src/tests.rs index fb71705f7..af58672e9 100644 --- a/crates/configuration/src/tests.rs +++ b/crates/configuration/src/tests.rs @@ -54,12 +54,6 @@ async fn cockroach_current_only_configure_is_idempotent() { .await .unwrap(); } -// -// #[tokio::test] -// async fn get_latest_schema() { -// let schema = crate::generate_latest_schema(); -// insta::assert_json_snapshot!(schema); -// } // Tests that configuration generation has not changed. // diff --git a/crates/configuration/src/version3/tests.rs b/crates/configuration/src/version3/tests.rs index 336513ad6..3da94c157 100644 --- a/crates/configuration/src/version3/tests.rs +++ b/crates/configuration/src/version3/tests.rs @@ -19,7 +19,6 @@ use crate::common; #[tokio::test] async fn get_configuration_schema() { - // TODO: have this respect the version-agnostic configuration interface? let schema = schemars::schema_for!(RawConfiguration); insta::assert_json_snapshot!(schema); } From 865bb8226585d8cded9ceb627a253c1b17764790 Mon Sep 17 00:00:00 2001 From: Philip Lykke Carlsen Date: Wed, 8 May 2024 13:54:17 +0200 Subject: [PATCH 17/18] Docs --- crates/configuration/src/configuration.rs | 32 ++++++++++++++--------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/crates/configuration/src/configuration.rs b/crates/configuration/src/configuration.rs index 1cde46179..72ea2bcbe 100644 --- a/crates/configuration/src/configuration.rs +++ b/crates/configuration/src/configuration.rs @@ -22,16 +22,18 @@ pub fn generate_latest_schema() -> RootSchema { pub const DEFAULT_CONNECTION_URI_VARIABLE: &str = "CONNECTION_URI"; -/// The parsed connector configuration. This data type is an enum with cases for each supported -/// version. +/// The 'ParsedConfiguration' type models the various concrete configuration formats that are +/// currently supported. /// -/// It supports various uses: +/// Introducing a breaking configuration format change involves adding a new case to this type. /// -/// * 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) +/// '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))}'. +/// +/// 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), @@ -44,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, From dacf07a20ae829a920d4bd84835e491af8d7bd44 Mon Sep 17 00:00:00 2001 From: Philip Lykke Carlsen Date: Wed, 8 May 2024 13:56:22 +0200 Subject: [PATCH 18/18] Docs --- crates/configuration/src/configuration.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/crates/configuration/src/configuration.rs b/crates/configuration/src/configuration.rs index 72ea2bcbe..4f0f173fa 100644 --- a/crates/configuration/src/configuration.rs +++ b/crates/configuration/src/configuration.rs @@ -95,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, @@ -116,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) => {