diff --git a/query-engine/connector-test-kit-rs/query-tests-setup/src/config.rs b/query-engine/connector-test-kit-rs/query-tests-setup/src/config.rs index 26d5161dbb5..883a02d9374 100644 --- a/query-engine/connector-test-kit-rs/query-tests-setup/src/config.rs +++ b/query-engine/connector-test-kit-rs/query-tests-setup/src/config.rs @@ -44,7 +44,6 @@ pub struct TestConfig { #[derive(Debug, Default, Serialize, Deserialize)] pub(crate) struct DriverAdapterConfig { pub(crate) proxy_url: Option, - pub(crate) connection_string_override: Option, } const CONFIG_LOAD_FAILED: &str = r####" @@ -199,7 +198,8 @@ impl TestConfig { | Ok(ConnectorVersion::SqlServer(None)) | Ok(ConnectorVersion::MongoDb(None)) | Ok(ConnectorVersion::CockroachDb(None)) - | Ok(ConnectorVersion::Postgres(None)) => { + | Ok(ConnectorVersion::Postgres(None)) + | Ok(ConnectorVersion::Sqlite(None)) => { exit_with_message("The current test connector requires a version to be set to run."); } Ok(ConnectorVersion::Vitess(Some(_))) @@ -208,7 +208,7 @@ impl TestConfig { | Ok(ConnectorVersion::MongoDb(Some(_))) | Ok(ConnectorVersion::CockroachDb(Some(_))) | Ok(ConnectorVersion::Postgres(Some(_))) - | Ok(ConnectorVersion::Sqlite) => (), + | Ok(ConnectorVersion::Sqlite(Some(_))) => (), Err(err) => exit_with_message(&err.to_string()), } @@ -284,7 +284,7 @@ impl TestConfig { ConnectorVersion::Postgres(_) => &PostgresConnectorTag, ConnectorVersion::MySql(_) => &MySqlConnectorTag, ConnectorVersion::MongoDb(_) => &MongoDbConnectorTag, - ConnectorVersion::Sqlite => &SqliteConnectorTag, + ConnectorVersion::Sqlite(_) => &SqliteConnectorTag, ConnectorVersion::CockroachDb(_) => &CockroachDbConnectorTag, ConnectorVersion::Vitess(_) => &VitessConnectorTag, }; diff --git a/query-engine/connector-test-kit-rs/query-tests-setup/src/connector_tag/mod.rs b/query-engine/connector-test-kit-rs/query-tests-setup/src/connector_tag/mod.rs index ea9b35fe9ad..970fcb80b62 100644 --- a/query-engine/connector-test-kit-rs/query-tests-setup/src/connector_tag/mod.rs +++ b/query-engine/connector-test-kit-rs/query-tests-setup/src/connector_tag/mod.rs @@ -55,17 +55,6 @@ pub(crate) fn connection_string( is_multi_schema: bool, isolation_level: Option<&'static str>, ) -> String { - if let Some(Some(connection_string)) = test_config - .driver_adapter_config - .as_ref() - .map(|c| c.connection_string_override.as_ref()) - { - return connection_string - .to_owned() - .replace("{database}", database) - .replace("{isolation_level}", isolation_level.unwrap_or_default()); - } - let is_ci = test_config.is_ci; match version { ConnectorVersion::SqlServer(v) => { @@ -110,7 +99,7 @@ pub(crate) fn connection_string( Some(PostgresVersion::V12) if is_ci => { format!("postgresql://postgres:prisma@test-db-postgres-12:5432/{database}") } - Some(PostgresVersion::V13) if is_ci => { + Some(PostgresVersion::V13) | Some(PostgresVersion::NeonJs) | Some(PostgresVersion::PgJs) if is_ci => { format!("postgresql://postgres:prisma@test-db-postgres-13:5432/{database}") } Some(PostgresVersion::V14) if is_ci => { @@ -127,7 +116,9 @@ pub(crate) fn connection_string( Some(PostgresVersion::V10) => format!("postgresql://postgres:prisma@127.0.0.1:5432/{database}"), Some(PostgresVersion::V11) => format!("postgresql://postgres:prisma@127.0.0.1:5433/{database}"), Some(PostgresVersion::V12) => format!("postgresql://postgres:prisma@127.0.0.1:5434/{database}"), - Some(PostgresVersion::V13) => format!("postgresql://postgres:prisma@127.0.0.1:5435/{database}"), + Some(PostgresVersion::V13) | Some(PostgresVersion::NeonJs) | Some(PostgresVersion::PgJs) => { + format!("postgresql://postgres:prisma@127.0.0.1:5435/{database}") + } Some(PostgresVersion::V14) => format!("postgresql://postgres:prisma@127.0.0.1:5437/{database}"), Some(PostgresVersion::V15) => format!("postgresql://postgres:prisma@127.0.0.1:5438/{database}"), Some(PostgresVersion::PgBouncer) => { @@ -174,7 +165,7 @@ pub(crate) fn connection_string( } None => unreachable!("A versioned connector must have a concrete version to run."), }, - ConnectorVersion::Sqlite => { + ConnectorVersion::Sqlite(_) => { let workspace_root = std::env::var("WORKSPACE_ROOT") .unwrap_or_else(|_| ".".to_owned()) .trim_end_matches('/') @@ -210,6 +201,10 @@ pub(crate) fn connection_string( } ConnectorVersion::Vitess(Some(VitessVersion::V8_0)) => "mysql://root@localhost:33807/test".into(), + ConnectorVersion::Vitess(Some(VitessVersion::PlanetscaleJs)) => { + format!("mysql://root@127.0.0.1:3310/{database}") + } + ConnectorVersion::Vitess(None) => unreachable!("A versioned connector must have a concrete version to run."), } } @@ -222,7 +217,7 @@ pub enum ConnectorVersion { Postgres(Option), MySql(Option), MongoDb(Option), - Sqlite, + Sqlite(Option), CockroachDb(Option), Vitess(Option), } @@ -245,14 +240,14 @@ impl ConnectorVersion { (MongoDb(a), MongoDb(b)) => versions_match(a, b), (CockroachDb(a), CockroachDb(b)) => versions_match(a, b), (Vitess(a), Vitess(b)) => versions_match(a, b), - (Sqlite, Sqlite) => true, + (Sqlite(a), Sqlite(b)) => versions_match(a, b), (MongoDb(..), _) | (_, MongoDb(..)) | (SqlServer(..), _) | (_, SqlServer(..)) - | (Sqlite, _) - | (_, Sqlite) + | (Sqlite(..), _) + | (_, Sqlite(..)) | (CockroachDb(..), _) | (_, CockroachDb(..)) | (Vitess(..), _) @@ -282,7 +277,10 @@ impl fmt::Display for ConnectorVersion { Some(v) => format!("MongoDB ({})", v.to_string()), None => "MongoDB (unknown)".to_string(), }, - Self::Sqlite => "SQLite".to_string(), + Self::Sqlite(v) => match v { + Some(v) => format!("SQLite ({})", v.to_string()), + None => "SQLite (unknown)".to_string(), + }, Self::Vitess(v) => match v { Some(v) => format!("Vitess ({v})"), None => "Vitess (unknown)".to_string(), @@ -353,7 +351,7 @@ impl TryFrom<(&str, Option<&str>)> for ConnectorVersion { #[track_caller] fn try_from((connector, version): (&str, Option<&str>)) -> Result { Ok(match connector.to_lowercase().as_str() { - "sqlite" => ConnectorVersion::Sqlite, + "sqlite" => ConnectorVersion::Sqlite(version.map(SqliteVersion::try_from).transpose()?), "sqlserver" => ConnectorVersion::SqlServer(version.map(SqlServerVersion::try_from).transpose()?), "cockroachdb" => ConnectorVersion::CockroachDb(version.map(CockroachDbVersion::try_from).transpose()?), "postgres" => ConnectorVersion::Postgres(version.map(PostgresVersion::try_from).transpose()?), diff --git a/query-engine/connector-test-kit-rs/query-tests-setup/src/connector_tag/postgres.rs b/query-engine/connector-test-kit-rs/query-tests-setup/src/connector_tag/postgres.rs index 039231a3f74..42d0a8c7afd 100644 --- a/query-engine/connector-test-kit-rs/query-tests-setup/src/connector_tag/postgres.rs +++ b/query-engine/connector-test-kit-rs/query-tests-setup/src/connector_tag/postgres.rs @@ -36,6 +36,8 @@ pub enum PostgresVersion { V14, V15, PgBouncer, + NeonJs, + PgJs, } impl TryFrom<&str> for PostgresVersion { @@ -51,6 +53,8 @@ impl TryFrom<&str> for PostgresVersion { "14" => Self::V14, "15" => Self::V15, "pgbouncer" => Self::PgBouncer, + "neon.js" => Self::NeonJs, + "pg.js" => Self::PgJs, _ => return Err(TestError::parse_error(format!("Unknown Postgres version `{s}`"))), }; @@ -69,6 +73,8 @@ impl ToString for PostgresVersion { PostgresVersion::V14 => "14", PostgresVersion::V15 => "15", PostgresVersion::PgBouncer => "pgbouncer", + PostgresVersion::NeonJs => "neon.js", + PostgresVersion::PgJs => "pg.js", } .to_owned() } diff --git a/query-engine/connector-test-kit-rs/query-tests-setup/src/connector_tag/sqlite.rs b/query-engine/connector-test-kit-rs/query-tests-setup/src/connector_tag/sqlite.rs index 16b16cf5ba2..7ecbe13bf2b 100644 --- a/query-engine/connector-test-kit-rs/query-tests-setup/src/connector_tag/sqlite.rs +++ b/query-engine/connector-test-kit-rs/query-tests-setup/src/connector_tag/sqlite.rs @@ -25,3 +25,37 @@ impl ConnectorTagInterface for SqliteConnectorTag { psl::builtin_connectors::SQLITE.capabilities() } } + +#[derive(Clone, Debug, PartialEq, Eq)] +pub enum SqliteVersion { + V3, + LibsqlJS, +} + +impl Default for SqliteVersion { + fn default() -> Self { + Self::V3 + } +} + +impl fmt::Display for SqliteVersion { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + SqliteVersion::V3 => write!(f, "3"), + SqliteVersion::LibsqlJS => write!(f, "libsql.js"), + } + } +} + +impl TryFrom<&str> for SqliteVersion { + type Error = TestError; + + fn try_from(s: &str) -> Result { + let version = match s { + "3" => Self::V3, + "libsql.js" => Self::LibsqlJS, + _ => return Err(TestError::parse_error(format!("Unknown SQLite version `{s}`"))), + }; + Ok(version) + } +} diff --git a/query-engine/connector-test-kit-rs/query-tests-setup/src/connector_tag/vitess.rs b/query-engine/connector-test-kit-rs/query-tests-setup/src/connector_tag/vitess.rs index 0376f45abbc..837fbd1e70b 100644 --- a/query-engine/connector-test-kit-rs/query-tests-setup/src/connector_tag/vitess.rs +++ b/query-engine/connector-test-kit-rs/query-tests-setup/src/connector_tag/vitess.rs @@ -34,6 +34,8 @@ impl ConnectorTagInterface for VitessConnectorTag { #[derive(Debug, Clone, Copy, PartialEq)] pub enum VitessVersion { V8_0, + // The planetscale driver adapter + PlanetscaleJs, } impl FromStr for VitessVersion { @@ -42,6 +44,7 @@ impl FromStr for VitessVersion { fn from_str(s: &str) -> Result { let version = match s { "8.0" => Self::V8_0, + "planetscale.js" => Self::PlanetscaleJs, _ => return Err(TestError::parse_error(format!("Unknown Vitess version `{s}`"))), }; @@ -53,6 +56,7 @@ impl Display for VitessVersion { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { Self::V8_0 => write!(f, "8.0"), + Self::PlanetscaleJs => write!(f, "planetscale.js"), } } } diff --git a/query-engine/connector-test-kit-rs/test-configs/neon-ws-postgres13 b/query-engine/connector-test-kit-rs/test-configs/neon-ws-postgres13 index 2ad79ea2f29..581455d2097 100644 --- a/query-engine/connector-test-kit-rs/test-configs/neon-ws-postgres13 +++ b/query-engine/connector-test-kit-rs/test-configs/neon-ws-postgres13 @@ -1,6 +1,6 @@ { "connector": "postgres", - "version": "13", + "version": "neon.js", "driver_adapter": "neon:ws", "driver_adapter_config": { "proxy_url": "127.0.0.1:5488/v1" }, "external_test_executor": "default" diff --git a/query-engine/connector-test-kit-rs/test-configs/pg-postgres13 b/query-engine/connector-test-kit-rs/test-configs/pg-postgres13 index 00f0c75ed73..df715de1188 100644 --- a/query-engine/connector-test-kit-rs/test-configs/pg-postgres13 +++ b/query-engine/connector-test-kit-rs/test-configs/pg-postgres13 @@ -1,6 +1,6 @@ { "connector": "postgres", - "version": "13", + "version": "pg.js", "driver_adapter": "pg", "external_test_executor": "default" } \ No newline at end of file diff --git a/query-engine/connector-test-kit-rs/test-configs/planetscale b/query-engine/connector-test-kit-rs/test-configs/planetscale index a4ae5216dbc..834086322c9 100644 --- a/query-engine/connector-test-kit-rs/test-configs/planetscale +++ b/query-engine/connector-test-kit-rs/test-configs/planetscale @@ -1,10 +1,9 @@ { "connector": "vitess", - "version": "8.0", + "version": "planetscale.js", "driver_adapter": "planetscale", "driver_adapter_config": { - "proxy_url": "http://root:root@127.0.0.1:8085", - "connection_string_override": "mysql://root@127.0.0.1:3310/{database}" + "proxy_url": "http://root:root@127.0.0.1:8085" }, "external_test_executor": "default" } diff --git a/query-engine/connector-test-kit-rs/test-configs/sqlite b/query-engine/connector-test-kit-rs/test-configs/sqlite index cfbcc7e8829..092f9182ec9 100644 --- a/query-engine/connector-test-kit-rs/test-configs/sqlite +++ b/query-engine/connector-test-kit-rs/test-configs/sqlite @@ -1,2 +1,4 @@ { - "connector": "sqlite"} \ No newline at end of file + "connector": "sqlite", + "version": "3" +} \ No newline at end of file