add regex pattern validation via DuckDB

This commit is contained in:
rustmailer
2026-03-05 16:41:30 +08:00
parent 393b7361e8
commit 5f013ea173
2 changed files with 27 additions and 0 deletions
+15
View File
@@ -99,6 +99,21 @@ impl DuckDBManager {
Ok(())
}
pub fn validate_regex(&self, pattern: &str) -> BichonResult<()> {
let conn = self.conn()?;
let check_sql = "SELECT regexp_matches('', ?)";
if let Err(e) = conn
.prepare(check_sql)
.and_then(|mut stmt| stmt.execute([pattern]))
{
return Err(raise_error!(
format!("Invalid Regular Expression for DuckDB: {}", e).into(),
ErrorCode::InvalidParameter
));
}
Ok(())
}
pub fn delete_envelopes_by_account(&self, account_id: u64) -> BichonResult<usize> {
let mut conn = self.conn()?;
let tx = conn