Skip to content

Instantly share code, notes, and snippets.

@icefoxen
Created March 25, 2019 23:12
Show Gist options
  • Save icefoxen/3a06b1fde0fefc2a747f169545ad1854 to your computer and use it in GitHub Desktop.
Save icefoxen/3a06b1fde0fefc2a747f169545ad1854 to your computer and use it in GitHub Desktop.
type SqlType = <(diesel::sql_types::Text, diesel::sql_types::BigInt) as Expression>::SqlType;
type BoxedQuery<'a> = cargofox::schema::analyze_metadata_authors::BoxedQuery<'a, Pg, SqlType>;
fn lookup<E>(conn: &PgConn, e: E) -> HashMap<String, i64>
where
E: AsExpression<(Text, BigInt)>
+ diesel::expression::SelectableExpression<cargofox::schema::analyze_metadata_authors::table>
+ diesel::query_builder::QueryFragment<Pg>
+ diesel::query_builder::QueryId,
E::Expression: BoxableExpression<ama::analyze_metadata_authors, Pg>,
{
let author_id_lookup: HashMap<String, i64> = {
ama::analyze_metadata_authors
.select(e)
.get_results(conn)
.expect("*SILLY COWS*")
.into_iter()
.collect()
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment