devbcn-workshop icon indicating copy to clipboard operation
devbcn-workshop copied to clipboard

Chapter 2.5 Working with a Database: Injecting the database connection - fails accourding to trait bound `shuttle_shared_db::Postgres: ResourceInputBuilder` is not satisfied

Open philipp10348r574kdfje opened this issue 1 year ago • 4 comments

Hello :)

I´m sorry for opening up a issue, but i can´t help me out.

As I was following the instructions from your Tutorial i ran into this error. I checked it multiple times and can say i exactly followed the instructions.

error[E0277]: the trait bound shuttle_shared_db::Postgres: ResourceInputBuilderis not satisfied --> api/shuttle/src/main.rs:11:7 #[shuttle_shared_db::Postgres()] pool: sqlx::PgPool, ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the traitResourceInputBuilderis not implemented forshuttle_shared_db::Postgres`

error[E0599]: no function or associated item named default found for struct shuttle_shared_db::Postgres in the current scope --> api/shuttle/src/main.rs:9:1

#[shuttle_runtime::main] |^^^^^^^^^^^^^^^^^^^^^^^^ function or associated item not found in Postgres `

As an absolute beginner i would be very thankfull for a solution to this problem, i can´t figure out myself.

philipp10348r574kdfje avatar Mar 12 '24 10:03 philipp10348r574kdfje

Hello :)

I had the same issue. By looking at the shuttle repository : https://github.com/shuttle-hq/shuttle-examples/blob/main/actix-web/postgres/Cargo.toml I found that you should replace the lines to paste in the api/shuttle/Cargo.toml file ( shuttle-shared-db = { version = "0.36.0", features = ["postgres"] } sqlx = { version = "0.7", default-features = false, features = [ "tls-native-tls", "macros", "postgres", "uuid", "chrono", "json", ] }), by those lines : shuttle-shared-db = { version = "0.42.0", features = ["postgres", "sqlx"] } sqlx = "0.7.1"

Arnaud-Parion avatar Mar 25 '24 22:03 Arnaud-Parion

Hello Arnaud,

thank you for your support 🙏☺️

philipp10348r574kdfje avatar Apr 05 '24 18:04 philipp10348r574kdfje

now should be:

shuttle-shared-db = { version = "0.46.0", features = ["postgres", "sqlx"] }
sqlx = "0.7.1"

denverbaumgartner avatar Jul 02 '24 18:07 denverbaumgartner

Hi all! sorry for late response, I will try to update the workshop with new versions of Shuttle and Dioxus, Thank you all for your patience :pray:

piny4man avatar Aug 09 '24 08:08 piny4man

@philipp10348r574kdfje I recently updated both project on main branch and Docs for the issue you had.

As @denverbaumgartner correctly mention, sqlx was missing on shuttle-shared-db crate, thanks for your comment!

Also I worth mentionning you have to change how you initialize Postgress pool on #[shuttle_runtime::main], the attribute now don't need ().

Updated some dependencies on Backend side, specially Shuttle crates.

Closing issue , if you have more doubts or you found some errors, happy to help and sorry again for the delay on the fix :pray:

piny4man avatar Sep 19 '24 18:09 piny4man