尝试从 table 获取总数时 Rust diesel 面临错误

Rust diesel facing error when trying to get total count from table

我正在使用 rust diesel 实现一个数据库。我想使用具有 filter 条件的查询来获取 table 中存在的总计数或总列数。下面是我的 table 结构和查询代码。我没有在我的 table 结构中使用任何 BIGINT, 大的小数。

the trait bound i32: FromSql<BigInt, Pg> is not satisfied the following implementations were found: <i32 as FromSql<Integer, DB>> required because of the requirements on the impl of diesel::Queryable<BigInt, Pg> for i32 required because of the requirements on the impl of LoadQuery<PooledConnection<ConnectionManager<PgConnection>>, i32> for

#Emplyee table

| employee-id  | employee_name | empolyee_email|       
| -----------  | --------------|-------------  |
| 1            | ABC           |abc@mail.com   |
| 2            | xyz           |xyz@mail.com   |


# Account table

| account  | employee-id    | account-balnce | created_at|
| -------- | ----------     |--------------- |-----------|
| 1        | 1              |   2000         | 22/10/2021|
| 2        | 2              |   5000         | 01/09/2021|

fn get_total_accounts(&self, employee_id: &str) -> anyhow::Result<Option<i32>> {
        let res: i32 = employee::table
            .inner_join(account::table)
            .filter(employee::dsl::employee_id.eq(employee_id))
            .count()
            .get_result(&self.pool.get()?)?;  //get_result through error
               
 }

使用 I64 解决了我的问题。

fn get_total_accounts(&self, employee_id: &str) -> anyhow::Result<Option<i32>> {
        let res: i64 = employee::table
            .inner_join(account::table)
            .filter(employee::dsl::employee_id.eq(employee_id))
            .count()
            .get_result(&self.pool.get()?)?;  //get_result through error
               
 }