1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
//! Mapping between app-level models and database-level tables.
//!
//! The types in this module define how each model field corresponds to one or
//! more database columns. The mapping supports:
//!
//! - Primitive fields that map 1:1 to a column
//! - Embedded structs that flatten into multiple columns
//! - Embedded enums stored as a discriminant column plus per-variant data columns
//! - Relation fields that have no direct column storage
//!
//! The root type is [`Mapping`], which holds a [`Model`] entry for each model.
//! Each `Model` contains per-field [`Field`] mappings and the expression
//! templates ([`Model::model_to_table`] and [`TableToModel`]) used during
//! query lowering.
//!
//! # Examples
//!
//! ```ignore
//! use toasty_core::schema::mapping::Mapping;
//!
//! // Access the mapping for a specific model
//! let model_mapping = mapping.model(model_id);
//! println!("backed by table {:?}", model_mapping.table);
//! ```
pub use ;
pub use ;
use ModelId;
use IndexMap;
/// Defines the correspondence between app-level models and database-level
/// tables.
///
/// The mapping is constructed during schema building and remains immutable at
/// runtime. It provides the translation layer that enables the query engine to
/// convert model-oriented statements into table-oriented statements during the
/// lowering phase.
///
/// # Examples
///
/// ```ignore
/// use toasty_core::schema::mapping::Mapping;
/// use indexmap::IndexMap;
///
/// let mapping = Mapping { models: IndexMap::new() };
/// assert_eq!(mapping.models.len(), 0);
/// ```