rustyroad 1.8.5

Rusty Road is a framework written in Rust that is based on Ruby on Rails. It is designed to provide the familiar conventions and ease of use of Ruby on Rails, while also taking advantage of the performance and efficiency of Rust.
//! Grouped constraint parts collected during introspection.

/// Constraint columns keyed by `(table, name)`, preserving column order.
/// For example, two tables may both declare a constraint named `token_key`.
pub(crate) type Grouped = std::collections::BTreeMap<(String, String), Vec<String>>;

/// Accumulated parts of one index.
#[derive(Default)]
pub(crate) struct IndexParts {
    pub table: String,
    pub columns: Vec<String>,
    pub unique: bool,
}

/// Accumulated parts of one foreign key.
#[derive(Default)]
pub(crate) struct FkParts {
    pub table: String,
    pub foreign_table: String,
    pub columns: Vec<String>,
    pub foreign_columns: Vec<String>,
    pub on_delete: Option<String>,
    pub on_update: Option<String>,
}

/// Maps a Postgres referential action code to its SQL keyword.
///
/// `a` is NO ACTION, the default, which is left unstated.
pub(crate) fn action(code: &str) -> Option<String> {
    match code {
        "c" => Some("cascade".to_string()),
        "n" => Some("set null".to_string()),
        "d" => Some("set default".to_string()),
        "r" => Some("restrict".to_string()),
        _ => None,
    }
}