diesel-rs/diesel · error
Failed to create trigger
Error message
Failed to create trigger
What it means
Registering the `diesel_manage_updated_at` helper failed while executing its trigger-creating SQL. The offending input is the SQLite connection or database schema state that rejected the trigger creation.
Solutions
- Ensure the database is writable and not locked
- Check for a conflicting trigger on the target table
- Register the function outside an active transaction if required
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at diesel/src/sqlite/connection/mod.rs:1750 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of diesel-rs/diesel@6fa6ed01b2 (2026-09-07).
Data as JSON: /api/errors/15b88133492eb980.
Report an issue: GitHub.
Appendix: source
Thrown at diesel/src/sqlite/connection/mod.rs:1750
})
}
fn register_diesel_sql_functions(&self) -> QueryResult<()> {
use crate::sql_types::{Integer, Text};
// This function has side effects (creates triggers), so it should not
// be deterministic. We use DIRECTONLY to prevent it from being called
// from malicious schema objects in untrusted databases.
functions::register::<Text, Integer, _, _, _>(
&self.raw_connection,
"diesel_manage_updated_at",
SqliteFunctionBehavior::DIRECTONLY,
|conn, table_name: String| {
conn.exec(&alloc::format!(
include_str!("diesel_manage_updated_at.sql"),
table_name = table_name
))
.expect("Failed to create trigger");
0 // have to return *something*
},
)
}
fn establish_inner(database_url: &str) -> Result<SqliteConnection, ConnectionError> {
use crate::result::ConnectionError::CouldntSetupConfiguration;
let raw_connection = RawConnection::establish(database_url)?;
let conn = Self {
statement_cache: StatementCache::new(),
raw_connection,
transaction_state: AnsiTransactionManager::default(),
metadata_lookup: (),
instrumentation: DynInstrumentation::none(),
serialized_data: Vec::new(),
};
conn.register_diesel_sql_functions()
.map_err(CouldntSetupConfiguration)?;View on GitHub (pinned to 6fa6ed01b2)