diff --git a/query-engine/prisma/src/tests/type_mappings/mysql_types.rs b/query-engine/prisma/src/tests/type_mappings/mysql_types.rs index d089fa137136..246acddaa47d 100644 --- a/query-engine/prisma/src/tests/type_mappings/mysql_types.rs +++ b/query-engine/prisma/src/tests/type_mappings/mysql_types.rs @@ -273,7 +273,7 @@ async fn mysql_bit_columns_are_properly_mapped_to_signed_integers(api: &TestApi) Ok(()) } -#[test_each_connector(tags("mysql"), log = "debug")] +#[test_each_connector(tags("mysql"))] async fn mysql_floats_do_not_lose_precision(api: &TestApi) -> TestResult { api.execute_sql(CREATE_TYPES_TABLE).await?; @@ -313,3 +313,76 @@ async fn mysql_floats_do_not_lose_precision(api: &TestApi) -> TestResult { Ok(()) } + +#[test_each_connector(tags("mysql"), log = "debug")] +async fn all_mysql_identifier_types_work(api: &TestApi) -> TestResult { + let identifier_types = &[ + ("tinyint", "12", ""), + ("smallint", "350", ""), + ("int", "9002", ""), + ("bigint", "30000", ""), + ("decimal(4, 2)", "3.1", ""), + // ("float", "2.8", ""), + ("double", "0.1", ""), + ("real", "12.1", ""), + ("bit(32)", "4", ""), + ("boolean", "true", ""), + ("date", "\"2020-02-27T00:00:00.000Z\"", ""), + ("datetime", "\"2020-02-27T19:10:22.000Z\"", ""), + ("timestamp", "\"2020-02-27T19:11:22.000Z\"", ""), + // ("time", "\"1970-01-01T12:50:01.000Z\"", ""), + ("year", "2091", ""), + ("char(18)", "\"make dolphins easy\"", ""), + ("varchar(200)", "\"dolphins of varying characters\"", ""), + ("tinytext", "\"tiny dolphins\"", "(20)"), + ("text", "\"dolphins\"", "(100)"), + ("mediumtext", "\"medium dolphins\"", "(100)"), + ("longtext", "\"long dolphins\"", "(100)"), + ( + "enum('pollicle_dogs','jellicle_cats')", + "\"jellicle_cats\"", + "", + ), + // ("json", "\"{\\\"name\\\": null}\"", ""), + ]; + + let drop_table = r#"DROP TABLE IF EXISTS `pk_test`"#; + + for (identifier_type, identifier_value, prefix) in identifier_types { + for index_type in &["PRIMARY KEY", "CONSTRAINT UNIQUE INDEX"] { + let create_pk_table = format!( + r#"CREATE TABLE `pk_test` (id {} NOT NULL, {} (id{}))"#, + identifier_type, index_type, prefix + ); + api.execute_sql(drop_table).await?; + api.execute_sql(&create_pk_table).await?; + + let (_datamodel, engine) = api.introspect_and_start_query_engine().await?; + + let query = format!( + r#" + mutation {{ + createOnepk_test( + data: {{ + id: {} + }} + ) {{ + id + }} + }} + "#, + identifier_value + ); + + let response = engine.request(query).await; + + let expected_response = format!( + r#"{{"data":{{"createOnepk_test":{{"id":{}}}}}}}"#, + identifier_value + ); + assert_eq!(response.to_string(), expected_response); + } + } + + Ok(()) +} diff --git a/query-engine/prisma/src/tests/type_mappings/postgres_types.rs b/query-engine/prisma/src/tests/type_mappings/postgres_types.rs index a5a91557e8d2..9cb39f80cd73 100644 --- a/query-engine/prisma/src/tests/type_mappings/postgres_types.rs +++ b/query-engine/prisma/src/tests/type_mappings/postgres_types.rs @@ -497,7 +497,7 @@ async fn all_postgres_id_types_work(api: &TestApi) -> TestResult { ("boolean", "true"), ("inet", "\"127.0.0.4\""), // ("json", "\"{ \\\"isThisPrimaryKeyReallyJSON\\\": true }\""), - // ("jsonb", "\"{ \\\"isThisPrimaryKeyReallyJSON\\\": true }\""), + ("jsonb", "\"{ \\\"isThisPrimaryKeyReallyJSON\\\": true }\""), ]; let drop_table = r#"DROP TABLE IF EXISTS "prisma-tests"."pk_test""#; diff --git a/query-engine/prisma/src/tests/type_mappings/test_api.rs b/query-engine/prisma/src/tests/type_mappings/test_api.rs index 457263dfacb6..f7e9822abfae 100644 --- a/query-engine/prisma/src/tests/type_mappings/test_api.rs +++ b/query-engine/prisma/src/tests/type_mappings/test_api.rs @@ -12,6 +12,10 @@ pub struct TestApi { } impl TestApi { + pub fn connection(&self) -> &Quaint { + &self.connection + } + fn datasource(&self) -> String { format!( r#"