Repository: diesel-rs/diesel
File: diesel/src/expression/mod.rs (Rust)

Code before:
///         id: 1,
///         name: "Sean".into(),
///     },
///     post_title: PostTitle {
///         title: "My first post".into(),
///     },
/// };
/// assert_eq!(expected_user_post, first_user_post);
/// #
/// #     Ok(())
/// # }
/// ```
///
/// It is also possible to specify an entirely custom select expression
/// for fields when deriving [`Selectable`](derive@Selectable).
/// This is useful for example to
///
///  * avoid nesting types, or to
///  * populate fields with values other than table columns, such as
///    the result of an SQL function like `CURRENT_TIMESTAMP()`
///    or a custom SQL function.
///
/// The select expression is specified via the `select_expression` parameter.
/// For more complex expressions, it may be required to also specify the result type
/// of the expression with `select_expression_type`, However, for most query fragments
/// this can be inferred and is not needed to be specified.
///
/// ```rust
/// # include!("../doctest_setup.rs");
/// use schema::{users, posts};
///
/// #[derive(Debug, PartialEq, Queryable, Selectable)]
/// struct User {
///     id: i32,
///     name: String,
/// }
///
/// #[derive(Debug, PartialEq, Queryable, Selectable)]
/// #[diesel(table_name = posts)]
/// struct PostTitle {
///     title: String,
/// }
///
/// #[derive(Debug, PartialEq, Queryable, Selectable)]
/// struct UserPost {
///     #[diesel(select_expression = users::columns::id)]
///     #[diesel(select_expression_type = users::columns::id)]
///     id: i32,
///     #[diesel(select_expression = users::columns::name)]
///     name: String,
///     #[diesel(select_expression = posts::columns::title)]

Review comment (suggestion):
```suggestion
/// this can be inferred and does not need to be specified.
```

Code after:
///         id: 1,
///         name: "Sean".into(),
///     },
///     post_title: PostTitle {
///         title: "My first post".into(),
///     },
/// };
/// assert_eq!(expected_user_post, first_user_post);
/// #
/// #     Ok(())
/// # }
/// ```
///
/// It is also possible to specify an entirely custom select expression
/// for fields when deriving [`Selectable`](derive@Selectable).
/// This is useful for example to
///
///  * avoid nesting types, or to
///  * populate fields with values other than table columns, such as
///    the result of an SQL function like `CURRENT_TIMESTAMP()`
///    or a custom SQL function.
///
/// The select expression is specified via the `select_expression` parameter.
/// For more complex expressions, it may be required to also specify the result type
/// of the expression with `select_expression_type`, However, for most query fragments
/// this can be inferred and does not need to be specified.
///
/// ```rust
/// # include!("../doctest_setup.rs");
/// use schema::{users, posts};
///
/// #[derive(Debug, PartialEq, Queryable, Selectable)]
/// struct User {
///     id: i32,
///     name: String,
/// }
///
/// #[derive(Debug, PartialEq, Queryable, Selectable)]
/// #[diesel(table_name = posts)]
/// struct PostTitle {
///     title: String,
/// }
///
/// #[derive(Debug, PartialEq, Queryable, Selectable)]
/// struct UserPost {
///     #[diesel(select_expression = users::columns::id)]
///     #[diesel(select_expression_type = users::columns::id)]
///     id: i32,
///     #[diesel(select_expression = users::columns::name)]
///     name: String,
///     #[diesel(select_expression = posts::columns::title)]