@@ -5,14 +5,14 @@ use byteorder::{ReadBytesExt, WriteBytesExt, BigEndian};
55use self :: chrono:: { Duration , NaiveDate , NaiveTime , NaiveDateTime , DateTime , UTC } ;
66
77use Result ;
8- use types:: { FromSql , ToSql , IsNull , Type } ;
8+ use types:: { FromSql , ToSql , IsNull , Type , SessionInfo } ;
99
1010fn base ( ) -> NaiveDateTime {
1111 NaiveDate :: from_ymd ( 2000 , 1 , 1 ) . and_hms ( 0 , 0 , 0 )
1212}
1313
1414impl FromSql for NaiveDateTime {
15- fn from_sql < R : Read > ( _: & Type , raw : & mut R ) -> Result < NaiveDateTime > {
15+ fn from_sql < R : Read > ( _: & Type , raw : & mut R , _ : & SessionInfo ) -> Result < NaiveDateTime > {
1616 let t = try!( raw. read_i64 :: < BigEndian > ( ) ) ;
1717 Ok ( base ( ) + Duration :: microseconds ( t) )
1818 }
@@ -21,7 +21,7 @@ impl FromSql for NaiveDateTime {
2121}
2222
2323impl ToSql for NaiveDateTime {
24- fn to_sql < W : Write +?Sized > ( & self , _: & Type , mut w : & mut W ) -> Result < IsNull > {
24+ fn to_sql < W : Write +?Sized > ( & self , _: & Type , mut w : & mut W , _ : & SessionInfo ) -> Result < IsNull > {
2525 let t = ( * self - base ( ) ) . num_microseconds ( ) . unwrap ( ) ;
2626 try!( w. write_i64 :: < BigEndian > ( t) ) ;
2727 Ok ( IsNull :: No )
@@ -32,7 +32,7 @@ impl ToSql for NaiveDateTime {
3232}
3333
3434impl FromSql for DateTime < UTC > {
35- fn from_sql < R : Read > ( type_ : & Type , raw : & mut R ) -> Result < DateTime < UTC > > {
35+ fn from_sql < R : Read > ( type_ : & Type , raw : & mut R , _ : & SessionInfo ) -> Result < DateTime < UTC > > {
3636 let naive = try!( NaiveDateTime :: from_sql ( type_, raw) ) ;
3737 Ok ( DateTime :: from_utc ( naive, UTC ) )
3838 }
@@ -41,7 +41,8 @@ impl FromSql for DateTime<UTC> {
4141}
4242
4343impl ToSql for DateTime < UTC > {
44- fn to_sql < W : Write +?Sized > ( & self , type_ : & Type , mut w : & mut W ) -> Result < IsNull > {
44+ fn to_sql < W : Write +?Sized > ( & self , type_ : & Type , mut w : & mut W , _: & SessionInfo )
45+ -> Result < IsNull > {
4546 self . naive_utc ( ) . to_sql ( type_, w)
4647 }
4748
@@ -50,7 +51,7 @@ impl ToSql for DateTime<UTC> {
5051}
5152
5253impl FromSql for NaiveDate {
53- fn from_sql < R : Read > ( _: & Type , raw : & mut R ) -> Result < NaiveDate > {
54+ fn from_sql < R : Read > ( _: & Type , raw : & mut R , _ : & SessionInfo ) -> Result < NaiveDate > {
5455 let jd = try!( raw. read_i32 :: < BigEndian > ( ) ) ;
5556 Ok ( base ( ) . date ( ) + Duration :: days ( jd as i64 ) )
5657 }
@@ -59,7 +60,7 @@ impl FromSql for NaiveDate {
5960}
6061
6162impl ToSql for NaiveDate {
62- fn to_sql < W : Write +?Sized > ( & self , _: & Type , mut w : & mut W ) -> Result < IsNull > {
63+ fn to_sql < W : Write +?Sized > ( & self , _: & Type , mut w : & mut W , _ : & SessionInfo ) -> Result < IsNull > {
6364 let jd = * self - base ( ) . date ( ) ;
6465 try!( w. write_i32 :: < BigEndian > ( jd. num_days ( ) as i32 ) ) ;
6566 Ok ( IsNull :: No )
@@ -70,7 +71,7 @@ impl ToSql for NaiveDate {
7071}
7172
7273impl FromSql for NaiveTime {
73- fn from_sql < R : Read > ( _: & Type , raw : & mut R ) -> Result < NaiveTime > {
74+ fn from_sql < R : Read > ( _: & Type , raw : & mut R , _ : & SessionInfo ) -> Result < NaiveTime > {
7475 let usec = try!( raw. read_i64 :: < BigEndian > ( ) ) ;
7576 Ok ( NaiveTime :: from_hms ( 0 , 0 , 0 ) + Duration :: microseconds ( usec) )
7677 }
@@ -79,7 +80,7 @@ impl FromSql for NaiveTime {
7980}
8081
8182impl ToSql for NaiveTime {
82- fn to_sql < W : Write +?Sized > ( & self , _: & Type , mut w : & mut W ) -> Result < IsNull > {
83+ fn to_sql < W : Write +?Sized > ( & self , _: & Type , mut w : & mut W , _ : & SessionInfo ) -> Result < IsNull > {
8384 let delta = * self - NaiveTime :: from_hms ( 0 , 0 , 0 ) ;
8485 try!( w. write_i64 :: < BigEndian > ( delta. num_microseconds ( ) . unwrap ( ) ) ) ;
8586 Ok ( IsNull :: No )
0 commit comments