Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

the trait bound bool: std::convert::From<std::option::Option<bool>> is not satisfied

Aperta
#4,065 4 commenti 1 reazione 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 4 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
28/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
postgresql, rust, sql
Ambito
backend, databases

Direzione di ricerca

Reproduce the compile error with the given sqlx::query_as! query and DBImportTorrent struct on Postgres. The CASE TRUE/FALSE is being inferred as Option<bool> while the field is bool. Start from how query_as! maps Postgres column types (boolean / CASE) onto Rust fields, then see why From<Option<bool>> is required. Done when that mapping compiles for a non-optional bool or the docs explain the needed type.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug
I have found these related issues/pull requests

None

Description
         let rows = sqlx::query_as!(
            DBImportTorrent,
            r#"
            SELECT
                id,
                upload_factor,
                download_factor,
                seeders,
                leechers,
                times_completed,
                CASE
                    WHEN deleted_at IS NOT NULL THEN TRUE
                    ELSE FALSE
                END AS is_deleted
            FROM torrents
            "#
        )


#[derive(Debug)]
pub struct DBImportTorrent {
    pub id: i32,
    pub upload_factor: f64,
    pub download_factor: f64,
    pub seeders: i64,
    pub leechers: i64,
    pub times_completed: i32,
    pub is_deleted: bool,
} 

Throws this error: the trait bound bool: std::convert::From<std::option::Option<bool>> is not satisfied

Reproduction steps

Run the code above

SQLx version

0.8

Enabled SQLx features

"runtime-tokio", "tls-native-tls", "postgres", "chrono", "ipnetwork"

Database server and version

Postgres

Operating system

Asahi linux

Rust version

1.89.0

Lingua principale
Rust
Stelle
17.5k
Fork
1.7k
Merge medio
3g 17h
PR unite (30g)
11

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di transact-rs/sqlx

Tutte le issue di transact-rs/sqlx

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.