-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sqlx 0.7 update #2604
Sqlx 0.7 update #2604
Conversation
Oh man, same work done twice 🤦🏻♂️ At least I learned something by doing it myself. The only differences to #2597 that I spotted are options for
To your questions:
|
I was about to merge (a version of) this when I noticed spurious failures caused by a change I made to the sqlx example: #[post("/", data = "<post>")]
-async fn create(mut db: Connection<Db>, post: Json<Post>) -> Result<Created<Json<Post>>> {
- // There is no support for `RETURNING`.
- sqlx::query!("INSERT INTO posts (title, text) VALUES (?, ?)", post.title, post.text)
- .execute(&mut *db)
- .await?;
+async fn create(mut db: Connection<Db>, mut post: Json<Post>) -> Result<Created<Json<Post>>> {
+ let query = sqlx::query! {
+ "INSERT INTO posts (title, text) VALUES (?, ?) RETURNING id",
+ post.title, post.text
+ };
+ post.id = Some(query.fetch_one(&mut **db).await?.id);
Ok(Created::new("/").body(post))
} This is something I had been wanting the example to do for some time but we lacked an updated version of
The I've pushed the was-ready-to-merge |
Looks like the issue I outline above is launchbadge/sqlx#2543. I'm rather surprised that this seemingly very serious issue has been completely ignored for over two months, or longer (launchbadge/sqlx#1648). |
Worked around the issue. Merged in aa7805a. Thank you! |
Changelog of sqlx
TL;DR:
mut db: Connection<Logs>
(🙏🏻reddit) -> 5e15bc7Fixes: "use two different sqlx versions?" when using shuttle.rs
I'm new to Rust. This is my first contribution to the Rust community. Please tell me, if you would have done this better. I'm willing to learn.