From c40fc64197bac317c16507a26dd1c53b9352900d Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Thu, 11 Sep 2014 21:40:52 -0700 Subject: [PATCH] Reenable types::array We really shouldn't need the 'static bound on T, but that can be fixed another day. --- src/types/array.rs | 8 ++++---- src/types/mod.rs | 10 ++-------- tests/types/mod.rs | 8 ++------ 3 files changed, 8 insertions(+), 18 deletions(-) diff --git a/src/types/array.rs b/src/types/array.rs index 9f3ef79f..41476328 100644 --- a/src/types/array.rs +++ b/src/types/array.rs @@ -201,14 +201,14 @@ impl InternalMutableArray for ArrayBase { } } -enum ArrayParent<'parent, T:'parent> { +enum ArrayParent<'parent, T:'static> { SliceParent(&'parent ArraySlice<'static, T>), MutSliceParent(&'parent MutArraySlice<'static, T>), BaseParent(&'parent ArrayBase), } /// An immutable slice of a multi-dimensional array -pub struct ArraySlice<'parent, T:'parent> { +pub struct ArraySlice<'parent, T:'static> { parent: ArrayParent<'parent, T>, idx: uint, } @@ -253,13 +253,13 @@ impl<'parent, T> InternalArray for ArraySlice<'parent, T> { } } -enum MutArrayParent<'parent, T> { +enum MutArrayParent<'parent, T:'static> { MutSliceMutParent(&'parent mut MutArraySlice<'static, T>), MutBaseParent(&'parent mut ArrayBase), } /// A mutable slice of a multi-dimensional array -pub struct MutArraySlice<'parent, T> { +pub struct MutArraySlice<'parent, T:'static> { parent: MutArrayParent<'parent, T>, idx: uint, } diff --git a/src/types/mod.rs b/src/types/mod.rs index fd5193a8..7e9a4db8 100644 --- a/src/types/mod.rs +++ b/src/types/mod.rs @@ -10,10 +10,10 @@ use time::Timespec; use PostgresResult; use error::{PgWrongType, PgStreamError, PgWasNull, PgBadData}; -//use types::array::{Array, ArrayBase, DimensionInfo}; +use types::array::{Array, ArrayBase, DimensionInfo}; use types::range::{RangeBound, Inclusive, Exclusive, Range}; -//pub mod array; +pub mod array; pub mod range; /// A Postgres OID @@ -107,7 +107,6 @@ macro_rules! make_postgres_type( } } - /* fn member_type(&self) -> PostgresType { match *self { $( @@ -116,7 +115,6 @@ macro_rules! make_postgres_type( _ => unreachable!() } } - */ } ) ) @@ -425,7 +423,6 @@ macro_rules! from_array_impl( ) ) -/* from_array_impl!(PgBoolArray, bool) from_array_impl!(PgByteAArray, Vec) from_array_impl!(PgCharArray, i8) @@ -440,7 +437,6 @@ from_array_impl!(PgFloat8Array, f64) from_array_impl!(PgInt4RangeArray, Range) from_array_impl!(PgTsRangeArray | PgTstzRangeArray, Range) from_array_impl!(PgInt8RangeArray, Range) -*/ impl FromSql for Option>> { fn from_sql(ty: &PostgresType, raw: &Option>) @@ -730,7 +726,6 @@ macro_rules! to_array_impl( ) ) -/* to_array_impl!(PgBoolArray, bool) to_array_impl!(PgByteAArray, Vec) to_array_impl!(PgCharArray, i8) @@ -745,7 +740,6 @@ to_array_impl!(PgInt4RangeArray, Range) to_array_impl!(PgTsRangeArray | PgTstzRangeArray, Range) to_array_impl!(PgInt8RangeArray, Range) to_array_impl!(PgJsonArray, Json) -*/ impl ToSql for HashMap> { fn to_sql(&self, ty: &PostgresType) -> PostgresResult<(Format, Option>)> { diff --git a/tests/types/mod.rs b/tests/types/mod.rs index 1ecc5fbc..f8698213 100644 --- a/tests/types/mod.rs +++ b/tests/types/mod.rs @@ -6,10 +6,10 @@ use time; use time::Timespec; use postgres::{PostgresConnection, NoSsl}; -//use postgres::types::array::ArrayBase; +use postgres::types::array::ArrayBase; use postgres::types::{ToSql, FromSql}; -//mod array; +mod array; mod range; fn test_type(sql_type: &str, checks: &[(T, S)]) { @@ -204,7 +204,6 @@ macro_rules! test_array_params( }) ) -/* #[test] fn test_boolarray_params() { test_array_params!("BOOL", false, "f", true, "t", true, "t"); @@ -315,7 +314,6 @@ fn test_int8rangearray_params() { range!('[' 10i64, ')'), "\"[10,)\"", range!('(', 10i64 ')'), "\"(,10)\""); } -*/ #[test] fn test_hstore_params() { @@ -359,7 +357,6 @@ fn test_f64_nan_param() { test_nan_param::("DOUBLE PRECISION"); } -/* #[test] fn test_jsonarray_params() { test_array_params!("JSON", @@ -370,7 +367,6 @@ fn test_jsonarray_params() { json::from_str(r#"{"a": [10], "b": true}"#).unwrap(), r#""{\"a\": [10], \"b\": true}""#); } -*/ #[test] fn test_pg_database_datname() {