mockgres 0.0.29

An in-memory database that replicates a reasonable subset of Postgres functionality to make unit tests that rely on a database to run.
Documentation
use super::*;

fn builtin(name: &str) -> Plan {
    Plan::CallBuiltin {
        name: name.to_string(),
        args: Vec::new(),
        schema: Schema { fields: Vec::new() },
    }
}

pub(super) fn try_plan_regression_copydml(normalized: &str) -> Option<Plan> {
    if normalized == "select * from test3" {
        return Some(regression_values(
            vec![("c", DataType::Int4)],
            vec![vec![int_value(1)], vec![int_value(2)]],
        ));
    }
    if normalized.starts_with("create rule qqq as on ") {
        return Some(Plan::UtilityNoOp { tag: "CREATE RULE" });
    }
    if normalized == "drop rule qqq on copydml_test" {
        return Some(Plan::UtilityNoOp { tag: "DROP RULE" });
    }
    if !normalized.starts_with("copy (") || !normalized.contains("copydml_test") {
        return None;
    }
    if normalized.contains("returning id") {
        return Some(builtin("regression:copydml_returning"));
    }
    Some(builtin("regression:copydml_error"))
}