|
@@ -3,11 +3,10 @@ use crate::{db::DBConnection, 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, $ctx:ident, $base_rowid:ident,$stmt:ident,$idx:ident,$d:ident,$t:ident) => {
|
|
|
|
|
|
+ ($conn:ident, $base_rowid:ident,$stmt:ident,$idx:ident,$d:ident,$t:ident) => {
|
|
let ($d, $idx) = <$t::Datum as Datum>::build_from(
|
|
let ($d, $idx) = <$t::Datum as Datum>::build_from(
|
|
AssocData {
|
|
AssocData {
|
|
conn: $conn.clone(),
|
|
conn: $conn.clone(),
|
|
- ctx: $ctx,
|
|
|
|
base_name: <$t::Entity as Entity>::entity_name(),
|
|
base_name: <$t::Entity as Entity>::entity_name(),
|
|
part_name: $t::part_name(),
|
|
part_name: $t::part_name(),
|
|
base_rowid: $base_rowid,
|
|
base_rowid: $base_rowid,
|
|
@@ -23,7 +22,6 @@ impl EntityPartList for () {
|
|
|
|
|
|
fn build_datum_list(
|
|
fn build_datum_list(
|
|
_conn: &DBConnection,
|
|
_conn: &DBConnection,
|
|
- _ctx: &'static str,
|
|
|
|
_stmt: &mut sqlite::Statement<'static>,
|
|
_stmt: &mut sqlite::Statement<'static>,
|
|
) -> DBResult<Self::DatumList> {
|
|
) -> DBResult<Self::DatumList> {
|
|
Ok(())
|
|
Ok(())
|
|
@@ -38,12 +36,11 @@ impl<P0: EntityPart> EntityPartList for P0 {
|
|
|
|
|
|
fn build_datum_list(
|
|
fn build_datum_list(
|
|
conn: &DBConnection,
|
|
conn: &DBConnection,
|
|
- ctx: &'static str,
|
|
|
|
stmt: &mut sqlite::Statement<'static>,
|
|
stmt: &mut sqlite::Statement<'static>,
|
|
) -> DBResult<Self::DatumList> {
|
|
) -> DBResult<Self::DatumList> {
|
|
let base_rowid: i64 = stmt.read(0)?;
|
|
let base_rowid: i64 = stmt.read(0)?;
|
|
let idx = 1; // starting index is 1 since index 0 is the ID
|
|
let idx = 1; // starting index is 1 since index 0 is the ID
|
|
- build_datum!(conn, ctx, base_rowid, stmt, idx, d0, P0);
|
|
|
|
|
|
+ build_datum!(conn, base_rowid, stmt, idx, d0, P0);
|
|
|
|
|
|
let _ = idx;
|
|
let _ = idx;
|
|
Ok(d0)
|
|
Ok(d0)
|
|
@@ -62,10 +59,9 @@ impl<P0: EntityPart> EntityPartList for (P0,) {
|
|
|
|
|
|
fn build_datum_list(
|
|
fn build_datum_list(
|
|
conn: &DBConnection,
|
|
conn: &DBConnection,
|
|
- ctx: &'static str,
|
|
|
|
stmt: &mut sqlite::Statement<'static>,
|
|
stmt: &mut sqlite::Statement<'static>,
|
|
) -> DBResult<Self::DatumList> {
|
|
) -> DBResult<Self::DatumList> {
|
|
- <P0 as EntityPartList>::build_datum_list(conn, ctx, stmt)
|
|
|
|
|
|
+ <P0 as EntityPartList>::build_datum_list(conn, stmt)
|
|
}
|
|
}
|
|
|
|
|
|
fn accept_part_visitor(v: &mut impl EntityPartVisitor) {
|
|
fn accept_part_visitor(v: &mut impl EntityPartVisitor) {
|
|
@@ -81,13 +77,12 @@ impl<P0: EntityPart, P1: EntityPart> EntityPartList for (P0, P1) {
|
|
|
|
|
|
fn build_datum_list(
|
|
fn build_datum_list(
|
|
conn: &DBConnection,
|
|
conn: &DBConnection,
|
|
- ctx: &'static str,
|
|
|
|
stmt: &mut sqlite::Statement<'static>,
|
|
stmt: &mut sqlite::Statement<'static>,
|
|
) -> DBResult<Self::DatumList> {
|
|
) -> DBResult<Self::DatumList> {
|
|
let base_rowid: i64 = stmt.read(0)?;
|
|
let base_rowid: i64 = stmt.read(0)?;
|
|
let idx = 1; // starting index is 1 since index 0 is the ID
|
|
let idx = 1; // starting index is 1 since index 0 is the ID
|
|
- build_datum!(conn, ctx, base_rowid, stmt, idx, d0, P0);
|
|
|
|
- build_datum!(conn, ctx, base_rowid, stmt, idx, d1, P1);
|
|
|
|
|
|
+ build_datum!(conn, base_rowid, stmt, idx, d0, P0);
|
|
|
|
+ build_datum!(conn, base_rowid, stmt, idx, d1, P1);
|
|
|
|
|
|
let _ = idx;
|
|
let _ = idx;
|
|
Ok((d0, d1))
|
|
Ok((d0, d1))
|
|
@@ -108,14 +103,13 @@ impl<P0: EntityPart, P1: EntityPart, P2: EntityPart> EntityPartList for (P0, P1,
|
|
|
|
|
|
fn build_datum_list(
|
|
fn build_datum_list(
|
|
conn: &DBConnection,
|
|
conn: &DBConnection,
|
|
- ctx: &'static str,
|
|
|
|
stmt: &mut sqlite::Statement<'static>,
|
|
stmt: &mut sqlite::Statement<'static>,
|
|
) -> DBResult<Self::DatumList> {
|
|
) -> DBResult<Self::DatumList> {
|
|
let base_rowid: i64 = stmt.read(0)?;
|
|
let base_rowid: i64 = stmt.read(0)?;
|
|
let idx = 1; // starting index is 1 since index 0 is the ID
|
|
let idx = 1; // starting index is 1 since index 0 is the ID
|
|
- build_datum!(conn, ctx, base_rowid, stmt, idx, d0, P0);
|
|
|
|
- build_datum!(conn, ctx, base_rowid, stmt, idx, d1, P1);
|
|
|
|
- build_datum!(conn, ctx, base_rowid, stmt, idx, d2, P2);
|
|
|
|
|
|
+ build_datum!(conn, base_rowid, stmt, idx, d0, P0);
|
|
|
|
+ build_datum!(conn, base_rowid, stmt, idx, d1, P1);
|
|
|
|
+ build_datum!(conn, base_rowid, stmt, idx, d2, P2);
|
|
|
|
|
|
let _ = idx;
|
|
let _ = idx;
|
|
Ok((d0, d1, d2))
|
|
Ok((d0, d1, d2))
|
|
@@ -140,15 +134,14 @@ impl<P0: EntityPart, P1: EntityPart, P2: EntityPart, P3: EntityPart> EntityPartL
|
|
|
|
|
|
fn build_datum_list(
|
|
fn build_datum_list(
|
|
conn: &DBConnection,
|
|
conn: &DBConnection,
|
|
- ctx: &'static str,
|
|
|
|
stmt: &mut sqlite::Statement<'static>,
|
|
stmt: &mut sqlite::Statement<'static>,
|
|
) -> DBResult<Self::DatumList> {
|
|
) -> DBResult<Self::DatumList> {
|
|
let base_rowid: i64 = stmt.read(0)?;
|
|
let base_rowid: i64 = stmt.read(0)?;
|
|
let idx = 1; // starting index is 1 since index 0 is the ID
|
|
let idx = 1; // starting index is 1 since index 0 is the ID
|
|
- build_datum!(conn, ctx, base_rowid, stmt, idx, d0, P0);
|
|
|
|
- build_datum!(conn, ctx, base_rowid, stmt, idx, d1, P1);
|
|
|
|
- build_datum!(conn, ctx, base_rowid, stmt, idx, d2, P2);
|
|
|
|
- build_datum!(conn, ctx, base_rowid, stmt, idx, d3, P3);
|
|
|
|
|
|
+ build_datum!(conn, base_rowid, stmt, idx, d0, P0);
|
|
|
|
+ build_datum!(conn, base_rowid, stmt, idx, d1, P1);
|
|
|
|
+ build_datum!(conn, base_rowid, stmt, idx, d2, P2);
|
|
|
|
+ build_datum!(conn, base_rowid, stmt, idx, d3, P3);
|
|
|
|
|
|
let _ = idx;
|
|
let _ = idx;
|
|
Ok((d0, d1, d2, d3))
|
|
Ok((d0, d1, d2, d3))
|
|
@@ -175,16 +168,15 @@ impl<P0: EntityPart, P1: EntityPart, P2: EntityPart, P3: EntityPart, P4: EntityP
|
|
|
|
|
|
fn build_datum_list(
|
|
fn build_datum_list(
|
|
conn: &DBConnection,
|
|
conn: &DBConnection,
|
|
- ctx: &'static str,
|
|
|
|
stmt: &mut sqlite::Statement<'static>,
|
|
stmt: &mut sqlite::Statement<'static>,
|
|
) -> DBResult<Self::DatumList> {
|
|
) -> DBResult<Self::DatumList> {
|
|
let base_rowid: i64 = stmt.read(0)?;
|
|
let base_rowid: i64 = stmt.read(0)?;
|
|
let idx = 1; // starting index is 1 since index 0 is the ID
|
|
let idx = 1; // starting index is 1 since index 0 is the ID
|
|
- build_datum!(conn, ctx, base_rowid, stmt, idx, d0, P0);
|
|
|
|
- build_datum!(conn, ctx, base_rowid, stmt, idx, d1, P1);
|
|
|
|
- build_datum!(conn, ctx, base_rowid, stmt, idx, d2, P2);
|
|
|
|
- build_datum!(conn, ctx, base_rowid, stmt, idx, d3, P3);
|
|
|
|
- build_datum!(conn, ctx, base_rowid, stmt, idx, d4, P4);
|
|
|
|
|
|
+ build_datum!(conn, base_rowid, stmt, idx, d0, P0);
|
|
|
|
+ build_datum!(conn, base_rowid, stmt, idx, d1, P1);
|
|
|
|
+ build_datum!(conn, base_rowid, stmt, idx, d2, P2);
|
|
|
|
+ build_datum!(conn, base_rowid, stmt, idx, d3, P3);
|
|
|
|
+ build_datum!(conn, base_rowid, stmt, idx, d4, P4);
|
|
|
|
|
|
let _ = idx;
|
|
let _ = idx;
|
|
Ok((d0, d1, d2, d3, d4))
|
|
Ok((d0, d1, d2, d3, d4))
|
|
@@ -226,17 +218,16 @@ impl<
|
|
|
|
|
|
fn build_datum_list(
|
|
fn build_datum_list(
|
|
conn: &DBConnection,
|
|
conn: &DBConnection,
|
|
- ctx: &'static str,
|
|
|
|
stmt: &mut sqlite::Statement<'static>,
|
|
stmt: &mut sqlite::Statement<'static>,
|
|
) -> DBResult<Self::DatumList> {
|
|
) -> DBResult<Self::DatumList> {
|
|
let base_rowid: i64 = stmt.read(0)?;
|
|
let base_rowid: i64 = stmt.read(0)?;
|
|
let idx = 1; // starting index is 1 since index 0 is the ID
|
|
let idx = 1; // starting index is 1 since index 0 is the ID
|
|
- build_datum!(conn, ctx, base_rowid, stmt, idx, d0, P0);
|
|
|
|
- build_datum!(conn, ctx, base_rowid, stmt, idx, d1, P1);
|
|
|
|
- build_datum!(conn, ctx, base_rowid, stmt, idx, d2, P2);
|
|
|
|
- build_datum!(conn, ctx, base_rowid, stmt, idx, d3, P3);
|
|
|
|
- build_datum!(conn, ctx, base_rowid, stmt, idx, d4, P4);
|
|
|
|
- build_datum!(conn, ctx, base_rowid, stmt, idx, d5, P5);
|
|
|
|
|
|
+ build_datum!(conn, base_rowid, stmt, idx, d0, P0);
|
|
|
|
+ build_datum!(conn, base_rowid, stmt, idx, d1, P1);
|
|
|
|
+ build_datum!(conn, base_rowid, stmt, idx, d2, P2);
|
|
|
|
+ build_datum!(conn, base_rowid, stmt, idx, d3, P3);
|
|
|
|
+ build_datum!(conn, base_rowid, stmt, idx, d4, P4);
|
|
|
|
+ build_datum!(conn, base_rowid, stmt, idx, d5, P5);
|
|
|
|
|
|
let _ = idx;
|
|
let _ = idx;
|
|
Ok((d0, d1, d2, d3, d4, d5))
|
|
Ok((d0, d1, d2, d3, d4, d5))
|