mirror of
https://github.com/launchbadge/sqlx.git
synced 2025-10-05 00:35:30 +00:00
doc: improve docs for Type
and FromRow
derives
This commit is contained in:
parent
5f793c6e95
commit
e44031676f
@ -47,6 +47,25 @@ use crate::row::Row;
|
|||||||
///
|
///
|
||||||
/// will read the content of the column `description` into the field `about_me`.
|
/// will read the content of the column `description` into the field `about_me`.
|
||||||
///
|
///
|
||||||
|
/// #### `rename_all`
|
||||||
|
/// By default, field names are expected verbatim (with the exception of the raw identifier prefix `r#`, if present).
|
||||||
|
/// Placed at the struct level, this attribute changes how the field name is mapped to its SQL column name:
|
||||||
|
///
|
||||||
|
/// ```rust,ignore
|
||||||
|
/// #[derive(sqlx::FromRow)]
|
||||||
|
/// #[sqlx(rename_all = "camelCase")]
|
||||||
|
/// struct UserPost {
|
||||||
|
/// id: i32,
|
||||||
|
/// // remapped to "userId"
|
||||||
|
/// user_id: i32,
|
||||||
|
/// contents: String
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
|
/// The supported values are `snake_case` (available if you have non-snake-case field names for some
|
||||||
|
/// reason), `lowercase`, `UPPERCASE`, `camelCase`, `SCREAMING_SNAKE_CASE` and `kebab-case`.
|
||||||
|
/// The styling of each option is intended to be an example of its behavior.
|
||||||
|
///
|
||||||
/// #### `default`
|
/// #### `default`
|
||||||
///
|
///
|
||||||
/// When your struct contains a field that is not present in your query,
|
/// When your struct contains a field that is not present in your query,
|
||||||
|
@ -98,6 +98,14 @@ pub use json::Json;
|
|||||||
/// struct UserId(i64);
|
/// struct UserId(i64);
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
|
/// ##### Attributes
|
||||||
|
///
|
||||||
|
/// * `#[sqlx(rename = "<SQL type name>")]` on struct definition: instead of inferring the SQL type name from the inner
|
||||||
|
/// field (in the above case, `BIGINT`), explicitly set it to `<SQL type name>` instead. May trigger
|
||||||
|
/// errors or unexpected behavior if the encoding of the given type is different than that of the
|
||||||
|
/// inferred type (e.g. if you rename the above to `VARCHAR`).
|
||||||
|
/// Affects Postgres only.
|
||||||
|
///
|
||||||
/// ### Enumeration
|
/// ### Enumeration
|
||||||
///
|
///
|
||||||
/// Enumerations may be defined in Rust and can match SQL by
|
/// Enumerations may be defined in Rust and can match SQL by
|
||||||
|
Loading…
x
Reference in New Issue
Block a user