Skip to content

Commit

Permalink
Allow mysql's unsigned types to be used with aggregate functions
Browse files Browse the repository at this point in the history
In the cases where the output type is `Numeric`, the output is signed as
there's no representation of an unsigned arbitrary precision decimal
number.

Fixes #1870.
  • Loading branch information
sgrif committed Oct 3, 2018
1 parent db66040 commit 6d563fb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions diesel/src/sql_types/fold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,10 @@ foldable_impls! {

sql_types::Interval => (sql_types::Interval, sql_types::Interval),
}

#[cfg(feature = "mysql")]
foldable_impls! {
sql_types::Unsigned<sql_types::SmallInt> => (sql_types::Unsigned<sql_types::BigInt>, sql_types::Numeric),
sql_types::Unsigned<sql_types::Integer> => (sql_types::Unsigned<sql_types::BigInt>, sql_types::Numeric),
sql_types::Unsigned<sql_types::BigInt> => (sql_types::Numeric, sql_types::Numeric),
}
7 changes: 7 additions & 0 deletions diesel/src/sql_types/ord.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,10 @@ impl<T: SqlOrd + NotNull> SqlOrd for sql_types::Nullable<T> {}

#[cfg(feature = "postgres")]
impl<T: SqlOrd> SqlOrd for sql_types::Array<T> {}

#[cfg(feature = "mysql")]
impl SqlOrd for sql_types::Unsigned<sql_types::SmallInt> {}
#[cfg(feature = "mysql")]
impl SqlOrd for sql_types::Unsigned<sql_types::Integer> {}
#[cfg(feature = "mysql")]
impl SqlOrd for sql_types::Unsigned<sql_types::BigInt> {}

0 comments on commit 6d563fb

Please sign in to comment.