tiberius icon indicating copy to clipboard operation
tiberius copied to clipboard

Error: UTF-16 error

Open efendioglukdz opened this issue 1 year ago • 0 comments

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) => {

        },
    }

efendioglukdz avatar Jan 23 '24 11:01 efendioglukdz