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

postgres: Create PgInterval type #271

Merged
merged 2 commits into from
Jul 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions sqlx-core/src/postgres/type_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ pub enum PgType {
TimeArray,
Timestamptz,
TimestamptzArray,
Interval,
IntervalArray,
NumericArray,
Timetz,
TimetzArray,
Expand All @@ -92,7 +94,6 @@ pub enum PgType {
VarbitArray,
Numeric,
Record,
Interval,
RecordArray,
Uuid,
UuidArray,
Expand Down Expand Up @@ -285,6 +286,8 @@ impl PgType {
1183 => PgType::TimeArray,
1184 => PgType::Timestamptz,
1185 => PgType::TimestamptzArray,
1186 => PgType::Interval,
1187 => PgType::IntervalArray,
1231 => PgType::NumericArray,
1266 => PgType::Timetz,
1270 => PgType::TimetzArray,
Expand All @@ -294,7 +297,6 @@ impl PgType {
1563 => PgType::VarbitArray,
1700 => PgType::Numeric,
2249 => PgType::Record,
2281 => PgType::Interval,
2287 => PgType::RecordArray,
2950 => PgType::Uuid,
2951 => PgType::UuidArray,
Expand Down Expand Up @@ -389,6 +391,8 @@ impl PgType {
PgType::TimeArray => 1183,
PgType::Timestamptz => 1184,
PgType::TimestamptzArray => 1185,
PgType::Interval => 1186,
PgType::IntervalArray => 1187,
PgType::NumericArray => 1231,
PgType::Timetz => 1266,
PgType::TimetzArray => 1270,
Expand All @@ -398,7 +402,6 @@ impl PgType {
PgType::VarbitArray => 1563,
PgType::Numeric => 1700,
PgType::Record => 2249,
PgType::Interval => 2281,
PgType::RecordArray => 2287,
PgType::Uuid => 2950,
PgType::UuidArray => 2951,
Expand Down Expand Up @@ -488,6 +491,8 @@ impl PgType {
PgType::TimeArray => "TIME[]",
PgType::Timestamptz => "TIMESTAMPTZ",
PgType::TimestamptzArray => "TIMESTAMPTZ[]",
PgType::Interval => "INTERVAL",
PgType::IntervalArray => "INTERVAL[]",
PgType::NumericArray => "NUMERIC[]",
PgType::Timetz => "TIMETZ",
PgType::TimetzArray => "TIMETZ[]",
Expand All @@ -497,7 +502,6 @@ impl PgType {
PgType::VarbitArray => "VARBIT[]",
PgType::Numeric => "NUMERIC",
PgType::Record => "RECORD",
PgType::Interval => "INTERVAL",
PgType::RecordArray => "RECORD[]",
PgType::Uuid => "UUID",
PgType::UuidArray => "UUID[]",
Expand Down Expand Up @@ -584,6 +588,8 @@ impl PgType {
PgType::TimeArray => "_time",
PgType::Timestamptz => "timestamptz",
PgType::TimestamptzArray => "_timestamptz",
PgType::Interval => "interval",
PgType::IntervalArray => "_interval",
PgType::NumericArray => "_numeric",
PgType::Timetz => "timetz",
PgType::TimetzArray => "_timetz",
Expand All @@ -593,7 +599,6 @@ impl PgType {
PgType::VarbitArray => "_varbit",
PgType::Numeric => "numeric",
PgType::Record => "record",
PgType::Interval => "interval",
PgType::RecordArray => "_record",
PgType::Uuid => "uuid",
PgType::UuidArray => "_uuid",
Expand Down Expand Up @@ -680,6 +685,8 @@ impl PgType {
PgType::TimeArray => &PgTypeKind::Array(PgTypeInfo(PgType::Time)),
PgType::Timestamptz => &PgTypeKind::Simple,
PgType::TimestamptzArray => &PgTypeKind::Array(PgTypeInfo(PgType::Timestamptz)),
PgType::Interval => &PgTypeKind::Simple,
PgType::IntervalArray => &PgTypeKind::Array(PgTypeInfo(PgType::Interval)),
PgType::NumericArray => &PgTypeKind::Array(PgTypeInfo(PgType::Numeric)),
PgType::Timetz => &PgTypeKind::Simple,
PgType::TimetzArray => &PgTypeKind::Array(PgTypeInfo(PgType::Timetz)),
Expand All @@ -689,7 +696,6 @@ impl PgType {
PgType::VarbitArray => &PgTypeKind::Array(PgTypeInfo(PgType::Varbit)),
PgType::Numeric => &PgTypeKind::Simple,
PgType::Record => &PgTypeKind::Simple,
PgType::Interval => &PgTypeKind::Simple,
PgType::RecordArray => &PgTypeKind::Array(PgTypeInfo(PgType::Record)),
PgType::Uuid => &PgTypeKind::Simple,
PgType::UuidArray => &PgTypeKind::Array(PgTypeInfo(PgType::Uuid)),
Expand Down Expand Up @@ -866,6 +872,7 @@ impl PgTypeInfo {

// time interval
pub(crate) const INTERVAL: Self = Self(PgType::Interval);
pub(crate) const INTERVAL_ARRAY: Self = Self(PgType::IntervalArray);

//
// geometric types
Expand Down
Loading