use rust_ef::provider::DbValue;
pub fn to_rusqlite_params(params: &[DbValue]) -> Vec<Box<dyn rusqlite::types::ToSql>> {
params
.iter()
.map(|v| match v {
DbValue::Null => Box::new(None::<String>) as Box<dyn rusqlite::types::ToSql>,
DbValue::Bool(b) => Box::new(*b),
DbValue::I16(n) => Box::new(*n),
DbValue::I32(n) => Box::new(*n),
DbValue::I64(n) => Box::new(*n),
DbValue::F32(n) => Box::new(*n as f64),
DbValue::F64(n) => Box::new(*n),
DbValue::String(s) => Box::new(s.clone()),
DbValue::Bytes(b) => Box::new(b.clone()),
DbValue::DateTime(dt) => Box::new(dt.to_rfc3339()),
DbValue::NaiveDateTime(ndt) => Box::new(ndt.to_string()),
DbValue::NaiveDate(nd) => Box::new(nd.to_string()),
DbValue::Uuid(u) => Box::new(u.to_string()),
DbValue::Decimal(d) => Box::new(d.to_string()),
})
.collect()
}