Skip to content

Commit bf22cc9

Browse files
authored
Merge pull request #4834 from LucaCappelletti94/hash-derive
Added `Hash` trait derive (and some `Eq` and `PartialEq`) to `PostgreSQL` types
2 parents 9d63bd7 + f8d31a8 commit bf22cc9

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

diesel/src/pg/backend.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ impl LikeIsAllowedForType<crate::sql_types::Binary> for Pg {}
169169

170170
// Using the same field names as tokio-postgres
171171
/// See Postgres documentation for SQL Commands NOTIFY and LISTEN
172-
#[derive(Clone, Debug)]
172+
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
173173
pub struct PgNotification {
174174
/// process ID of notifying server process
175175
pub process_id: i32,

diesel/src/pg/types/date_and_time/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ mod std_time;
1515
mod time;
1616

1717
#[cfg(feature = "postgres_backend")]
18-
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, AsExpression, FromSqlRow)]
18+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, AsExpression, FromSqlRow)]
1919
#[diesel(sql_type = Timestamp)]
2020
#[diesel(sql_type = Timestamptz)]
2121
/// Timestamps are represented in Postgres as a 64 bit signed integer representing the number of
@@ -30,7 +30,7 @@ impl Defaultable for PgTimestamp {
3030
}
3131

3232
#[cfg(feature = "postgres_backend")]
33-
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, AsExpression, FromSqlRow)]
33+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, AsExpression, FromSqlRow)]
3434
#[diesel(sql_type = Date)]
3535
/// Dates are represented in Postgres as a 32 bit signed integer representing the number of julian
3636
/// days since January 1st 2000. This struct is a dumb wrapper type, meant only to indicate the
@@ -47,7 +47,7 @@ impl Defaultable for PgDate {
4747
/// microseconds since midnight. This struct is a dumb wrapper type, meant only to indicate the
4848
/// integer's meaning.
4949
#[cfg(feature = "postgres_backend")]
50-
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, AsExpression, FromSqlRow)]
50+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, AsExpression, FromSqlRow)]
5151
#[diesel(sql_type = Time)]
5252
pub struct PgTime(pub i64);
5353

@@ -62,7 +62,7 @@ impl Defaultable for PgTime {
6262
/// representing number of months. This struct is a dumb wrapper type, meant only to indicate the
6363
/// meaning of these parts.
6464
#[cfg(feature = "postgres_backend")]
65-
#[derive(Debug, Clone, Copy, PartialEq, Eq, AsExpression, FromSqlRow)]
65+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, AsExpression, FromSqlRow)]
6666
#[diesel(sql_type = Interval)]
6767
pub struct PgInterval {
6868
/// The number of whole microseconds

diesel/src/pg/types/money.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use crate::sql_types::{BigInt, Money};
1818
/// use diesel::data_types::PgMoney as Pence; // 1/100th unit of Pound
1919
/// use diesel::data_types::PgMoney as Fils; // 1/1000th unit of Dinar
2020
/// ```
21-
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, AsExpression, FromSqlRow)]
21+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, AsExpression, FromSqlRow)]
2222
#[diesel(sql_type = Money)]
2323
pub struct PgMoney(pub i64);
2424

diesel/src/pg/types/pg_lsn.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use byteorder::{NetworkEndian, ReadBytesExt, WriteBytesExt};
99

1010
/// A type encoding a position in the PostgreSQL *Write Ahead Log* (WAL).
1111
/// In Postgres, it is represented as an unsigned 64 bit integer.
12-
#[derive(Debug, Default, Copy, Clone, PartialEq, Eq, AsExpression, FromSqlRow)]
12+
#[derive(Debug, Default, Copy, Clone, PartialEq, Eq, Hash, AsExpression, FromSqlRow)]
1313
#[diesel(sql_type = sql_types::PgLsn)]
1414
pub struct PgLsn(pub u64);
1515

0 commit comments

Comments
 (0)