|
@@ -110,10 +110,7 @@ pub fn get_one_by_id<T: Entity>(db: &DB, id: <T as Entity>::ID) -> Option<WithID
|
|
let table_name = <T as Entity>::table_name();
|
|
let table_name = <T as Entity>::table_name();
|
|
let mut prepared = db
|
|
let mut prepared = db
|
|
.conn
|
|
.conn
|
|
- .prepare(&format!(
|
|
|
|
- "SELECT * FROM \"{}\" WHERE id = ?1",
|
|
|
|
- table_name
|
|
|
|
- ))
|
|
|
|
|
|
+ .prepare(&format!("SELECT * FROM \"{}\" WHERE id = ?1", table_name))
|
|
.ok()?;
|
|
.ok()?;
|
|
|
|
|
|
let result = prepared.query_row([&id], |row| {
|
|
let result = prepared.query_row([&id], |row| {
|
|
@@ -131,7 +128,7 @@ pub fn get_one_by_id<T: Entity>(db: &DB, id: <T as Entity>::ID) -> Option<WithID
|
|
pub fn add<T: Entity + serde::Serialize>(db: &DB, m: &T) -> Option<<T as Entity>::ID> {
|
|
pub fn add<T: Entity + serde::Serialize>(db: &DB, m: &T) -> Option<<T as Entity>::ID> {
|
|
let row = crate::model::store::serialize_as_row(m);
|
|
let row = crate::model::store::serialize_as_row(m);
|
|
|
|
|
|
- let placeholders = (0..(<T as Entity>::column_count()-1))
|
|
|
|
|
|
+ let placeholders = (0..(<T as Entity>::column_count() - 1))
|
|
.map(|n| format!("?{}", n + 1))
|
|
.map(|n| format!("?{}", n + 1))
|
|
.collect::<Vec<_>>()
|
|
.collect::<Vec<_>>()
|
|
.join(",");
|
|
.join(",");
|