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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
//! IDE-visible markers accepted by the MySQL schema macros.
//!
//! Attribute macros parse these tokens before Rust type checking. Re-exporting
//! marker constants from the prelude lets rust-analyzer resolve and document
//! them without turning the attribute vocabulary into runtime state.
/// Zero-sized marker referenced by generated hover bindings.
;
/// Adds a database `DEFAULT` clause and leaves omitted insert values to MySQL.
///
/// String literals become quoted SQL values. SQL keywords and function calls
/// are emitted as database expressions.
pub const DEFAULT: AttributeMarker = AttributeMarker;
/// Generates an omitted insert value in the Rust application.
///
/// This does not add a database `DEFAULT` clause.
pub const DEFAULT_FN: AttributeMarker = AttributeMarker;
/// Declares a foreign key to another table's column.
///
/// ```rust
/// # let _ = r####"
/// #[column(REFERENCES = User::id)]
/// user_id: u64,
/// # "####;
/// ```
///
/// With the `query` feature this also generates relation accessors: a
/// forward one on this table, named after the column without its `_id` suffix
/// (`user_id` gives `.user()`), and a reverse one on the referenced table
/// (see [`RELATION`]).
pub const REFERENCES: AttributeMarker = AttributeMarker;
/// Sets the reverse relation accessor name on the referenced table.
///
/// By default, reverse relations are named from the referencing struct
/// (`posts` for a `Post` table). When several foreign keys target the same
/// table, or the foreign key is self-referential, the name is disambiguated as
/// `{forward}_{plural}` (e.g. `author_posts`). Use `RELATION` to pick an
/// explicit reverse name instead; it is required only when two reverse names
/// would still collide.
///
/// The forward relation (on this table) is unchanged; only the reverse
/// accessor on the referenced table is renamed.
///
/// ```rust
/// # let _ = r####"
/// // Users get `.authored()` instead of `.author_posts()`
/// #[column(REFERENCES = User::id, RELATION = "authored")]
/// author_id: u64,
///
/// // Still auto-disambiguated: Users get `.editor_posts()`
/// #[column(REFERENCES = User::id)]
/// editor_id: Option<u64>,
/// # "####;
/// ```
///
/// Requires a `REFERENCES` attribute on the same column.
pub const RELATION: AttributeMarker = AttributeMarker;
markers!;