prisma / tiberius

TDS 7.2+ (Microsoft SQL Server) driver for Rust
Apache License 2.0
311 stars 113 forks source link

Error: UTF-16 error #325

Open efendioglukdz opened 6 months ago

efendioglukdz commented 6 months ago

Hello friends,

I have some strange issues when reading from database. Is there any chance to catch that or at least to catch that string with the value that has some broken characters in it � � �. I cant always correct the Database values. It seems to me that it always panics when trying stream.try_next().await.unwrap(). Unfortunately stream.try_next().await.unwrap_or_else(|_| None) { doesnt do better. It breaks the loop. Does anybody had the same issues already and did u come to a solution? Or mayb I use the Library wrong I dnt know

match client.query(sql,&[]).await{
        Ok(mut stream) => {

            while let Some(item) = stream.try_next().await.unwrap(){
                match item{
                    QueryItem::Metadata(meta) if meta.result_index() == 0 => {
                        // the first result column info can be handled here
                        let col_names:Vec<String> = meta.columns().iter().map(|c| c.name().to_string()).collect();
                        println!("{}",col_names.join(","));
                    },
                    // the second result set returns first another metadata item
                    QueryItem::Metadata(meta) => {
                        // .. handling
                    },
                    // ...and, again, we get rows from the second resultset
                    QueryItem::Row(row) => {

                        println!("{row:?}");
                    }

                }
            }
        },
        Err(error) => {

        },
    }