@@ -60,22 +60,27 @@ impl Column {
6060 ColumnType :: Date => match opt. date_time_crate {
6161 DateTimeCrate :: Chrono => "Date" . to_owned ( ) ,
6262 DateTimeCrate :: Time => "TimeDate" . to_owned ( ) ,
63+ DateTimeCrate :: Jiff => "JiffDate" . to_owned ( ) ,
6364 } ,
6465 ColumnType :: Time => match opt. date_time_crate {
6566 DateTimeCrate :: Chrono => "Time" . to_owned ( ) ,
6667 DateTimeCrate :: Time => "TimeTime" . to_owned ( ) ,
68+ DateTimeCrate :: Jiff => "JiffTime" . to_owned ( ) ,
6769 } ,
6870 ColumnType :: DateTime => match opt. date_time_crate {
6971 DateTimeCrate :: Chrono => "DateTime" . to_owned ( ) ,
7072 DateTimeCrate :: Time => "TimeDateTime" . to_owned ( ) ,
73+ DateTimeCrate :: Jiff => "JiffDateTime" . to_owned ( ) ,
7174 } ,
7275 ColumnType :: Timestamp => match opt. date_time_crate {
7376 DateTimeCrate :: Chrono => "DateTimeUtc" . to_owned ( ) ,
7477 DateTimeCrate :: Time => "TimeDateTime" . to_owned ( ) ,
78+ DateTimeCrate :: Jiff => "JiffDateTime" . to_owned ( ) ,
7579 } ,
7680 ColumnType :: TimestampWithTimeZone => match opt. date_time_crate {
7781 DateTimeCrate :: Chrono => "DateTimeWithTimeZone" . to_owned ( ) ,
7882 DateTimeCrate :: Time => "TimeDateTimeWithTimeZone" . to_owned ( ) ,
83+ DateTimeCrate :: Jiff => "JiffTimestamp" . to_owned ( ) ,
7984 } ,
8085 ColumnType :: Decimal ( _) | ColumnType :: Money ( _) => "Decimal" . to_owned ( ) ,
8186 ColumnType :: Uuid => "Uuid" . to_owned ( ) ,
@@ -107,6 +112,7 @@ impl Column {
107112
108113 pub fn get_col_type_attrs ( & self ) -> Option < TokenStream > {
109114 let col_type = match & self . col_type {
115+ ColumnType :: DateTime => Some ( "DateTime" . to_owned ( ) ) ,
110116 ColumnType :: Float => Some ( "Float" . to_owned ( ) ) ,
111117 ColumnType :: Double => Some ( "Double" . to_owned ( ) ) ,
112118 ColumnType :: Decimal ( Some ( ( p, s) ) ) => Some ( format ! ( "Decimal(Some(({p}, {s})))" ) ) ,
@@ -329,6 +335,13 @@ mod tests {
329335 }
330336 }
331337
338+ fn date_time_crate_jiff ( ) -> ColumnOption {
339+ ColumnOption {
340+ date_time_crate : DateTimeCrate :: Jiff ,
341+ big_integer_type : Default :: default ( ) ,
342+ }
343+ }
344+
332345 fn setup ( ) -> Vec < Column > {
333346 macro_rules! make_col {
334347 ( $name: expr, $col_type: expr) => {
@@ -526,6 +539,48 @@ mod tests {
526539 quote!( Option <#rs_type>) . to_string( )
527540 ) ;
528541 }
542+
543+ let columns = setup ( ) ;
544+ let rs_types = vec ! [
545+ "String" ,
546+ "String" ,
547+ "String" ,
548+ "i8" ,
549+ "u8" ,
550+ "i16" ,
551+ "u16" ,
552+ "i32" ,
553+ "u32" ,
554+ "i64" ,
555+ "u64" ,
556+ "f32" ,
557+ "f64" ,
558+ "Vec<u8>" ,
559+ "Vec<u8>" ,
560+ "Vec<u8>" ,
561+ "Vec<u8>" ,
562+ "bool" ,
563+ "JiffDate" ,
564+ "JiffTime" ,
565+ "JiffDateTime" ,
566+ "JiffDateTime" ,
567+ "JiffTimestamp" ,
568+ ] ;
569+ for ( mut col, rs_type) in columns. into_iter ( ) . zip ( rs_types) {
570+ let rs_type: TokenStream = rs_type. parse ( ) . unwrap ( ) ;
571+
572+ col. not_null = true ;
573+ assert_eq ! (
574+ col. get_rs_type( & date_time_crate_jiff( ) ) . to_string( ) ,
575+ quote!( #rs_type) . to_string( )
576+ ) ;
577+
578+ col. not_null = false ;
579+ assert_eq ! (
580+ col. get_rs_type( & date_time_crate_jiff( ) ) . to_string( ) ,
581+ quote!( Option <#rs_type>) . to_string( )
582+ ) ;
583+ }
529584 }
530585
531586 #[ test]
@@ -712,6 +767,55 @@ mod tests {
712767 column. get_info( & date_time_crate_time( ) ) . as_str( ) ,
713768 "Column `timestamp_with_timezone_field`: TimeDateTimeWithTimeZone, not_null"
714769 ) ;
770+ let column: Column = ColumnDef :: new ( Alias :: new ( "date_field" ) )
771+ . date ( )
772+ . not_null ( )
773+ . to_owned ( )
774+ . into ( ) ;
775+ assert_eq ! (
776+ column. get_info( & date_time_crate_jiff( ) ) . as_str( ) ,
777+ "Column `date_field`: JiffDate, not_null"
778+ ) ;
779+
780+ let column: Column = ColumnDef :: new ( Alias :: new ( "time_field" ) )
781+ . time ( )
782+ . not_null ( )
783+ . to_owned ( )
784+ . into ( ) ;
785+ assert_eq ! (
786+ column. get_info( & date_time_crate_jiff( ) ) . as_str( ) ,
787+ "Column `time_field`: JiffTime, not_null"
788+ ) ;
789+
790+ let column: Column = ColumnDef :: new ( Alias :: new ( "date_time_field" ) )
791+ . date_time ( )
792+ . not_null ( )
793+ . to_owned ( )
794+ . into ( ) ;
795+ assert_eq ! (
796+ column. get_info( & date_time_crate_jiff( ) ) . as_str( ) ,
797+ "Column `date_time_field`: JiffDateTime, not_null"
798+ ) ;
799+
800+ let column: Column = ColumnDef :: new ( Alias :: new ( "timestamp_field" ) )
801+ . timestamp ( )
802+ . not_null ( )
803+ . to_owned ( )
804+ . into ( ) ;
805+ assert_eq ! (
806+ column. get_info( & date_time_crate_jiff( ) ) . as_str( ) ,
807+ "Column `timestamp_field`: JiffDateTime, not_null"
808+ ) ;
809+
810+ let column: Column = ColumnDef :: new ( Alias :: new ( "timestamp_with_timezone_field" ) )
811+ . timestamp_with_time_zone ( )
812+ . not_null ( )
813+ . to_owned ( )
814+ . into ( ) ;
815+ assert_eq ! (
816+ column. get_info( & date_time_crate_jiff( ) ) . as_str( ) ,
817+ "Column `timestamp_with_timezone_field`: JiffTimestamp, not_null"
818+ ) ;
715819 }
716820
717821 #[ test]
0 commit comments