You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if norm.is_some() && col["file"].is_badvalue(){// Many-to-one relation (subtable with fkey in parent table)
300
+
false => match cardinality {
301
+
Cardinality::ManyToOne =>{// Many-to-one relation (subtable with fkey in parent table)
292
302
let subtable = add_table(colname,&path, norm, settings, col["cols"].as_vec().unwrap_or_else(|| fatalerr!("Error: subtable 'cols' entry is not an array")), cardinality);
293
303
emit_preamble(&subtable, settings,None);
294
304
Some(subtable)
295
-
}
296
-
elseif norm.is_some(){// Many-to-many relation (this file will contain the crosslink table)
305
+
},
306
+
Cardinality::ManyToMany =>{// Many-to-many relation (this file will contain the crosslink table)
297
307
let filename = col["file"].as_str().unwrap_or_else(|| fatalerr!("Error: subtable {} has no 'file' entry", colname));
298
308
if table.columns.is_empty(){fatalerr!("Error: table '{}' cannot have a subtable as first column", name);}
299
309
let subtable = add_table(colname,&path,Some(filename), settings, col["cols"].as_vec().unwrap_or_else(|| fatalerr!("Error: subtable 'cols' entry is not an array")), cardinality);
else{// One-to-many relation (this file will contain the subtable with the parent table fkey)
312
+
},
313
+
_ =>{// One-to-many relation (this file will contain the subtable with the parent table fkey)
304
314
let filename = col["file"].as_str().unwrap_or_else(|| fatalerr!("Error: subtable {} has no 'file' entry", colname));
305
315
if table.columns.is_empty(){fatalerr!("Error: table '{}' cannot have a subtable as first column", name);}
306
316
let subtable = add_table(colname,&path,Some(filename), settings, col["cols"].as_vec().unwrap_or_else(|| fatalerr!("Error: subtable 'cols' entry is not an array")), cardinality);
continue'restart;// Continue the restart loop because another column may also match the current path
600
+
}
589
601
}
590
602
591
603
// Handle 'subtable' case (the 'cols' entry has 'cols' of its own)
@@ -708,12 +720,16 @@ fn main() {
708
720
let key = tables.last().unwrap().columns[0].value.borrow();
709
721
if key.is_empty() && !settings.hush_warning{println!("Warning: subtable {} has no foreign key for parent (you may need to add a 'seri' column)", table.name);}
710
722
table.write(&format!("{}\t", key));
723
+
let rowid;
711
724
ifletSome(domain) = table.domain.as_ref(){
712
-
if table.columns[0].value.borrow().is_empty(){println!("Warning: subtable {} has no primary key to normalize on", table.name);}
713
-
table.write(&format!("{}", table.columns[0].value.borrow()));// This is a many-to-may relation; write the two keys into the link table
714
725
letmut domain = domain.borrow_mut();
715
726
if !domain.map.contains_key(&table.columns[0].value.borrow().to_string()){
716
-
domain.map.insert(table.columns[0].value.borrow().to_string(),0);// Table domains use the HashMap as a HashSet
0 commit comments