Skip to content

Instantly share code, notes, and snippets.

@cdxker
Last active March 13, 2024 10:45
Show Gist options
  • Save cdxker/9d0f1da80f825be39f9a4499aa8990a7 to your computer and use it in GitHub Desktop.
Save cdxker/9d0f1da80f825be39f9a4499aa8990a7 to your computer and use it in GitHub Desktop.
Async Diesel with Vec error
use diesel_async::RunQueryDsl;
struct A;
impl A {
fn first() {
print!("hi");
}
}
fn main() {
A.first();
}
// error[E0277]: the trait bound `A: diesel::query_source::Table` is not satisfied
// --> src/main.rs:11:7
// |
// 11 | A.first();
// | ^^^^^ the trait `diesel::query_source::Table` is not implemented for `A`
// |
// = help: the following other types implement trait `diesel::query_dsl::limit_dsl::LimitDsl`:
// diesel::query_builder::select_statement::boxed::BoxedSelectStatement<'a, ST, QS, DB, GB>
// diesel::query_builder::select_statement::SelectStatement<F, S, D, W, O, diesel::query_builder::limit_offset_clause::Lim
// itOffsetClause<L, Of>, G, H, LC>
// diesel::query_source::aliasing::alias::Alias<S>
// = note: required for `A` to implement `diesel::query_dsl::limit_dsl::LimitDsl`
//
// error[E0277]: the trait bound `A: diesel::query_builder::Query` is not satisfied
// --> src/main.rs:11:7
// |
// 11 | A.first();
// | ^^^^^ the trait `diesel::query_builder::Query` is not implemented for `A`
// |
// = help: the following other types implement trait `diesel::query_builder::Query`:
// diesel::query_builder::delete_statement::DeleteStatement<T, U, diesel::query_builder::returning_clause::ReturningClause
// <Ret>>
// diesel::query_builder::sql_query::BoxedSqlQuery<'_, DB, Q>
// diesel::expression::sql_literal::SqlLiteral<ST, T>
// diesel::expression::sql_literal::UncheckedBind<Q, Value>
// diesel::query_builder::combination_clause::CombinationClause<Combinator, Rule, Source, Rhs>
// diesel::query_builder::insert_statement::InsertStatement<T, U, Op, diesel::query_builder::returning_clause::ReturningCl
// ause<Ret>>
// diesel::query_builder::select_statement::boxed::BoxedSelectStatement<'a, ST, QS, DB, GB>
// diesel::query_builder::select_statement::SelectStatement<F, S, D, W, O, LOf, G, H, LC>
// and 6 others
// = note: required for `A` to implement `diesel::query_builder::AsQuery`
// = note: required for `A` to implement `diesel::query_dsl::limit_dsl::LimitDsl`
//
// error[E0275]: overflow evaluating the requirement `<A as diesel::query_dsl::limit_dsl::LimitDsl>::Output == _`
// --> src/main.rs:11:7
// |
// 11 | A.first();
// | ^^^^^
use diesel_async::RunQueryDsl;
fn main() {
vec![1, 2, 3, 4].first();
}
// error[E0277]: the trait bound `Vec<{integer}>: diesel::query_source::Table` is not satisfied
// --> src/main.rs:4:22
// |
// 4 | vec![1, 2, 3, 4].first();
// | ^^^^^ the trait `diesel::query_source::Table` is not implemented for `Vec<{integer}>`
// |
// = help: the following other types implement trait `diesel::query_dsl::limit_dsl::LimitDsl`:
// diesel::query_builder::select_statement::boxed::BoxedSelectStatement<'a, ST, QS, DB, GB>
// diesel::query_builder::select_statement::SelectStatement<F, S, D, W, O, diesel::query_builder::limit_offset_clause::LimitOffsetClause<L, Of>, G, H, LC>
// diesel::query_source::aliasing::alias::Alias<S>
// = note: required for `Vec<{integer}>` to implement `diesel::query_dsl::limit_dsl::LimitDsl`
//
// error[E0277]: the trait bound `Vec<{integer}>: diesel::query_builder::Query` is not satisfied
// --> src/main.rs:4:22
// |
// 4 | vec![1, 2, 3, 4].first();
// | ^^^^^ the trait `diesel::query_builder::Query` is not implemented for `Vec<{integer}>`
// |
// = help: the following other types implement trait `diesel::query_builder::Query`:
// diesel::query_builder::delete_statement::DeleteStatement<T, U, diesel::query_builder::returning_clause::ReturningClause<Ret>>
// diesel::query_builder::sql_query::BoxedSqlQuery<'_, DB, Q>
// diesel::expression::sql_literal::SqlLiteral<ST, T>
// diesel::expression::sql_literal::UncheckedBind<Q, Value>
// diesel::query_builder::combination_clause::CombinationClause<Combinator, Rule, Source, Rhs>
// diesel::query_builder::insert_statement::InsertStatement<T, U, Op, diesel::query_builder::returning_clause::ReturningClause<Ret>>
// diesel::query_builder::select_statement::boxed::BoxedSelectStatement<'a, ST, QS, DB, GB>
// diesel::query_builder::select_statement::SelectStatement<F, S, D, W, O, LOf, G, H, LC>
// and 6 others
// = note: required for `Vec<{integer}>` to implement `diesel::query_builder::AsQuery`
// = note: required for `Vec<{integer}>` to implement `diesel::query_dsl::limit_dsl::LimitDsl`
//
// error[E0275]: overflow evaluating the requirement `<Vec<{integer}> as diesel::query_dsl::limit_dsl::LimitDsl>::Output == _`
// --> src/main.rs:4:22
// |
// 4 | vec![1, 2, 3, 4].first();
// | ^^^^^
//
// Some errors have detailed explanations: E0275, E0277.
// For more information about an error, try `rustc --explain E0275`.
use diesel::RunQueryDsl;
fn main() {
let x = vec![1, 2, 3, 4];
println!("Hello {:?}", x.first());
}
// Hello Some(1)
@cdxker
Copy link
Author

cdxker commented Mar 13, 2024

Adding a comment here that this gist is linked to the issue tracked here weiznich/diesel_async#142. Will update gist comment when this is fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment