|
@@ -230,42 +230,21 @@ impl<'l> QueryInterface<'l> {
|
|
|
&mut |stmt| {
|
|
|
val.bind_to(stmt, 1).ok()?;
|
|
|
|
|
|
- todo!()
|
|
|
+ let mut res = Vec::new();
|
|
|
+ loop {
|
|
|
+ let state = stmt.next().ok()?;
|
|
|
+ if state == sqlite::State::Done {
|
|
|
+ break;
|
|
|
+ }
|
|
|
|
|
|
- /*self.expect_one_result(stmt, &mut |stmt| {
|
|
|
let id: i64 = stmt.read(0).ok()?;
|
|
|
let mut rd = crate::model::load::RowDeserializer::from_row(stmt);
|
|
|
- Some(WithID::wrap(T::deserialize(&mut rd).ok()?, id))
|
|
|
- })*/
|
|
|
+ res.push(WithID::wrap(T::deserialize(&mut rd).ok()?, id));
|
|
|
+ }
|
|
|
+
|
|
|
+ Some(res)
|
|
|
},
|
|
|
)
|
|
|
-
|
|
|
- /*
|
|
|
- let mut prepared = self
|
|
|
- .db
|
|
|
- .conn
|
|
|
- .prepare(&format!(
|
|
|
- "SELECT * FROM \"{}\" WHERE \"{}\" = ?",
|
|
|
- table_name, column_name
|
|
|
- ))
|
|
|
- .ok()?;
|
|
|
-
|
|
|
- val.bind_to(&mut prepared, 1).ok()?;
|
|
|
-
|
|
|
- todo!();
|
|
|
- */
|
|
|
-
|
|
|
- /*let rows = prepared
|
|
|
- .query_map([&val], |row| {
|
|
|
- let mut deser = crate::model::load::RowDeserializer::from_row(row);
|
|
|
- Ok(WithID::wrap(
|
|
|
- T::deserialize(&mut deser)?,
|
|
|
- row.get(0).expect("can get rowid"),
|
|
|
- ))
|
|
|
- })
|
|
|
- .ok()?;
|
|
|
-
|
|
|
- Some(rows.map(|x| x.unwrap()).collect())*/
|
|
|
}
|
|
|
|
|
|
/// Add an entity to its table
|
|
@@ -283,7 +262,8 @@ impl<'l> QueryInterface<'l> {
|
|
|
.conn
|
|
|
.prepare(&format!(
|
|
|
"INSERT INTO \"{}\" VALUES (NULL, {}) RETURNING \"id\"",
|
|
|
- <T as Entity>::table_name(), placeholders
|
|
|
+ <T as Entity>::table_name(),
|
|
|
+ placeholders
|
|
|
))
|
|
|
.expect("")
|
|
|
},
|