Skip to content

Instantly share code, notes, and snippets.

@shssoichiro
Created January 18, 2018 14:14
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save shssoichiro/d09a2e3a23489208253fe36cad9a00bf to your computer and use it in GitHub Desktop.
impl<C: Connection> Connection for LoggingConnection<C>
where
C: Connection<TransactionManager = AnsiTransactionManager> + Send + 'static,
C::Backend: UsesAnsiSavepointSyntax,
{
type Backend = C::Backend;
fn query_by_index<T, U>(&self, source: T) -> QueryResult<Vec<U>>
where
T: AsQuery,
T::Query: QueryFragment<Self::Backend> + QueryId,
U: Queryable<T::SqlType, Self::Backend>,
Self::Backend: HasSqlType<T::SqlType>,
Self::Backend::QueryBuilder: Default,
{
let start_time = Instant::now();
let result = self.0.query_by_index(source);
let duration = start_time.elapsed();
log_query(&debug_query::<Self::Backend, _>(&source.as_query()).to_string(), duration);
result
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment