@@ -36,6 +36,7 @@ static FLOAT8OID: Oid = 701;
3636static BOOLARRAYOID : Oid = 1000 ;
3737static BYTEAARRAYOID : Oid = 1001 ;
3838static CHARARRAYOID : Oid = 1002 ;
39+ static INT2ARRAYOID : Oid = 1005 ;
3940static INT4ARRAYOID : Oid = 1007 ;
4041static INT8ARRAYOID : Oid = 1016 ;
4142static FLOAT4ARRAYOID : Oid = 1021 ;
@@ -91,6 +92,8 @@ pub enum PostgresType {
9192 PgByteAArray ,
9293 /// "char"[]
9394 PgCharArray ,
95+ /// INT2[]
96+ PgInt2Array ,
9497 /// INT4[]
9598 PgInt4Array ,
9699 /// INT8[]
@@ -143,6 +146,7 @@ impl PostgresType {
143146 BOOLARRAYOID => PgBoolArray ,
144147 BYTEAARRAYOID => PgByteAArray ,
145148 CHARARRAYOID => PgCharArray ,
149+ INT2ARRAYOID => PgInt2Array ,
146150 INT4ARRAYOID => PgInt4Array ,
147151 INT8ARRAYOID => PgInt8Array ,
148152 FLOAT4ARRAYOID => PgFloat4Array ,
@@ -227,6 +231,7 @@ impl RawFromSql for ~[u8] {
227231}
228232
229233raw_from_impl ! ( i8 , read_i8)
234+ raw_from_impl ! ( i16 , read_be_i16)
230235raw_from_impl ! ( i32 , read_be_i32)
231236raw_from_impl ! ( i64 , read_be_i64)
232237raw_from_impl ! ( f32 , read_be_f32)
@@ -267,15 +272,6 @@ macro_rules! from_raw_from_impl(
267272 )
268273)
269274
270- macro_rules! from_conversions_impl(
271- ( $expected: pat, $t: ty, $f: ident) => (
272- from_map_impl!( $expected, $t, |buf| {
273- let mut reader = BufReader :: new( buf. as_slice( ) ) ;
274- reader. $f( )
275- } )
276- )
277- )
278-
279275macro_rules! from_option_impl(
280276 ( $t: ty) => (
281277 impl FromSql for $t {
@@ -294,6 +290,8 @@ from_raw_from_impl!(PgByteA, ~[u8])
294290from_option_impl ! ( ~[ u8 ] )
295291from_raw_from_impl ! ( PgChar , i8 )
296292from_option_impl ! ( i8 )
293+ from_raw_from_impl ! ( PgInt2 , i16 )
294+ from_option_impl ! ( i16 )
297295from_raw_from_impl ! ( PgInt4 , i32 )
298296from_option_impl ! ( i32 )
299297from_raw_from_impl ! ( PgInt8 , i64 )
@@ -303,9 +301,6 @@ from_option_impl!(f32)
303301from_raw_from_impl ! ( PgFloat8 , f64 )
304302from_option_impl ! ( f64 )
305303
306- from_conversions_impl ! ( PgInt2 , i16 , read_be_i16)
307- from_option_impl ! ( i16 )
308-
309304from_map_impl ! ( PgVarchar | PgText | PgCharN , ~str , |buf| {
310305 str :: from_utf8_owned( buf. clone( ) )
311306} )
@@ -416,6 +411,9 @@ from_option_impl!(ArrayBase<Option<~[u8]>>)
416411from_array_impl ! ( PgCharArray , i8 )
417412from_option_impl ! ( ArrayBase <Option <i8 >>)
418413
414+ from_array_impl ! ( PgInt2Array , i16 )
415+ from_option_impl ! ( ArrayBase <Option <i16 >>)
416+
419417from_array_impl ! ( PgInt4Array , i32 )
420418from_option_impl ! ( ArrayBase <Option <i32 >>)
421419
@@ -506,6 +504,7 @@ impl RawToSql for ~[u8] {
506504}
507505
508506raw_to_impl!(i8, write_i8)
507+ raw_to_impl!(i16, write_be_i16)
509508raw_to_impl!(i32, write_be_i32)
510509raw_to_impl!(i64, write_be_i64)
511510raw_to_impl!(f32, write_be_f32)
@@ -567,26 +566,14 @@ macro_rules! to_raw_to_impl(
567566 )
568567)
569568
570- macro_rules! to_conversions_impl(
571- ($($oid:ident)|+, $t:ty, $f:ident) => (
572- impl ToSql for $t {
573- fn to_sql(&self, ty: &PostgresType) -> (Format, Option<~[u8]>) {
574- check_types!($($oid)|+, ty)
575-
576- let mut writer = MemWriter::new();
577- writer.$f(*self);
578- (Binary, Some(writer.inner()))
579- }
580- }
581- )
582- )
583-
584569to_raw_to_impl!(PgBool, bool)
585570to_option_impl!(PgBool, bool)
586571to_raw_to_impl!(PgByteA, ~[u8])
587572to_option_impl!(PgByteA, ~[u8])
588573to_raw_to_impl!(PgChar, i8)
589574to_option_impl!(PgChar, i8)
575+ to_raw_to_impl!(PgInt2, i16)
576+ to_option_impl!(PgInt2, i16)
590577to_raw_to_impl!(PgInt4, i32)
591578to_option_impl!(PgInt4, i32)
592579to_raw_to_impl!(PgInt8, i64)
@@ -596,9 +583,6 @@ to_option_impl!(PgFloat4, f32)
596583to_raw_to_impl!(PgFloat8, f64)
597584to_option_impl!(PgFloat8, f64)
598585
599- to_conversions_impl!(PgInt2, i16, write_be_i16)
600- to_option_impl!(PgInt2, i16)
601-
602586impl ToSql for ~str {
603587 fn to_sql(&self, ty: &PostgresType) -> (Format, Option<~[u8]>) {
604588 check_types!(PgVarchar | PgText | PgCharN, ty)
@@ -744,6 +728,9 @@ to_option_impl!(PgByteAArray, ArrayBase<Option<~[u8]>>)
744728to_array_impl!(PgCharArray, CHAROID, i8)
745729to_option_impl!(PgCharArray, ArrayBase<Option<i8>>)
746730
731+ to_array_impl!(PgInt2Array, INT2OID, i16)
732+ to_option_impl!(PgInt2Array, ArrayBase<Option<i16>>)
733+
747734to_array_impl!(PgInt4Array, INT4OID, i32)
748735to_option_impl!(PgInt4Array, ArrayBase<Option<i32>>)
749736
0 commit comments