Derive Macro diesel::expression::Selectable[][src]

#[derive(Selectable)]
{
    // Attributes available to this derive:
    #[table_name]
    #[column_name]
    #[sql_type]
    #[diesel]
}

Implements Selectable

To implement Selectable this derive needs to know the corresponding table type. By default it uses the snake_case type name with an added s. It is possible to change this default by using #[table_name = "something"].

If the name of a field on your struct is different than the column in your table! declaration, or if you are deriving this trait on a tuple struct, you can annotate the field with #[column_name = "some_column"]. For tuple structs, all fields must have this annotation.

If a field is another struct which implements Selectable, instead of a column, you can annotate that struct with #[diesel(embed)]. Then all fields contained by that inner struct are selected as separate tuple. Fields from a inner struct can come from a different table, as long as the select clause is valid in current query.

The derive enables using the SelectableHelper::as_select method to construct select clauses, in order to use LoadDsl, you might also check the Queryable trait and derive.

Attributes

Type attributes

Field attributes