Skip to content

Commit 08daaba

Browse files
committed
fix: sqlx-crud
1 parent 5f2452d commit 08daaba

File tree

4 files changed

+52
-31
lines changed

4 files changed

+52
-31
lines changed

TROUBLESHOOTING_NOTES.md

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,54 @@ rustapi-openapi = "0.1.233" # ✅ Bunu kullan
5656

5757
---
5858

59-
### 3. **Query Extractor ile Attribute Macros**
59+
### 3. **rustapi_extras Değil, rustapi_rs Kullan**
60+
61+
**Sorun:**
62+
```rust
63+
use rustapi_extras::SqlxErrorExt; // ❌ Eski isim
64+
```
65+
```
66+
error[E0432]: unresolved import `rustapi_extras`
67+
--> src/main.rs:24:5
68+
|
69+
24 | use rustapi_extras::SqlxErrorExt;
70+
| ^^^^^^^^^^^^^^ use of unresolved module or unlinked crate `rustapi_extras`
71+
```
72+
73+
**Çözüm:**
74+
```rust
75+
use rustapi_rs::SqlxErrorExt; // ✅ Doğru import
76+
```
77+
78+
**Neden?**
79+
- `rustapi_extras` eski bir modül ismidir ve artık mevcut değildir
80+
- SQLx error extension trait'i artık doğrudan `rustapi_rs` içindedir
81+
- Bu trait'i kullanmak için `rustapi-rs`'nin `sqlx` feature'ını etkinleştirmeniz gerekir
82+
83+
**Gerekli Konfigürasyon:**
84+
```toml
85+
[dependencies]
86+
rustapi-rs = { version = "0.1.233", features = ["sqlx"] }
87+
```
88+
89+
**Kullanım:**
90+
```rust
91+
use rustapi_rs::prelude::*;
92+
use rustapi_rs::SqlxErrorExt; // ✅ Doğru path
93+
94+
async fn handler() -> Result<Json<Data>> {
95+
let data = sqlx::query_as::<_, Data>("SELECT * FROM items")
96+
.fetch_all(&pool)
97+
.await
98+
.map_err(|e| e.into_api_error())?; // SqlxErrorExt trait metodu
99+
100+
Ok(Json(data))
101+
}
102+
```
103+
104+
---
105+
106+
### 4. **Query Extractor ile Attribute Macros**
60107

61108
**Yanlış:**
62109
```rust
@@ -89,7 +136,7 @@ pub struct ListParams {
89136

90137
---
91138

92-
### 4. **Handler Macro Kullanımı**
139+
### 5. **Handler Macro Kullanımı**
93140

94141
**Doğru Kullanım:**
95142
```rust

sqlx-crud/Cargo.lock

Lines changed: 2 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sqlx-crud/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,3 @@ tokio = { version = "1.35", features = ["full"] }
1111
serde = { version = "1.0", features = ["derive"] }
1212
serde_json = "1"
1313
sqlx = { version = "0.8", features = ["runtime-tokio", "sqlite"] }
14-
utoipa = "4.2"

sqlx-crud/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
//! - `DELETE /users/{id}` - Delete a user
2222
//! - `POST /users/batch` - Create multiple users in a transaction
2323
24-
use rustapi_extras::SqlxErrorExt;
2524
use rustapi_rs::prelude::*;
25+
use rustapi_rs::SqlxErrorExt;
2626
use sqlx::{Pool, Sqlite, SqlitePool};
2727
use std::sync::Arc;
2828

0 commit comments

Comments
 (0)