Commit 15713ba 1 parent 0a16742 commit 15713ba Copy full SHA for 15713ba
File tree 1 file changed +39
-1
lines changed
1 file changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -123,7 +123,45 @@ use crate::row::Row;
123
123
///
124
124
/// This field is compatible with the `default` attribute.
125
125
///
126
- /// ## Manual implementation
126
+ /// #### `skip`
127
+ ///
128
+ /// This is a variant of the `default` attribute which instead always takes the value from
129
+ /// the `Default` implementation for this field type ignoring any results in your query.
130
+ /// This can be useful, if some field does not satifisfy the trait bounds (i.e.
131
+ /// `sqlx::decode::Decode`, `sqlx::type::Type`), in particular in case of nested structures.
132
+ /// For example:
133
+ ///
134
+ /// ```rust,ignore
135
+ /// #[derive(sqlx::FromRow)]
136
+ /// struct Address {
137
+ /// user_name: String,
138
+ /// street: String,
139
+ /// city: String,
140
+ /// }
141
+ ///
142
+ /// #[derive(sqlx::FromRow)]
143
+ /// struct User {
144
+ /// name: String,
145
+ /// #[sqlx(skip)]
146
+ /// addresses: Vec<Address>,
147
+ /// }
148
+ /// ```
149
+ ///
150
+ /// Given 2 querys
151
+ ///
152
+ /// ```sql
153
+ /// SELECT name FROM users;
154
+ /// ```
155
+ ///
156
+ /// and
157
+ ///
158
+ /// ```sql
159
+ /// SELECT user_name, street, city addresses;
160
+ /// ```
161
+ ///
162
+ /// the addresses can be assigned to the empty `addresses` field of each `User`.
163
+ ///
164
+ ////// ## Manual implementation
127
165
///
128
166
/// You can also implement the [`FromRow`] trait by hand. This can be useful if you
129
167
/// have a struct with a field that needs manual decoding:
You can’t perform that action at this time.
0 commit comments