Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting result error using py_sql with single result #498

Open
SnowyThinker opened this issue Mar 10, 2024 · 1 comment
Open

Setting result error using py_sql with single result #498

SnowyThinker opened this issue Mar 10, 2024 · 1 comment
Labels
help wanted Extra attention is needed

Comments

@SnowyThinker
Copy link

#[py_sql("select ROUND(IFNULL(AVG(level), 0)) from rating WHERE id = #{id}  ")]
async fn query_rating_by_app(rb: &RBatis, id: usize) -> usize { impled!() }

called Result::unwrap() on an Err value: E("error while decoding value: invalid type: map, expected usize")

@zhuxiujia
Copy link
Member

select ROUND return an float value(just like 1.0)
so,you should change to type f64

#[py_sql("select ROUND(IFNULL(AVG(level), 0)) from rating WHERE id = #{id}  ")]
async fn query_rating_by_app(rb: &RBatis, id: usize) -> f64{ impled!() }

@zhuxiujia zhuxiujia added the help wanted Extra attention is needed label Mar 10, 2024
zhuxiujia added a commit that referenced this issue Mar 10, 2024
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
Projects
None yet
Development

No branches or pull requests

2 participants