/// Creates a recipe from a set of pre-parsed `SqlQuery` structures.
/// Note that the recipe is not backed by a Soup data-flow graph until `activate` is called on
/// it.
Creates a recipe from a set of pre-parsed `SqlQuery` structures.
Note that the recipe is not backed by a Soup data-flow graph until `activate` is called on
it.
Creates a recipe from a set of pre - parsed ` SqlQuery ` structures . Note that the recipe is not backed by a Soup data - flow graph until ` activate ` is called on it .
fn from_queries(
        qs: Vec<(Option<String>, SqlQuery, bool)>,
        log: Option<slog::Logger>,
    ) -> Recipe {
        let mut aliases = HashMap::default();
        let mut expression_order = Vec::new();
        let mut duplicates = 0;
        let expressions = qs
            .into_iter()
            .map(|(n, q, is_leaf)| {
                let qid = hash_query(&q);
                if !expression_order.contains(&qid) {
                    expression_order.push(qid);
                } else {
                    duplicates += 1;
                }
                match n {
                    None => (),
                    Some(ref name) => {
                        assert!(
                            !aliases.contains_key(name) || aliases[name] == qid,
                            "Query name exists but existing query is different: {}",
                            name
                        );
                        aliases.insert(name.clone(), qid);
                    }
                }
                (qid, (n, q, is_leaf))
            })
            .collect::<HashMap<_, _>>();
        let inc = match log {
            None => SqlIncorporator::default(),
            Some(ref log) => SqlIncorporator::new(log.clone()),
        };
        let log = match log {
            None => slog::Logger::root(slog::Discard, o!()),
            Some(log) => log,
        };
        debug!(log, "{} duplicate queries", duplicates; "version" => 0);
        Recipe {
            expressions,
            expression_order,
            aliases,
            security_config: None,
            version: 0,
            prior: None,
            inc: Some(inc),
            log,
        }
    }
fn from_queries ( qs : Vec < ( Option < String > , SqlQuery , bool ) > , log : Option < slog :: Logger > , ) -> Recipe { let mut aliases = HashMap :: default ( ) ; let mut expression_order = Vec :: new ( ) ; let mut duplicates = 0 ; let expressions = qs . into_iter ( ) . map ( | ( n , q , is_leaf ) | { let qid = hash_query ( & q ) ; if ! expression_order . contains ( & qid ) { expression_order . push ( qid ) ; } else { duplicates += 1 ; } match n { None => ( ) , Some ( ref name ) => { assert ! ( aliases contains_key ( name ) aliases [ name ] qid " " name ) ; aliases . insert ( name . clone ( ) , qid ) ; } } ( qid , ( n , q , is_leaf ) ) } ) . collect :: < HashMap < _ , _ > > ( ) ; let inc = match log { None => SqlIncorporator :: default ( ) , Some ( ref log ) => SqlIncorporator :: new ( log . clone ( ) ) , } ; let log = match log { None => slog :: Logger :: root ( slog :: Discard , o ! ( ) ) , Some ( log ) => log , } ; debug ! ( log " " duplicates " " 0 ) ; Recipe { expressions , expression_order , aliases , security_config : None , version : 0 , prior : None , inc : Some ( inc ) , log , } }
Creates a recipe from a set of pre-parsed `SqlQuery` structures.
Creates a recipe from a set of pre - parsed ` SqlQuery ` structures .
qs
Vec<(Option<String>, SqlQuery, bool)>
log
Option<slog::Logger>