use crate::{
db::{
access::{AccessPlanError, validate_access_structure_model},
executor::EntityAuthority,
query::plan::AccessPlannedQuery,
schema::SchemaInfo,
},
error::InternalError,
};
fn executor_plan_schema(authority: EntityAuthority) -> Result<SchemaInfo, InternalError> {
let entity_path = authority.entity_path();
SchemaInfo::from_entity_model(authority.model()).map_err(|err| {
InternalError::query_invariant(format!("entity schema invalid for {entity_path}: {err}"))
})
}
pub(in crate::db::executor) fn validate_executor_plan_for_authority(
authority: EntityAuthority,
plan: &AccessPlannedQuery,
) -> Result<(), InternalError> {
let schema = executor_plan_schema(authority)?;
validate_access_structure_model(&schema, authority.model(), &plan.access)
.map_err(AccessPlanError::into_internal_error)?;
Ok(())
}