|
2 | 2 | //! |
3 | 3 | //! Generates async `from_model` implementations for `SeaORM` models with relations. |
4 | 4 |
|
| 5 | +use std::collections::HashMap; |
| 6 | + |
5 | 7 | use proc_macro2::TokenStream; |
6 | 8 | use quote::quote; |
7 | 9 | use syn::Type; |
@@ -80,7 +82,7 @@ pub fn generate_from_model_with_relations( |
80 | 82 | field_mappings: &[(syn::Ident, syn::Ident, bool, bool)], |
81 | 83 | relation_fields: &[RelationFieldInfo], |
82 | 84 | source_module_path: &[String], |
83 | | - _schema_storage: &[StructMetadata], |
| 85 | + _schema_storage: &HashMap<String, StructMetadata>, |
84 | 86 | ) -> TokenStream { |
85 | 87 | // Build relation loading statements |
86 | 88 | let relation_loads: Vec<TokenStream> = relation_fields |
@@ -583,7 +585,7 @@ mod tests { |
583 | 585 | &field_mappings, |
584 | 586 | &relation_fields, |
585 | 587 | &source_module_path, |
586 | | - &[], |
| 588 | + &HashMap::new(), |
587 | 589 | ); |
588 | 590 | let output = tokens.to_string(); |
589 | 591 |
|
@@ -612,7 +614,7 @@ mod tests { |
612 | 614 | &field_mappings, |
613 | 615 | &relation_fields, |
614 | 616 | &source_module_path, |
615 | | - &[], |
| 617 | + &HashMap::new(), |
616 | 618 | ); |
617 | 619 | let output = tokens.to_string(); |
618 | 620 |
|
@@ -655,7 +657,7 @@ mod tests { |
655 | 657 | &field_mappings, |
656 | 658 | &relation_fields, |
657 | 659 | &source_module_path, |
658 | | - &[], |
| 660 | + &HashMap::new(), |
659 | 661 | ); |
660 | 662 | let output = tokens.to_string(); |
661 | 663 |
|
@@ -704,7 +706,7 @@ mod tests { |
704 | 706 | &field_mappings, |
705 | 707 | &relation_fields, |
706 | 708 | &source_module_path, |
707 | | - &[], |
| 709 | + &HashMap::new(), |
708 | 710 | ); |
709 | 711 | let output = tokens.to_string(); |
710 | 712 |
|
@@ -749,7 +751,7 @@ mod tests { |
749 | 751 | &field_mappings, |
750 | 752 | &relation_fields, |
751 | 753 | &source_module_path, |
752 | | - &[], |
| 754 | + &HashMap::new(), |
753 | 755 | ); |
754 | 756 | let output = tokens.to_string(); |
755 | 757 |
|
@@ -785,7 +787,7 @@ mod tests { |
785 | 787 | &field_mappings, |
786 | 788 | &relation_fields, |
787 | 789 | &source_module_path, |
788 | | - &[], |
| 790 | + &HashMap::new(), |
789 | 791 | ); |
790 | 792 | let output = tokens.to_string(); |
791 | 793 |
|
@@ -832,7 +834,7 @@ mod tests { |
832 | 834 | &field_mappings, |
833 | 835 | &relation_fields, |
834 | 836 | &source_module_path, |
835 | | - &[], |
| 837 | + &HashMap::new(), |
836 | 838 | ); |
837 | 839 | let output = tokens.to_string(); |
838 | 840 |
|
@@ -873,7 +875,7 @@ mod tests { |
873 | 875 | &field_mappings, |
874 | 876 | &relation_fields, |
875 | 877 | &source_module_path, |
876 | | - &[], |
| 878 | + &HashMap::new(), |
877 | 879 | ); |
878 | 880 | let output = tokens.to_string(); |
879 | 881 |
|
@@ -914,7 +916,7 @@ mod tests { |
914 | 916 | &field_mappings, |
915 | 917 | &relation_fields, |
916 | 918 | &source_module_path, |
917 | | - &[], |
| 919 | + &HashMap::new(), |
918 | 920 | ); |
919 | 921 | let output = tokens.to_string(); |
920 | 922 |
|
@@ -960,7 +962,7 @@ mod tests { |
960 | 962 | &field_mappings, |
961 | 963 | &relation_fields, |
962 | 964 | &source_module_path, |
963 | | - &[], |
| 965 | + &HashMap::new(), |
964 | 966 | ); |
965 | 967 | let output = tokens.to_string(); |
966 | 968 |
|
@@ -1058,7 +1060,7 @@ pub struct Model { |
1058 | 1060 | &field_mappings, |
1059 | 1061 | &relation_fields, |
1060 | 1062 | &source_module_path, |
1061 | | - &[], |
| 1063 | + &HashMap::new(), |
1062 | 1064 | ); |
1063 | 1065 |
|
1064 | 1066 | // Restore CARGO_MANIFEST_DIR |
@@ -1145,7 +1147,7 @@ pub struct Model { |
1145 | 1147 | &field_mappings, |
1146 | 1148 | &relation_fields, |
1147 | 1149 | &source_module_path, |
1148 | | - &[], |
| 1150 | + &HashMap::new(), |
1149 | 1151 | ); |
1150 | 1152 |
|
1151 | 1153 | // Restore CARGO_MANIFEST_DIR |
@@ -1231,7 +1233,7 @@ pub struct Model { |
1231 | 1233 | &field_mappings, |
1232 | 1234 | &relation_fields, |
1233 | 1235 | &source_module_path, |
1234 | | - &[], |
| 1236 | + &HashMap::new(), |
1235 | 1237 | ); |
1236 | 1238 |
|
1237 | 1239 | // Restore CARGO_MANIFEST_DIR |
@@ -1301,7 +1303,7 @@ pub struct Model { |
1301 | 1303 | &field_mappings, |
1302 | 1304 | &relation_fields, |
1303 | 1305 | &source_module_path, |
1304 | | - &[], |
| 1306 | + &HashMap::new(), |
1305 | 1307 | ); |
1306 | 1308 |
|
1307 | 1309 | let output = tokens.to_string(); |
@@ -1379,7 +1381,7 @@ pub struct Model { |
1379 | 1381 | &field_mappings, |
1380 | 1382 | &relation_fields, |
1381 | 1383 | &source_module_path, |
1382 | | - &[], |
| 1384 | + &HashMap::new(), |
1383 | 1385 | ); |
1384 | 1386 |
|
1385 | 1387 | // Restore CARGO_MANIFEST_DIR |
@@ -1466,7 +1468,7 @@ pub struct Model { |
1466 | 1468 | &field_mappings, |
1467 | 1469 | &relation_fields, |
1468 | 1470 | &source_module_path, |
1469 | | - &[], |
| 1471 | + &HashMap::new(), |
1470 | 1472 | ); |
1471 | 1473 |
|
1472 | 1474 | // Restore CARGO_MANIFEST_DIR |
@@ -1562,7 +1564,7 @@ pub struct Model { |
1562 | 1564 | &field_mappings, |
1563 | 1565 | &relation_fields, |
1564 | 1566 | &source_module_path, |
1565 | | - &[], |
| 1567 | + &HashMap::new(), |
1566 | 1568 | ); |
1567 | 1569 |
|
1568 | 1570 | // Restore CARGO_MANIFEST_DIR |
@@ -1659,7 +1661,7 @@ pub struct Model { |
1659 | 1661 | &field_mappings, |
1660 | 1662 | &relation_fields, |
1661 | 1663 | &source_module_path, |
1662 | | - &[], |
| 1664 | + &HashMap::new(), |
1663 | 1665 | ); |
1664 | 1666 |
|
1665 | 1667 | // Restore CARGO_MANIFEST_DIR |
@@ -1757,7 +1759,7 @@ pub struct Model { |
1757 | 1759 | &field_mappings, |
1758 | 1760 | &relation_fields, |
1759 | 1761 | &source_module_path, |
1760 | | - &[], |
| 1762 | + &HashMap::new(), |
1761 | 1763 | ); |
1762 | 1764 |
|
1763 | 1765 | // Restore CARGO_MANIFEST_DIR |
@@ -1911,7 +1913,7 @@ pub struct Model { |
1911 | 1913 | &field_mappings, |
1912 | 1914 | &relation_fields, |
1913 | 1915 | &source_module_path, |
1914 | | - &[], |
| 1916 | + &HashMap::new(), |
1915 | 1917 | ); |
1916 | 1918 |
|
1917 | 1919 | // Restore CARGO_MANIFEST_DIR |
@@ -2022,7 +2024,7 @@ pub struct Model { |
2022 | 2024 | &field_mappings, |
2023 | 2025 | &relation_fields, |
2024 | 2026 | &source_module_path, |
2025 | | - &[], |
| 2027 | + &HashMap::new(), |
2026 | 2028 | ); |
2027 | 2029 | let output = tokens.to_string(); |
2028 | 2030 |
|
@@ -2089,7 +2091,7 @@ pub struct Model { |
2089 | 2091 | &field_mappings, |
2090 | 2092 | &relation_fields, |
2091 | 2093 | &source_module_path, |
2092 | | - &[], |
| 2094 | + &HashMap::new(), |
2093 | 2095 | ); |
2094 | 2096 | let output = tokens.to_string(); |
2095 | 2097 |
|
@@ -2146,7 +2148,7 @@ pub struct Model { |
2146 | 2148 | &field_mappings, |
2147 | 2149 | &relation_fields, |
2148 | 2150 | &source_module_path, |
2149 | | - &[], |
| 2151 | + &HashMap::new(), |
2150 | 2152 | ); |
2151 | 2153 | let output = tokens.to_string(); |
2152 | 2154 |
|
@@ -2203,7 +2205,7 @@ pub struct Model { |
2203 | 2205 | &field_mappings, |
2204 | 2206 | &relation_fields, |
2205 | 2207 | &source_module_path, |
2206 | | - &[], |
| 2208 | + &HashMap::new(), |
2207 | 2209 | ); |
2208 | 2210 | let output = tokens.to_string(); |
2209 | 2211 |
|
@@ -2287,7 +2289,7 @@ pub struct Model { |
2287 | 2289 | &field_mappings, |
2288 | 2290 | &relation_fields, |
2289 | 2291 | &source_module_path, |
2290 | | - &[], |
| 2292 | + &HashMap::new(), |
2291 | 2293 | ); |
2292 | 2294 |
|
2293 | 2295 | unsafe { |
@@ -2387,7 +2389,7 @@ pub struct Model { |
2387 | 2389 | &field_mappings, |
2388 | 2390 | &relation_fields, |
2389 | 2391 | &source_module_path, |
2390 | | - &[], |
| 2392 | + &HashMap::new(), |
2391 | 2393 | ); |
2392 | 2394 |
|
2393 | 2395 | unsafe { |
@@ -2475,7 +2477,7 @@ pub struct Model { |
2475 | 2477 | &field_mappings, |
2476 | 2478 | &relation_fields, |
2477 | 2479 | &source_module_path, |
2478 | | - &[], |
| 2480 | + &HashMap::new(), |
2479 | 2481 | ); |
2480 | 2482 |
|
2481 | 2483 | unsafe { |
@@ -2570,7 +2572,7 @@ pub struct Model { |
2570 | 2572 | &field_mappings, |
2571 | 2573 | &relation_fields, |
2572 | 2574 | &source_module_path, |
2573 | | - &[], |
| 2575 | + &HashMap::new(), |
2574 | 2576 | ); |
2575 | 2577 |
|
2576 | 2578 | unsafe { |
|
0 commit comments