Skip to content
\n

when I try to follow the example code for using Rocket with SQLx 0.6.0 and rocket_db_pools
\nIt compiles when using SQLx 0.5.13 so I'm guessing some traits need to be implemented?
\nOr do I have to pass the connection pool in another way? Right now I'm doing it like this:

\n
#[get(\"/tags\")]\npub async fn fetch(\n\tmut db: Connection<Db>\n) -> Result<Json<Vec<Tag>>, (Status, Json<ApiError>)> {\n\tsqlx::query_as!(Tag, \"SELECT id, label, color FROM tag ORDER BY id\")\n\t\t.fetch_all(&mut *db)\n\t\t.await\n\t\t.map(|tag| Json(tag))\n\t\t.map_err(|e| {\n\t\t\tApiError::server_error(\n\t\t\t\tStatus::InternalServerError, \n\t\t\t\t&e.to_string()\n\t\t\t)\n\t\t})\n}\n
","upvoteCount":9,"answerCount":4,"acceptedAnswer":{"@type":"Answer","text":"

Just so it's absolutely clear what worked: .fetch_all(&mut *db) became .fetch_all(&mut **db).

","upvoteCount":1,"url":"https://github.com/rwf2/Rocket/discussions/2241#discussioncomment-10336708"}}}
Discussion options

You must be logged in to vote

Just so it's absolutely clear what worked: .fetch_all(&mut *db) became .fetch_all(&mut **db).

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by SergioBenitez
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants