From 57146672abc93b8e2379188ed4563d02b669d3f8 Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Mon, 2 Sep 2013 18:14:22 -0400 Subject: [PATCH] Support for "char" type --- src/test.rs | 5 +++++ src/types.rs | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/test.rs b/src/test.rs index 5a40c8b0..98d7dd3b 100644 --- a/src/test.rs +++ b/src/test.rs @@ -119,6 +119,11 @@ fn test_bool_params() { test_type("BOOL", [Some(true), Some(false), None]); } +#[test] +fn test_i8_params() { + test_type("\"char\"", [Some(0i8), Some(127i8), None]); +} + #[test] fn test_i16_params() { test_type("SMALLINT", [Some(0x0011i16), Some(-0x0011i16), None]); diff --git a/src/types.rs b/src/types.rs index 0b67d6fe..e2e4faa8 100644 --- a/src/types.rs +++ b/src/types.rs @@ -13,6 +13,7 @@ pub type Oid = i32; // Values from pg_type.h static BOOLOID: Oid = 16; static BYTEAOID: Oid = 17; +static CHAROID: Oid = 18; static INT8OID: Oid = 20; static INT2OID: Oid = 21; static INT4OID: Oid = 23; @@ -92,6 +93,8 @@ macro_rules! from_option_impl( from_map_impl!(BOOLOID, bool, |buf| { buf[0] != 0 }) from_option_impl!(bool) +from_conversions_impl!(CHAROID, i8, read_i8_) +from_option_impl!(i8) from_conversions_impl!(INT2OID, i16, read_be_i16_) from_option_impl!(i16) from_conversions_impl!(INT4OID, i32, read_be_i32_) @@ -179,6 +182,8 @@ impl ToSql for bool { } to_option_impl!(BOOLOID, bool) +to_conversions_impl!(CHAROID, i8, write_i8_) +to_option_impl!(CHAROID, i8) to_conversions_impl!(INT2OID, i16, write_be_i16_) to_option_impl!(INT2OID, i16) to_conversions_impl!(INT4OID, i32, write_be_i32_)