diesel-rs / diesel

A safe, extensible ORM and Query Builder for Rust
https://diesel.rs
Apache License 2.0
12.82k stars 1.08k forks source link

&mut in Call to Establish SqliteConnection Results in Compile Error #3293

Closed adolph closed 2 years ago

adolph commented 2 years ago

https://github.com/diesel-rs/diesel/blob/d4113eda1d0d432707c1a731c5df448b300ffa40/examples/sqlite/getting_started_step_3/src/bin/show_posts.rs#L8

Removal of the &mut in the above line resolved error:

error[E0277]: the trait bound &mut SqliteConnection: Connection is not satisfied --> src/bin/show_posts.rs:17:10 17 .load::(&connection) ^^^^ the trait Connection is not implemented for &mut SqliteConnection
 = help: the trait `Connection` is implemented for `SqliteConnection`
 = note: required because of the requirements on the impl of `LoadQuery<&mut SqliteConnection, diesel_demo::models::Post>` for `SelectStatement<table, diesel::query_builder::select_clause::DefaultSelectClause, diesel::query_builder::distinct_clause::NoDistinctClause, diesel::query_builder::where_clause::WhereClause<diesel::expression::operators::Eq<diesel_demo::schema::posts::published, diesel::expression::bound::Bound<Bool, bool>>>, diesel::query_builder::order_clause::NoOrderClause, diesel::query_builder::limit_clause::LimitClause<diesel::expression::bound::Bound<BigInt, i64>>>`

note: required by a bound in load

weiznich commented 2 years ago

Please provide all information requested in the issue template. Otherwise this issue is not actionable and will be closed as incomplete. Also note that these examples are tested as part of the CI runs, so its unlikely that they are broken. It might therefore be required to provide an minimal reproducible example of your issue.

Mingun commented 2 years ago

It seems that you should replace .load(&connection) with .load(connection), because connection is already a reference.

weiznich commented 2 years ago

Closed as the error message does not even match the linked code. Please use the support forum for such questions in the future.