Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Getting Error while decoding value when using Select #256

vjkolaventy started this conversation in General
Discussion options

Hi
I am new to Rust and I am trying to use impl_select to get a row by username with Sqlite database. Please help with my code below.

#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct AureumUsers {
pub user_id: u64,
pub username: String,
pub password: String,
pub first_name: String,
pub last_name: String,
pub address1: String,
pub address2: String,
pub city: String,
pub state: String,
pub postal_code: String,
pub mobile: String,
pub phone: String,
pub email: String,
pub birth_date: String,
pub kyc: bool,
pub create_date: String,
}
impl_select!(AureumUsers{select_by_username(table_name: String, username: &str) => "WHERE username = #{username}"});

pub async fn get_aureum_user (username: &str) {
let rb = open_db().await.unwrap();
let data = AureumUsers::select_by_username(&mut rb, "aureum_users".to_string(), username).await;
match data {
Ok(data) => println!("{:?}", data),
Err(err) => println!("Error: {}", err.to_string())
}
}

I am getting the following error when run the program.
Error: error while decoding value: invalid type: integer 0, expected a boolean

You must be logged in to vote

Replies: 2 comments · 1 reply

Comment options

pub kyc: bool,

maybe

pub kyc: bool,

should be

pub kyc: i32,
You must be logged in to vote
0 replies
Comment options

Thank you. I changed it string and it worked. I was confused earlier because the documentation showed that bool can be used.

rbatis::decode decode json vec to an object support decode types: Value,BigDecimal, i8..i64,u8..u64,i64,bool,String or object used rbs::Value macro object

You must be logged in to vote
1 reply
@DogLi
Comment options

#324

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
3 participants
Converted from issue

This discussion was converted from issue #253 on September 29, 2022 08:38.

Morty Proxy This is a proxified and sanitized view of the page, visit original site.