Skip to content

Commit 7d07e61

Browse files
committed
Remove fixmes in Type builder
1 parent dede118 commit 7d07e61

5 files changed

Lines changed: 52 additions & 99 deletions

File tree

codegen/src/types.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,6 @@ fn parse_types(ranges: &BTreeMap<u32, u32>) -> BTreeMap<u32, Type> {
7171

7272
let variant = match name {
7373
"anyarray" => "AnyArray".to_owned(),
74-
// FIXME remove following overrides for 0.12
75-
"anyrange" => "Anyrange".to_owned(),
76-
"tsvector" => "Tsvector".to_owned(),
77-
"gtsvector" => "Gtsvector".to_owned(),
78-
"_tsvector" => "TsvectorArray".to_owned(),
79-
"_gtsvector" => "GtsvectorArray".to_owned(),
80-
"timestamptz" => "TimestampTZ".to_owned(),
81-
"_timestamptz" => "TimestampTZArray".to_owned(),
8274
name => {
8375
let variant = range_vector_re.replace(name, "_$1");
8476
let variant = array_re.replace(&variant, "$1_array");
@@ -88,13 +80,10 @@ fn parse_types(ranges: &BTreeMap<u32, u32>) -> BTreeMap<u32, Type> {
8880

8981
let kind = split[11];
9082

91-
// FIXME enable for 0.12
92-
/*
9383
// we need to be able to pull composite fields and enum variants at runtime
9484
if kind == "C" || kind == "E" {
9585
continue;
9686
}
97-
*/
9887

9988
let element = if let Some(&element) = ranges.get(&oid) {
10089
element

src/types/chrono.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl FromSql for DateTime<UTC> {
4646
Ok(DateTime::from_utc(naive, UTC))
4747
}
4848

49-
accepts!(Type::TimestampTZ);
49+
accepts!(Type::Timestamptz);
5050
}
5151

5252
impl ToSql for DateTime<UTC> {
@@ -58,7 +58,7 @@ impl ToSql for DateTime<UTC> {
5858
self.naive_utc().to_sql(type_, w, info)
5959
}
6060

61-
accepts!(Type::TimestampTZ);
61+
accepts!(Type::Timestamptz);
6262
to_sql_checked!();
6363
}
6464

@@ -68,7 +68,7 @@ impl FromSql for DateTime<Local> {
6868
Ok(utc.with_timezone(&Local))
6969
}
7070

71-
accepts!(Type::TimestampTZ);
71+
accepts!(Type::Timestamptz);
7272
}
7373

7474
impl ToSql for DateTime<Local> {
@@ -80,7 +80,7 @@ impl ToSql for DateTime<Local> {
8080
self.with_timezone(&UTC).to_sql(type_, w, info)
8181
}
8282

83-
accepts!(Type::TimestampTZ);
83+
accepts!(Type::Timestamptz);
8484
to_sql_checked!();
8585
}
8686

@@ -93,7 +93,7 @@ impl FromSql for DateTime<FixedOffset> {
9393
Ok(utc.with_timezone(&FixedOffset::east(0)))
9494
}
9595

96-
accepts!(Type::TimestampTZ);
96+
accepts!(Type::Timestamptz);
9797
}
9898

9999
impl ToSql for DateTime<FixedOffset> {
@@ -105,7 +105,7 @@ impl ToSql for DateTime<FixedOffset> {
105105
self.with_timezone(&UTC).to_sql(type_, w, info)
106106
}
107107

108-
accepts!(Type::TimestampTZ);
108+
accepts!(Type::Timestamptz);
109109
to_sql_checked!();
110110
}
111111

src/types/special.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ impl<T: ToSql> ToSql for Date<T> {
6161
to_sql_checked!();
6262
}
6363

64-
/// A wrapper that can be used to represent infinity with `Type::Timestamp` and `Type::TimestampTZ`
64+
/// A wrapper that can be used to represent infinity with `Type::Timestamp` and `Type::Timestamptz`
6565
/// types.
6666
#[derive(Debug, Clone, Copy, PartialEq)]
6767
pub enum Timestamp<T> {
@@ -75,7 +75,7 @@ pub enum Timestamp<T> {
7575

7676
impl<T: FromSql> FromSql for Timestamp<T> {
7777
fn from_sql<R: Read>(ty: &Type, raw: &mut R, ctx: &SessionInfo) -> Result<Self> {
78-
if *ty != Type::Timestamp && *ty != Type::TimestampTZ {
78+
if *ty != Type::Timestamp && *ty != Type::Timestamptz {
7979
return Err(Error::Conversion("expected timestamp or timestamptz type".into()));
8080
}
8181

@@ -90,13 +90,13 @@ impl<T: FromSql> FromSql for Timestamp<T> {
9090
}
9191

9292
fn accepts(ty: &Type) -> bool {
93-
(*ty == Type::Timestamp || *ty == Type::TimestampTZ) && T::accepts(ty)
93+
(*ty == Type::Timestamp || *ty == Type::Timestamptz) && T::accepts(ty)
9494
}
9595
}
9696

9797
impl<T: ToSql> ToSql for Timestamp<T> {
9898
fn to_sql<W: Write+?Sized>(&self, ty: &Type, out: &mut W, ctx: &SessionInfo) -> Result<IsNull> {
99-
if *ty != Type::Timestamp && *ty != Type::TimestampTZ {
99+
if *ty != Type::Timestamp && *ty != Type::Timestamptz {
100100
return Err(Error::Conversion("expected timestamp or timestamptz type".into()));
101101
}
102102

@@ -111,7 +111,7 @@ impl<T: ToSql> ToSql for Timestamp<T> {
111111
}
112112

113113
fn accepts(ty: &Type) -> bool {
114-
(*ty == Type::Timestamp || *ty == Type::TimestampTZ) && T::accepts(ty)
114+
(*ty == Type::Timestamp || *ty == Type::Timestamptz) && T::accepts(ty)
115115
}
116116

117117
to_sql_checked!();

src/types/time.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ impl FromSql for Timespec {
2727
Ok(Timespec::new(sec, (usec * NSEC_PER_USEC) as i32))
2828
}
2929

30-
accepts!(Type::Timestamp, Type::TimestampTZ);
30+
accepts!(Type::Timestamp, Type::Timestamptz);
3131
}
3232

3333
impl ToSql for Timespec {
@@ -41,6 +41,6 @@ impl ToSql for Timespec {
4141
Ok(IsNull::No)
4242
}
4343

44-
accepts!(Type::Timestamp, Type::TimestampTZ);
44+
accepts!(Type::Timestamp, Type::Timestamptz);
4545
to_sql_checked!();
4646
}

0 commit comments

Comments
 (0)