|
@@ -6,7 +6,12 @@ use crate::schema::{DatumDiscriminator, Relation};
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
pub enum PartType {
|
|
|
+ /// stores sql data type
|
|
|
Datum(&'static str),
|
|
|
+ /// stores the entity name
|
|
|
+ IDReference(
|
|
|
+ &'static str,
|
|
|
+ ),
|
|
|
AssocDomain {
|
|
|
table_name: String,
|
|
|
range_name: &'static str,
|
|
@@ -33,8 +38,7 @@ impl PartState {
|
|
|
}
|
|
|
impl<EP: EntityPart> DatumDiscriminator for Discriminator<EP> {
|
|
|
fn visit_entity_id<E: Entity>(&mut self) {
|
|
|
- // TODO: add foreign key constraint
|
|
|
- self.ty = Some(PartType::Datum(<E::ID as Datum>::sql_type()));
|
|
|
+ self.ty = Some(PartType::IDReference(E::entity_name()));
|
|
|
}
|
|
|
|
|
|
fn visit_bare_field<T: Datum>(&mut self) {
|