SeaQL/sea-orm · error

Audit not supported for {} yet

Error message

Audit not supported for {} yet

What it means

Schema statements (e.g. TableCreateStatement) generated by the build_schema_stmt! macro implement audit() with todo!() under the rbac feature. Calling audit() on such a statement always panics with 'Audit not supported for {stmt} yet' — the rbac access-audit API has no implementation for schema DDL statements.

Source

Thrown at src/database/statement.rs:149

}

build_query_stmt!(sea_query::InsertStatement);
build_query_stmt!(sea_query::SelectStatement);
build_query_stmt!(sea_query::UpdateStatement);
build_query_stmt!(sea_query::DeleteStatement);
build_query_stmt!(sea_query::WithQuery);

macro_rules! build_schema_stmt {
    ($stmt: ty) => {
        impl StatementBuilder for $stmt {
            fn build(&self, db_backend: &DbBackend) -> Statement {
                let stmt = build_any_stmt!(self, db_backend);
                Statement::from_string(*db_backend, stmt)
            }

            #[cfg(feature = "rbac")]
            fn audit(&self) -> Result<QueryAccessAudit, AuditError> {
                todo!("Audit not supported for {} yet", stringify!($stmt))
            }
        }
    };
}

build_schema_stmt!(sea_query::TableCreateStatement);
build_schema_stmt!(sea_query::TableDropStatement);
build_schema_stmt!(sea_query::TableAlterStatement);
build_schema_stmt!(sea_query::TableRenameStatement);
build_schema_stmt!(sea_query::TableTruncateStatement);
build_schema_stmt!(sea_query::IndexCreateStatement);
build_schema_stmt!(sea_query::IndexDropStatement);
build_schema_stmt!(sea_query::ForeignKeyCreateStatement);
build_schema_stmt!(sea_query::ForeignKeyDropStatement);

macro_rules! build_type_stmt {
    ($stmt: ty) => {
        impl StatementBuilder for $stmt {

View on GitHub (pinned to e29bcd1b41)

Solutions

  1. Only call audit() on query statements that implement it; skip auditing for schema/DDL statements
  2. Guard the call with a statement-kind check and treat audit as not-applicable for DDL
  3. Implement (or request) audit support for the specific schema statement type in the library

Example fix

// before
let audit = schema_statement.audit()?; // panics via todo!
// after
let audit = if is_query_statement(&stmt) { Some(stmt.audit()?) } else { None };
Defensive patterns

Strategy: type-guard

Type guard

fn audit_supported(stmt_kind: StatementKind) -> bool {
    // schema statements (TableCreateStatement etc.) do not implement audit under rbac
    !matches!(stmt_kind, StatementKind::Schema(_))
}

Try / catch

// todo!() panics; never call on schema statements
if audit_supported(kind) { let a = stmt.audit()?; } // else skip

Prevention

When it happens

Trigger: Enabling the rbac feature and calling .audit() on a Database/SchemaStatement wrapping a TableCreateStatement (or any statement type built by build_schema_stmt! in src/database/statement.rs:150+).

Common situations: Auditing DDL/migration statements for access control; assuming audit() works uniformly across all statement kinds once the rbac feature is enabled.

Related errors


AI-assisted analysis of SeaQL/sea-orm@e29bcd1b41 (2026-09-10). Data as JSON: /api/errors/88b1f7c8dcdb7d0a. Report an issue: GitHub.