|
@@ -1,10 +1,14 @@
|
|
-use crate::{db::DBConnection, schema::AssocData, DBResult};
|
|
|
|
|
|
+use crate::{
|
|
|
|
+ db::{Connection, StatementRow},
|
|
|
|
+ schema::AssocData,
|
|
|
|
+ DBResult,
|
|
|
|
+};
|
|
|
|
|
|
use super::{Datum, Entity, EntityPart, EntityPartList, EntityPartVisitor};
|
|
use super::{Datum, Entity, EntityPart, EntityPartList, EntityPartVisitor};
|
|
|
|
|
|
macro_rules! build_datum {
|
|
macro_rules! build_datum {
|
|
($conn:ident,$local_id:ident,$stmt:ident,$idx:ident,$d:ident,$t:ident) => {
|
|
($conn:ident,$local_id:ident,$stmt:ident,$idx:ident,$d:ident,$t:ident) => {
|
|
- let ($d, $idx) = <$t::Datum as Datum>::build_from(
|
|
|
|
|
|
+ let $d = <$t::Datum as Datum>::build_from(
|
|
AssocData {
|
|
AssocData {
|
|
conn: $conn.clone(),
|
|
conn: $conn.clone(),
|
|
local_name: <$t::Entity as Entity>::entity_name(),
|
|
local_name: <$t::Entity as Entity>::entity_name(),
|
|
@@ -12,7 +16,7 @@ macro_rules! build_datum {
|
|
local_id: $local_id,
|
|
local_id: $local_id,
|
|
},
|
|
},
|
|
$stmt,
|
|
$stmt,
|
|
- $idx,
|
|
|
|
|
|
+ &mut $idx,
|
|
)?;
|
|
)?;
|
|
};
|
|
};
|
|
}
|
|
}
|
|
@@ -20,10 +24,7 @@ macro_rules! build_datum {
|
|
impl EntityPartList for () {
|
|
impl EntityPartList for () {
|
|
type DatumList = ();
|
|
type DatumList = ();
|
|
|
|
|
|
- fn build_datum_list(
|
|
|
|
- _conn: &DBConnection,
|
|
|
|
- _stmt: &mut sqlite::Statement<'static>,
|
|
|
|
- ) -> DBResult<Self::DatumList> {
|
|
|
|
|
|
+ fn build_datum_list(_conn: &Connection, _stmt: &mut StatementRow) -> DBResult<Self::DatumList> {
|
|
Ok(())
|
|
Ok(())
|
|
}
|
|
}
|
|
|
|
|
|
@@ -34,15 +35,11 @@ impl EntityPartList for () {
|
|
impl<P0: EntityPart> EntityPartList for P0 {
|
|
impl<P0: EntityPart> EntityPartList for P0 {
|
|
type DatumList = P0::Datum;
|
|
type DatumList = P0::Datum;
|
|
|
|
|
|
- fn build_datum_list(
|
|
|
|
- conn: &DBConnection,
|
|
|
|
- stmt: &mut sqlite::Statement<'static>,
|
|
|
|
- ) -> DBResult<Self::DatumList> {
|
|
|
|
|
|
+ fn build_datum_list(conn: &Connection, stmt: &mut StatementRow) -> DBResult<Self::DatumList> {
|
|
let local_id: i64 = stmt.read(0)?;
|
|
let local_id: i64 = stmt.read(0)?;
|
|
- let idx = 1; // starting index is 1 since index 0 is the ID
|
|
|
|
|
|
+ let mut idx = 1; // starting index is 1 since index 0 is the ID
|
|
build_datum!(conn, local_id, stmt, idx, d0, P0);
|
|
build_datum!(conn, local_id, stmt, idx, d0, P0);
|
|
|
|
|
|
- let _ = idx;
|
|
|
|
Ok(d0)
|
|
Ok(d0)
|
|
}
|
|
}
|
|
|
|
|
|
@@ -57,10 +54,7 @@ impl<P0: EntityPart> EntityPartList for P0 {
|
|
impl<P0: EntityPart> EntityPartList for (P0,) {
|
|
impl<P0: EntityPart> EntityPartList for (P0,) {
|
|
type DatumList = P0::Datum;
|
|
type DatumList = P0::Datum;
|
|
|
|
|
|
- fn build_datum_list(
|
|
|
|
- conn: &DBConnection,
|
|
|
|
- stmt: &mut sqlite::Statement<'static>,
|
|
|
|
- ) -> DBResult<Self::DatumList> {
|
|
|
|
|
|
+ fn build_datum_list(conn: &Connection, stmt: &mut StatementRow) -> DBResult<Self::DatumList> {
|
|
<P0 as EntityPartList>::build_datum_list(conn, stmt)
|
|
<P0 as EntityPartList>::build_datum_list(conn, stmt)
|
|
}
|
|
}
|
|
|
|
|
|
@@ -75,16 +69,12 @@ impl<P0: EntityPart> EntityPartList for (P0,) {
|
|
impl<P0: EntityPart, P1: EntityPart> EntityPartList for (P0, P1) {
|
|
impl<P0: EntityPart, P1: EntityPart> EntityPartList for (P0, P1) {
|
|
type DatumList = (P0::Datum, P1::Datum);
|
|
type DatumList = (P0::Datum, P1::Datum);
|
|
|
|
|
|
- fn build_datum_list(
|
|
|
|
- conn: &DBConnection,
|
|
|
|
- stmt: &mut sqlite::Statement<'static>,
|
|
|
|
- ) -> DBResult<Self::DatumList> {
|
|
|
|
|
|
+ fn build_datum_list(conn: &Connection, stmt: &mut StatementRow) -> DBResult<Self::DatumList> {
|
|
let local_id: i64 = stmt.read(0)?;
|
|
let local_id: i64 = stmt.read(0)?;
|
|
- let idx = 1; // starting index is 1 since index 0 is the ID
|
|
|
|
|
|
+ let mut idx = 1; // starting index is 1 since index 0 is the ID
|
|
build_datum!(conn, local_id, stmt, idx, d0, P0);
|
|
build_datum!(conn, local_id, stmt, idx, d0, P0);
|
|
build_datum!(conn, local_id, stmt, idx, d1, P1);
|
|
build_datum!(conn, local_id, stmt, idx, d1, P1);
|
|
|
|
|
|
- let _ = idx;
|
|
|
|
Ok((d0, d1))
|
|
Ok((d0, d1))
|
|
}
|
|
}
|
|
|
|
|
|
@@ -101,17 +91,13 @@ impl<P0: EntityPart, P1: EntityPart> EntityPartList for (P0, P1) {
|
|
impl<P0: EntityPart, P1: EntityPart, P2: EntityPart> EntityPartList for (P0, P1, P2) {
|
|
impl<P0: EntityPart, P1: EntityPart, P2: EntityPart> EntityPartList for (P0, P1, P2) {
|
|
type DatumList = (P0::Datum, P1::Datum, P2::Datum);
|
|
type DatumList = (P0::Datum, P1::Datum, P2::Datum);
|
|
|
|
|
|
- fn build_datum_list(
|
|
|
|
- conn: &DBConnection,
|
|
|
|
- stmt: &mut sqlite::Statement<'static>,
|
|
|
|
- ) -> DBResult<Self::DatumList> {
|
|
|
|
|
|
+ fn build_datum_list(conn: &Connection, stmt: &mut StatementRow) -> DBResult<Self::DatumList> {
|
|
let local_id: i64 = stmt.read(0)?;
|
|
let local_id: i64 = stmt.read(0)?;
|
|
- let idx = 1; // starting index is 1 since index 0 is the ID
|
|
|
|
|
|
+ let mut idx = 1; // starting index is 1 since index 0 is the ID
|
|
build_datum!(conn, local_id, stmt, idx, d0, P0);
|
|
build_datum!(conn, local_id, stmt, idx, d0, P0);
|
|
build_datum!(conn, local_id, stmt, idx, d1, P1);
|
|
build_datum!(conn, local_id, stmt, idx, d1, P1);
|
|
build_datum!(conn, local_id, stmt, idx, d2, P2);
|
|
build_datum!(conn, local_id, stmt, idx, d2, P2);
|
|
|
|
|
|
- let _ = idx;
|
|
|
|
Ok((d0, d1, d2))
|
|
Ok((d0, d1, d2))
|
|
}
|
|
}
|
|
|
|
|
|
@@ -132,18 +118,14 @@ impl<P0: EntityPart, P1: EntityPart, P2: EntityPart, P3: EntityPart> EntityPartL
|
|
{
|
|
{
|
|
type DatumList = (P0::Datum, P1::Datum, P2::Datum, P3::Datum);
|
|
type DatumList = (P0::Datum, P1::Datum, P2::Datum, P3::Datum);
|
|
|
|
|
|
- fn build_datum_list(
|
|
|
|
- conn: &DBConnection,
|
|
|
|
- stmt: &mut sqlite::Statement<'static>,
|
|
|
|
- ) -> DBResult<Self::DatumList> {
|
|
|
|
|
|
+ fn build_datum_list(conn: &Connection, stmt: &mut StatementRow) -> DBResult<Self::DatumList> {
|
|
let local_id: i64 = stmt.read(0)?;
|
|
let local_id: i64 = stmt.read(0)?;
|
|
- let idx = 1; // starting index is 1 since index 0 is the ID
|
|
|
|
|
|
+ let mut idx = 1; // starting index is 1 since index 0 is the ID
|
|
build_datum!(conn, local_id, stmt, idx, d0, P0);
|
|
build_datum!(conn, local_id, stmt, idx, d0, P0);
|
|
build_datum!(conn, local_id, stmt, idx, d1, P1);
|
|
build_datum!(conn, local_id, stmt, idx, d1, P1);
|
|
build_datum!(conn, local_id, stmt, idx, d2, P2);
|
|
build_datum!(conn, local_id, stmt, idx, d2, P2);
|
|
build_datum!(conn, local_id, stmt, idx, d3, P3);
|
|
build_datum!(conn, local_id, stmt, idx, d3, P3);
|
|
|
|
|
|
- let _ = idx;
|
|
|
|
Ok((d0, d1, d2, d3))
|
|
Ok((d0, d1, d2, d3))
|
|
}
|
|
}
|
|
|
|
|
|
@@ -166,19 +148,15 @@ impl<P0: EntityPart, P1: EntityPart, P2: EntityPart, P3: EntityPart, P4: EntityP
|
|
{
|
|
{
|
|
type DatumList = (P0::Datum, P1::Datum, P2::Datum, P3::Datum, P4::Datum);
|
|
type DatumList = (P0::Datum, P1::Datum, P2::Datum, P3::Datum, P4::Datum);
|
|
|
|
|
|
- fn build_datum_list(
|
|
|
|
- conn: &DBConnection,
|
|
|
|
- stmt: &mut sqlite::Statement<'static>,
|
|
|
|
- ) -> DBResult<Self::DatumList> {
|
|
|
|
|
|
+ fn build_datum_list(conn: &Connection, stmt: &mut StatementRow) -> DBResult<Self::DatumList> {
|
|
let local_id: i64 = stmt.read(0)?;
|
|
let local_id: i64 = stmt.read(0)?;
|
|
- let idx = 1; // starting index is 1 since index 0 is the ID
|
|
|
|
|
|
+ let mut idx = 1; // starting index is 1 since index 0 is the ID
|
|
build_datum!(conn, local_id, stmt, idx, d0, P0);
|
|
build_datum!(conn, local_id, stmt, idx, d0, P0);
|
|
build_datum!(conn, local_id, stmt, idx, d1, P1);
|
|
build_datum!(conn, local_id, stmt, idx, d1, P1);
|
|
build_datum!(conn, local_id, stmt, idx, d2, P2);
|
|
build_datum!(conn, local_id, stmt, idx, d2, P2);
|
|
build_datum!(conn, local_id, stmt, idx, d3, P3);
|
|
build_datum!(conn, local_id, stmt, idx, d3, P3);
|
|
build_datum!(conn, local_id, stmt, idx, d4, P4);
|
|
build_datum!(conn, local_id, stmt, idx, d4, P4);
|
|
|
|
|
|
- let _ = idx;
|
|
|
|
Ok((d0, d1, d2, d3, d4))
|
|
Ok((d0, d1, d2, d3, d4))
|
|
}
|
|
}
|
|
|
|
|
|
@@ -216,12 +194,9 @@ impl<
|
|
P5::Datum,
|
|
P5::Datum,
|
|
);
|
|
);
|
|
|
|
|
|
- fn build_datum_list(
|
|
|
|
- conn: &DBConnection,
|
|
|
|
- stmt: &mut sqlite::Statement<'static>,
|
|
|
|
- ) -> DBResult<Self::DatumList> {
|
|
|
|
|
|
+ fn build_datum_list(conn: &Connection, stmt: &mut StatementRow) -> DBResult<Self::DatumList> {
|
|
let local_id: i64 = stmt.read(0)?;
|
|
let local_id: i64 = stmt.read(0)?;
|
|
- let idx = 1; // starting index is 1 since index 0 is the ID
|
|
|
|
|
|
+ let mut idx = 1; // starting index is 1 since index 0 is the ID
|
|
build_datum!(conn, local_id, stmt, idx, d0, P0);
|
|
build_datum!(conn, local_id, stmt, idx, d0, P0);
|
|
build_datum!(conn, local_id, stmt, idx, d1, P1);
|
|
build_datum!(conn, local_id, stmt, idx, d1, P1);
|
|
build_datum!(conn, local_id, stmt, idx, d2, P2);
|
|
build_datum!(conn, local_id, stmt, idx, d2, P2);
|
|
@@ -229,7 +204,6 @@ impl<
|
|
build_datum!(conn, local_id, stmt, idx, d4, P4);
|
|
build_datum!(conn, local_id, stmt, idx, d4, P4);
|
|
build_datum!(conn, local_id, stmt, idx, d5, P5);
|
|
build_datum!(conn, local_id, stmt, idx, d5, P5);
|
|
|
|
|
|
- let _ = idx;
|
|
|
|
Ok((d0, d1, d2, d3, d4, d5))
|
|
Ok((d0, d1, d2, d3, d4, d5))
|
|
}
|
|
}
|
|
|
|
|