diff --git a/codegen/src/types.rs b/codegen/src/types.rs index 11c0257c..5b73e3ec 100644 --- a/codegen/src/types.rs +++ b/codegen/src/types.rs @@ -71,14 +71,6 @@ fn parse_types(ranges: &BTreeMap) -> BTreeMap { let variant = match name { "anyarray" => "AnyArray".to_owned(), - // FIXME remove following overrides for 0.12 - "anyrange" => "Anyrange".to_owned(), - "tsvector" => "Tsvector".to_owned(), - "gtsvector" => "Gtsvector".to_owned(), - "_tsvector" => "TsvectorArray".to_owned(), - "_gtsvector" => "GtsvectorArray".to_owned(), - "timestamptz" => "TimestampTZ".to_owned(), - "_timestamptz" => "TimestampTZArray".to_owned(), name => { let variant = range_vector_re.replace(name, "_$1"); let variant = array_re.replace(&variant, "$1_array"); @@ -88,13 +80,10 @@ fn parse_types(ranges: &BTreeMap) -> BTreeMap { let kind = split[11]; - // FIXME enable for 0.12 - /* // we need to be able to pull composite fields and enum variants at runtime if kind == "C" || kind == "E" { continue; } - */ let element = if let Some(&element) = ranges.get(&oid) { element diff --git a/src/types/chrono.rs b/src/types/chrono.rs index 0bcfe2eb..66f24e29 100644 --- a/src/types/chrono.rs +++ b/src/types/chrono.rs @@ -46,7 +46,7 @@ impl FromSql for DateTime { Ok(DateTime::from_utc(naive, UTC)) } - accepts!(Type::TimestampTZ); + accepts!(Type::Timestamptz); } impl ToSql for DateTime { @@ -58,7 +58,7 @@ impl ToSql for DateTime { self.naive_utc().to_sql(type_, w, info) } - accepts!(Type::TimestampTZ); + accepts!(Type::Timestamptz); to_sql_checked!(); } @@ -68,7 +68,7 @@ impl FromSql for DateTime { Ok(utc.with_timezone(&Local)) } - accepts!(Type::TimestampTZ); + accepts!(Type::Timestamptz); } impl ToSql for DateTime { @@ -80,7 +80,7 @@ impl ToSql for DateTime { self.with_timezone(&UTC).to_sql(type_, w, info) } - accepts!(Type::TimestampTZ); + accepts!(Type::Timestamptz); to_sql_checked!(); } @@ -93,7 +93,7 @@ impl FromSql for DateTime { Ok(utc.with_timezone(&FixedOffset::east(0))) } - accepts!(Type::TimestampTZ); + accepts!(Type::Timestamptz); } impl ToSql for DateTime { @@ -105,7 +105,7 @@ impl ToSql for DateTime { self.with_timezone(&UTC).to_sql(type_, w, info) } - accepts!(Type::TimestampTZ); + accepts!(Type::Timestamptz); to_sql_checked!(); } diff --git a/src/types/special.rs b/src/types/special.rs index 8af86081..f5cce810 100644 --- a/src/types/special.rs +++ b/src/types/special.rs @@ -61,7 +61,7 @@ impl ToSql for Date { to_sql_checked!(); } -/// A wrapper that can be used to represent infinity with `Type::Timestamp` and `Type::TimestampTZ` +/// A wrapper that can be used to represent infinity with `Type::Timestamp` and `Type::Timestamptz` /// types. #[derive(Debug, Clone, Copy, PartialEq)] pub enum Timestamp { @@ -75,7 +75,7 @@ pub enum Timestamp { impl FromSql for Timestamp { fn from_sql(ty: &Type, raw: &mut R, ctx: &SessionInfo) -> Result { - if *ty != Type::Timestamp && *ty != Type::TimestampTZ { + if *ty != Type::Timestamp && *ty != Type::Timestamptz { return Err(Error::Conversion("expected timestamp or timestamptz type".into())); } @@ -90,13 +90,13 @@ impl FromSql for Timestamp { } fn accepts(ty: &Type) -> bool { - (*ty == Type::Timestamp || *ty == Type::TimestampTZ) && T::accepts(ty) + (*ty == Type::Timestamp || *ty == Type::Timestamptz) && T::accepts(ty) } } impl ToSql for Timestamp { fn to_sql(&self, ty: &Type, out: &mut W, ctx: &SessionInfo) -> Result { - if *ty != Type::Timestamp && *ty != Type::TimestampTZ { + if *ty != Type::Timestamp && *ty != Type::Timestamptz { return Err(Error::Conversion("expected timestamp or timestamptz type".into())); } @@ -111,7 +111,7 @@ impl ToSql for Timestamp { } fn accepts(ty: &Type) -> bool { - (*ty == Type::Timestamp || *ty == Type::TimestampTZ) && T::accepts(ty) + (*ty == Type::Timestamp || *ty == Type::Timestamptz) && T::accepts(ty) } to_sql_checked!(); diff --git a/src/types/time.rs b/src/types/time.rs index ec284402..ef5860d8 100644 --- a/src/types/time.rs +++ b/src/types/time.rs @@ -27,7 +27,7 @@ impl FromSql for Timespec { Ok(Timespec::new(sec, (usec * NSEC_PER_USEC) as i32)) } - accepts!(Type::Timestamp, Type::TimestampTZ); + accepts!(Type::Timestamp, Type::Timestamptz); } impl ToSql for Timespec { @@ -41,6 +41,6 @@ impl ToSql for Timespec { Ok(IsNull::No) } - accepts!(Type::Timestamp, Type::TimestampTZ); + accepts!(Type::Timestamp, Type::Timestamptz); to_sql_checked!(); } diff --git a/src/types/types.rs b/src/types/types.rs index be31eea9..f9fc75d8 100644 --- a/src/types/types.rs +++ b/src/types/types.rs @@ -38,14 +38,6 @@ pub enum Type { OidVector, /// PG_DDL_COMMAND - internal type for passing CollectedCommand PgDdlCommand, - /// PG_TYPE - PgType, - /// PG_ATTRIBUTE - PgAttribute, - /// PG_PROC - PgProc, - /// PG_CLASS - PgClass, /// JSON Json, /// XML - XML content @@ -179,9 +171,9 @@ pub enum Type { /// TIME[] TimeArray, /// TIMESTAMPTZ - date and time with time zone - TimestampTZ, + Timestamptz, /// TIMESTAMPTZ[] - TimestampTZArray, + TimestamptzArray, /// INTERVAL - @ <number> <units>, time interval Interval, /// INTERVAL[] @@ -271,15 +263,15 @@ pub enum Type { /// ANYENUM Anyenum, /// TSVECTOR - text representation for text search - Tsvector, + TsVector, /// TSQUERY - query representation for text search Tsquery, /// GTSVECTOR - GiST index internal text representation for text search - Gtsvector, + GtsVector, /// TSVECTOR[] - TsvectorArray, + TsVectorArray, /// GTSVECTOR[] - GtsvectorArray, + GtsVectorArray, /// TSQUERY[] TsqueryArray, /// REGCONFIG - registered text search configuration @@ -295,7 +287,7 @@ pub enum Type { /// JSONB[] JsonbArray, /// ANYRANGE - Anyrange, + AnyRange, /// EVENT_TRIGGER EventTrigger, /// INT4RANGE - range of integers @@ -365,10 +357,6 @@ impl Type { 29 => Some(Type::Cid), 30 => Some(Type::OidVector), 32 => Some(Type::PgDdlCommand), - 71 => Some(Type::PgType), - 75 => Some(Type::PgAttribute), - 81 => Some(Type::PgProc), - 83 => Some(Type::PgClass), 114 => Some(Type::Json), 142 => Some(Type::Xml), 143 => Some(Type::XmlArray), @@ -435,8 +423,8 @@ impl Type { 1115 => Some(Type::TimestampArray), 1182 => Some(Type::DateArray), 1183 => Some(Type::TimeArray), - 1184 => Some(Type::TimestampTZ), - 1185 => Some(Type::TimestampTZArray), + 1184 => Some(Type::Timestamptz), + 1185 => Some(Type::TimestamptzArray), 1186 => Some(Type::Interval), 1187 => Some(Type::IntervalArray), 1231 => Some(Type::NumericArray), @@ -481,11 +469,11 @@ impl Type { 3221 => Some(Type::PgLsnArray), 3310 => Some(Type::TsmHandler), 3500 => Some(Type::Anyenum), - 3614 => Some(Type::Tsvector), + 3614 => Some(Type::TsVector), 3615 => Some(Type::Tsquery), - 3642 => Some(Type::Gtsvector), - 3643 => Some(Type::TsvectorArray), - 3644 => Some(Type::GtsvectorArray), + 3642 => Some(Type::GtsVector), + 3643 => Some(Type::TsVectorArray), + 3644 => Some(Type::GtsVectorArray), 3645 => Some(Type::TsqueryArray), 3734 => Some(Type::Regconfig), 3735 => Some(Type::RegconfigArray), @@ -493,7 +481,7 @@ impl Type { 3770 => Some(Type::RegdictionaryArray), 3802 => Some(Type::Jsonb), 3807 => Some(Type::JsonbArray), - 3831 => Some(Type::Anyrange), + 3831 => Some(Type::AnyRange), 3838 => Some(Type::EventTrigger), 3904 => Some(Type::Int4Range), 3905 => Some(Type::Int4RangeArray), @@ -534,10 +522,6 @@ impl Type { Type::Cid => 29, Type::OidVector => 30, Type::PgDdlCommand => 32, - Type::PgType => 71, - Type::PgAttribute => 75, - Type::PgProc => 81, - Type::PgClass => 83, Type::Json => 114, Type::Xml => 142, Type::XmlArray => 143, @@ -604,8 +588,8 @@ impl Type { Type::TimestampArray => 1115, Type::DateArray => 1182, Type::TimeArray => 1183, - Type::TimestampTZ => 1184, - Type::TimestampTZArray => 1185, + Type::Timestamptz => 1184, + Type::TimestamptzArray => 1185, Type::Interval => 1186, Type::IntervalArray => 1187, Type::NumericArray => 1231, @@ -650,11 +634,11 @@ impl Type { Type::PgLsnArray => 3221, Type::TsmHandler => 3310, Type::Anyenum => 3500, - Type::Tsvector => 3614, + Type::TsVector => 3614, Type::Tsquery => 3615, - Type::Gtsvector => 3642, - Type::TsvectorArray => 3643, - Type::GtsvectorArray => 3644, + Type::GtsVector => 3642, + Type::TsVectorArray => 3643, + Type::GtsVectorArray => 3644, Type::TsqueryArray => 3645, Type::Regconfig => 3734, Type::RegconfigArray => 3735, @@ -662,7 +646,7 @@ impl Type { Type::RegdictionaryArray => 3770, Type::Jsonb => 3802, Type::JsonbArray => 3807, - Type::Anyrange => 3831, + Type::AnyRange => 3831, Type::EventTrigger => 3838, Type::Int4Range => 3904, Type::Int4RangeArray => 3905, @@ -751,22 +735,6 @@ impl Type { const V: &'static Kind = &Kind::Pseudo; V } - Type::PgType => { - const V: &'static Kind = &Kind::Simple; - V - } - Type::PgAttribute => { - const V: &'static Kind = &Kind::Simple; - V - } - Type::PgProc => { - const V: &'static Kind = &Kind::Simple; - V - } - Type::PgClass => { - const V: &'static Kind = &Kind::Simple; - V - } Type::Json => { const V: &'static Kind = &Kind::Simple; V @@ -1031,12 +999,12 @@ impl Type { const V: &'static Kind = &Kind::Array(Type::Time); V } - Type::TimestampTZ => { + Type::Timestamptz => { const V: &'static Kind = &Kind::Simple; V } - Type::TimestampTZArray => { - const V: &'static Kind = &Kind::Array(Type::TimestampTZ); + Type::TimestamptzArray => { + const V: &'static Kind = &Kind::Array(Type::Timestamptz); V } Type::Interval => { @@ -1215,7 +1183,7 @@ impl Type { const V: &'static Kind = &Kind::Pseudo; V } - Type::Tsvector => { + Type::TsVector => { const V: &'static Kind = &Kind::Simple; V } @@ -1223,16 +1191,16 @@ impl Type { const V: &'static Kind = &Kind::Simple; V } - Type::Gtsvector => { + Type::GtsVector => { const V: &'static Kind = &Kind::Simple; V } - Type::TsvectorArray => { - const V: &'static Kind = &Kind::Array(Type::Tsvector); + Type::TsVectorArray => { + const V: &'static Kind = &Kind::Array(Type::TsVector); V } - Type::GtsvectorArray => { - const V: &'static Kind = &Kind::Array(Type::Gtsvector); + Type::GtsVectorArray => { + const V: &'static Kind = &Kind::Array(Type::GtsVector); V } Type::TsqueryArray => { @@ -1263,7 +1231,7 @@ impl Type { const V: &'static Kind = &Kind::Array(Type::Jsonb); V } - Type::Anyrange => { + Type::AnyRange => { const V: &'static Kind = &Kind::Pseudo; V } @@ -1296,7 +1264,7 @@ impl Type { V } Type::TstzRange => { - const V: &'static Kind = &Kind::Range(Type::TimestampTZ); + const V: &'static Kind = &Kind::Range(Type::Timestamptz); V } Type::TstzRangeArray => { @@ -1366,10 +1334,6 @@ impl Type { Type::Cid => "cid", Type::OidVector => "oidvector", Type::PgDdlCommand => "pg_ddl_command", - Type::PgType => "pg_type", - Type::PgAttribute => "pg_attribute", - Type::PgProc => "pg_proc", - Type::PgClass => "pg_class", Type::Json => "json", Type::Xml => "xml", Type::XmlArray => "_xml", @@ -1436,8 +1400,8 @@ impl Type { Type::TimestampArray => "_timestamp", Type::DateArray => "_date", Type::TimeArray => "_time", - Type::TimestampTZ => "timestamptz", - Type::TimestampTZArray => "_timestamptz", + Type::Timestamptz => "timestamptz", + Type::TimestamptzArray => "_timestamptz", Type::Interval => "interval", Type::IntervalArray => "_interval", Type::NumericArray => "_numeric", @@ -1482,11 +1446,11 @@ impl Type { Type::PgLsnArray => "_pg_lsn", Type::TsmHandler => "tsm_handler", Type::Anyenum => "anyenum", - Type::Tsvector => "tsvector", + Type::TsVector => "tsvector", Type::Tsquery => "tsquery", - Type::Gtsvector => "gtsvector", - Type::TsvectorArray => "_tsvector", - Type::GtsvectorArray => "_gtsvector", + Type::GtsVector => "gtsvector", + Type::TsVectorArray => "_tsvector", + Type::GtsVectorArray => "_gtsvector", Type::TsqueryArray => "_tsquery", Type::Regconfig => "regconfig", Type::RegconfigArray => "_regconfig", @@ -1494,7 +1458,7 @@ impl Type { Type::RegdictionaryArray => "_regdictionary", Type::Jsonb => "jsonb", Type::JsonbArray => "_jsonb", - Type::Anyrange => "anyrange", + Type::AnyRange => "anyrange", Type::EventTrigger => "event_trigger", Type::Int4Range => "int4range", Type::Int4RangeArray => "_int4range",