diff --git a/introspection-engine/connectors/sql-introspection-connector/tests/db_specific_introspection/postgres/enums_postgres.rs b/introspection-engine/connectors/sql-introspection-connector/tests/db_specific_introspection/postgres/enums_postgres.rs index 33014d7e710e..e56f8dcd3c2a 100644 --- a/introspection-engine/connectors/sql-introspection-connector/tests/db_specific_introspection/postgres/enums_postgres.rs +++ b/introspection-engine/connectors/sql-introspection-connector/tests/db_specific_introspection/postgres/enums_postgres.rs @@ -164,3 +164,35 @@ async fn introspecting_a_table_with_enum_default_values_should_work(api: &TestAp let result = dbg!(api.introspect().await); custom_assert(&result, dm); } + +#[test_each_connector(tags("postgres"))] +async fn introspecting_a_table_with_enum_default_values_that_look_like_booleans_should_work(api: &TestApi) { + let sql = format!("CREATE Type Truth as ENUM ( 'true', 'false', 'rumor')"); + + api.database().execute_raw(&sql, &[]).await.unwrap(); + + api.barrel() + .execute(|migration| { + migration.create_table("News", |t| { + t.add_column("id", types::primary()); + t.inject_custom("confirmed truth Not Null default 'true'"); + }); + }) + .await; + + let dm = r#" + model News { + confirmed truth @default(true) + id Int @default(autoincrement()) @id + } + + enum truth{ + false + rumor + true + } + "#; + + let result = dbg!(api.introspect().await); + custom_assert(&result, dm); +} diff --git a/libs/datamodel/core/src/common/value_validator.rs b/libs/datamodel/core/src/common/value_validator.rs index 9330b2e035d9..f96e0f77341e 100644 --- a/libs/datamodel/core/src/common/value_validator.rs +++ b/libs/datamodel/core/src/common/value_validator.rs @@ -182,6 +182,7 @@ impl ValueValidator { pub fn as_constant_literal(&self) -> Result { match &self.value { ast::Expression::ConstantValue(value, _) => Ok(value.to_string()), + ast::Expression::BooleanValue(value, _) => Ok(value.to_string()), ast::Expression::Any(value, _) => Ok(value.to_string()), _ => Err(self.construct_type_mismatch_error("constant literal")), }