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