Skip to content

Unclear how to use SUM(_) for BigInt columns in Sqlite #4684

Answered by drahnr
drahnr asked this question in Q&A
Discussion options

You must be logged in to vote

Manual implementation of QueryableByName works, using #[derive(QueryableByName)] does not, since there is a dependency on the existence of mod $fieldname which is only satisfied when used with a column name as generated by the cli tool / table!.

The following works:

    #[derive(Debug, PartialEq, Clone)]
    struct X {
        summed: i64,
    }

    impl QueryableByName<Sqlite> for X {
        // Required method
        fn build<'a>(row: &impl NamedRow<'a, Sqlite>) -> diesel::deserialize::Result<Self> {
            let summed =
                NamedRow::<'a, Sqlite>::get::<diesel::sql_types::BigInt, i64>(row, "summed")?;
            Ok(Self { summed })
        }
    }

    let maybe_nonc…

Replies: 3 comments 10 replies

Comment options

You must be logged in to vote
4 replies
@drahnr
Comment options

@weiznich
Comment options

@drahnr
Comment options

@weiznich
Comment options

Comment options

You must be logged in to vote
3 replies
@weiznich
Comment options

@drahnr
Comment options

@weiznich
Comment options

Comment options

You must be logged in to vote
3 replies
@weiznich
Comment options

@drahnr
Comment options

@weiznich
Comment options

Answer selected by weiznich
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants