#![cfg(feature = "postgresql")]
pub mod _test_common;
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, ormer::ModelEnum)]
pub enum ReproTaskKind {
Charge,
#[default]
Load,
Unload,
Transport,
}
#[derive(Debug, ormer::Model, Clone)]
#[table = "collect.schema_enum_cross_tasks_1"]
struct SchemaEnumTask {
#[primary]
id: i64,
name: String,
kind: ReproTaskKind,
}
async fn test_schema_enum_cross_schema_impl(
config: &_test_common::DbConfig,
) -> Result<(), Box<dyn std::error::Error>> {
if !matches!(config.0, ormer::DbType::PostgreSQL) {
return Ok(());
}
let db = _test_common::create_db_connection(config).await?;
let _ = db.drop_table::<SchemaEnumTask>().execute().await;
db.create_table::<SchemaEnumTask>()
.execute()
.await
.expect("first create_table on schema-qualified table should succeed");
db.validate_table::<SchemaEnumTask>()
.await
.expect("validate_table must resolve enum type via column udt_schema, not table schema");
db.create_table::<SchemaEnumTask>()
.execute()
.await
.expect("second create_table (validate path) must pass");
let _ = db.drop_table::<SchemaEnumTask>().execute().await;
Ok(())
}
test_on_all_dbs_result!(test_schema_enum_cross_schema_impl);