test(db): cover delete/empty-changes/empty-history; clarify map_row naming
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -41,6 +41,7 @@ pub async fn history_for<'e, E>(
|
||||
where
|
||||
E: sqlx::PgExecutor<'e>,
|
||||
{
|
||||
// TODO: add LIMIT/keyset pagination before exposing history_for via the API.
|
||||
let rows = sqlx::query(
|
||||
"SELECT seq, at, actor_kind, actor_id, action, entity_type, entity_id, changes \
|
||||
FROM audit_log \
|
||||
@@ -60,7 +61,7 @@ fn map_row(row: sqlx::postgres::PgRow) -> Result<AuditEntry, sqlx::Error> {
|
||||
let at: time::OffsetDateTime = row.try_get("at")?;
|
||||
let actor_kind: String = row.try_get("actor_kind")?;
|
||||
let actor_id: Option<Uuid> = row.try_get("actor_id")?;
|
||||
let action: String = row.try_get("action")?;
|
||||
let action_str: String = row.try_get("action")?;
|
||||
let entity_type: String = row.try_get("entity_type")?;
|
||||
let entity_id: Uuid = row.try_get("entity_id")?;
|
||||
let changes: sqlx::types::Json<Vec<FieldChange>> = row.try_get("changes")?;
|
||||
@@ -77,8 +78,8 @@ fn map_row(row: sqlx::postgres::PgRow) -> Result<AuditEntry, sqlx::Error> {
|
||||
}
|
||||
};
|
||||
|
||||
let action = domain::AuditAction::from_db(&action)
|
||||
.ok_or_else(|| sqlx::Error::Decode(format!("unknown action: {action}").into()))?;
|
||||
let action = domain::AuditAction::from_db(&action_str)
|
||||
.ok_or_else(|| sqlx::Error::Decode(format!("unknown action: {action_str}").into()))?;
|
||||
|
||||
Ok(AuditEntry {
|
||||
seq,
|
||||
|
||||
Reference in New Issue
Block a user