second test case
@@ -277,3 +277,51 @@ async fn introspecting_a_table_enums_should_work(api: &TestApi) {
custom_assert(&result3, dm);
custom_assert(&result4, dm);
}
+
+#[test_one_connector(connector = "postgres")]
+async fn introspecting_a_table_enums_should_return_alphabetically_even_when_in_different_order(api: &TestApi) {
+ let sql1 = format!("CREATE Type Color as ENUM ( 'black', 'white')");
+ let sql2 = format!("CREATE Type Color2 as ENUM ( 'black2', 'white2')");
+
+ api.database().execute_raw(&sql2, &[]).await.unwrap();
+ api.database().execute_raw(&sql1, &[]).await.unwrap();
+
+ api.barrel()
+ .execute(|migration| {
+ migration.create_table("Book", |t| {
+ t.add_column("id", types::primary());
+ t.inject_custom("color2 Color2 Not Null");
+ t.inject_custom("color Color Not Null");
+ });
+ })
+ .await;
+
+ let dm = r#"
+ model Book {
+ color String
+ color2 String
+ id Int @default(autoincrement()) @id
+ }
+
+ enum color{
+ black
+ white
+ }
+
+ enum color2{
+ black2
+ white2
+ }
+ "#;
+
+ let result = dbg!(api.introspect().await);
+ let result1 = dbg!(api.introspect().await);
+ let result2 = dbg!(api.introspect().await);
+ let result3 = dbg!(api.introspect().await);
+ let result4 = dbg!(api.introspect().await);
+ custom_assert(&result, dm);
+ custom_assert(&result1, dm);
+ custom_assert(&result2, dm);
+ custom_assert(&result3, dm);
+ custom_assert(&result4, dm);
+}
