|
@@ -12,7 +12,7 @@ use crate::{
|
|
|
},
|
|
|
};
|
|
|
|
|
|
-use super::{ContainerEntityChange, Query};
|
|
|
+use super::{OutputContainer, Query};
|
|
|
|
|
|
/// Allow manipulation of an entire table.
|
|
|
pub(crate) struct TableComponent<E: Entity> {
|
|
@@ -416,7 +416,7 @@ impl<
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-/// Get an entity via a foreign key
|
|
|
+/// Get an entity via a foreign key.
|
|
|
pub(crate) struct ForeignComponent<FE: Entity, EP: EntityPart, Parent: Queryable> {
|
|
|
parent: Parent,
|
|
|
_ghost: std::marker::PhantomData<(FE, EP)>,
|
|
@@ -440,46 +440,11 @@ impl<FE: Entity, EP: EntityPart, Parent: Queryable> Clone for ForeignComponent<F
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-pub(crate) struct CanonicalForeignComponent<FE: Entity, EP: EntityPart, Parent: Queryable> {
|
|
|
- _ghost: std::marker::PhantomData<(FE, EP, Parent)>,
|
|
|
-}
|
|
|
-
|
|
|
-impl<FE: Entity, EP: EntityPart, Parent: Queryable> Clone
|
|
|
- for CanonicalForeignComponent<FE, EP, Parent>
|
|
|
-{
|
|
|
- fn clone(&self) -> Self {
|
|
|
- Self {
|
|
|
- _ghost: Default::default(),
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-impl<FE: Entity, EP: EntityPart, Parent: Queryable> Queryable
|
|
|
- for CanonicalForeignComponent<FE, EP, Parent>
|
|
|
-{
|
|
|
- type EntityOutput = FE;
|
|
|
- type OutputContainer = Option<Stored<FE>>;
|
|
|
- type StaticVersion = CanonicalForeignComponent<FE, EP, Parent::StaticVersion>;
|
|
|
-
|
|
|
- fn build(&self) -> Query {
|
|
|
- unreachable!()
|
|
|
- }
|
|
|
- fn bind(&self, _stmt: &mut StatementContext, _index: &mut i32) {
|
|
|
- unreachable!()
|
|
|
- }
|
|
|
- fn conn(&self) -> &Connection {
|
|
|
- unreachable!()
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-impl<FE: Entity, EP: EntityPart, Parent: Queryable> Queryable for ForeignComponent<FE, EP, Parent>
|
|
|
-where
|
|
|
- Parent::OutputContainer: ContainerEntityChange<Parent::EntityOutput, FE>,
|
|
|
-{
|
|
|
+impl<FE: Entity, EP: EntityPart, Parent: Queryable> Queryable for ForeignComponent<FE, EP, Parent> {
|
|
|
type EntityOutput = FE;
|
|
|
- type StaticVersion = CanonicalForeignComponent<FE, EP, Parent::StaticVersion>;
|
|
|
+ type StaticVersion = ForeignComponent<FE, EP, Parent::StaticVersion>;
|
|
|
type OutputContainer =
|
|
|
- <Parent::OutputContainer as ContainerEntityChange<Parent::EntityOutput, FE>>::Container;
|
|
|
+ <Parent::OutputContainer as OutputContainer<Parent::EntityOutput>>::ReplacedEntity<FE>;
|
|
|
|
|
|
fn build(&self) -> Query {
|
|
|
let subquery = self.parent.build().replace(
|