@@ -260,51 +260,49 @@ mod chrono {
260
260
type PgTimeTz = sqlx:: postgres:: types:: PgTimeTz < NaiveTime , FixedOffset > ;
261
261
262
262
test_type ! ( chrono_date<NaiveDate >( Postgres ,
263
- "DATE '2001-01-05'" == NaiveDate :: from_ymd ( 2001 , 1 , 5 ) ,
264
- "DATE '2050-11-23'" == NaiveDate :: from_ymd ( 2050 , 11 , 23 )
263
+ "DATE '2001-01-05'" == NaiveDate :: from_ymd_opt ( 2001 , 1 , 5 ) . unwrap ( ) ,
264
+ "DATE '2050-11-23'" == NaiveDate :: from_ymd_opt ( 2050 , 11 , 23 ) . unwrap ( )
265
265
) ) ;
266
266
267
267
test_type ! ( chrono_time<NaiveTime >( Postgres ,
268
- "TIME '05:10:20.115100'" == NaiveTime :: from_hms_micro ( 5 , 10 , 20 , 115100 )
268
+ "TIME '05:10:20.115100'" == NaiveTime :: from_hms_micro_opt ( 5 , 10 , 20 , 115100 ) . unwrap ( )
269
269
) ) ;
270
270
271
271
test_type ! ( chrono_date_time<NaiveDateTime >( Postgres ,
272
- "'2019-01-02 05:10:20'::timestamp" == NaiveDate :: from_ymd ( 2019 , 1 , 2 ) . and_hms ( 5 , 10 , 20 )
272
+ "'2019-01-02 05:10:20'::timestamp" == NaiveDate :: from_ymd_opt ( 2019 , 1 , 2 ) . unwrap ( ) . and_hms_opt ( 5 , 10 , 20 ) . unwrap ( )
273
273
) ) ;
274
274
275
275
test_type ! ( chrono_date_time_vec<Vec <NaiveDateTime >>( Postgres ,
276
276
"array['2019-01-02 05:10:20']::timestamp[]"
277
- == vec![ NaiveDate :: from_ymd ( 2019 , 1 , 2 ) . and_hms ( 5 , 10 , 20 ) ]
277
+ == vec![ NaiveDate :: from_ymd_opt ( 2019 , 1 , 2 ) . unwrap ( ) . and_hms_opt ( 5 , 10 , 20 ) . unwrap ( ) ]
278
278
) ) ;
279
279
280
280
test_type ! ( chrono_date_time_tz_utc<DateTime :: <Utc >>( Postgres ,
281
281
"TIMESTAMPTZ '2019-01-02 05:10:20.115100'"
282
- == DateTime :: <Utc >:: from_utc(
283
- NaiveDate :: from_ymd( 2019 , 1 , 2 ) . and_hms_micro( 5 , 10 , 20 , 115100 ) ,
284
- Utc ,
282
+ == Utc . from_utc_datetime(
283
+ & NaiveDate :: from_ymd_opt( 2019 , 1 , 2 ) . unwrap( ) . and_hms_micro_opt( 5 , 10 , 20 , 115100 ) . unwrap( ) ,
285
284
)
286
285
) ) ;
287
286
288
287
test_type ! ( chrono_date_time_tz<DateTime :: <FixedOffset >>( Postgres ,
289
288
"TIMESTAMPTZ '2019-01-02 05:10:20.115100+06:30'"
290
- == FixedOffset :: east ( 60 * 60 * 6 + 1800 ) . ymd( 2019 , 1 , 2 ) . and_hms_micro ( 5 , 10 , 20 , 115100 )
289
+ == FixedOffset :: east_opt ( 60 * 60 * 6 + 1800 ) . unwrap ( ) . ymd( 2019 , 1 , 2 ) . and_hms_micro_opt ( 5 , 10 , 20 , 115100 ) . unwrap ( )
291
290
) ) ;
292
291
293
292
test_type ! ( chrono_date_time_tz_vec<Vec <DateTime :: <Utc >>>( Postgres ,
294
293
"array['2019-01-02 05:10:20.115100']::timestamptz[]"
295
294
== vec![
296
- DateTime :: <Utc >:: from_utc(
297
- NaiveDate :: from_ymd( 2019 , 1 , 2 ) . and_hms_micro( 5 , 10 , 20 , 115100 ) ,
298
- Utc ,
295
+ Utc . from_utc_datetime(
296
+ & NaiveDate :: from_ymd_opt( 2019 , 1 , 2 ) . unwrap( ) . and_hms_micro_opt( 5 , 10 , 20 , 115100 ) . unwrap( ) ,
299
297
)
300
298
]
301
299
) ) ;
302
300
303
301
test_type ! ( chrono_time_tz<PgTimeTz >( Postgres ,
304
- "TIMETZ '05:10:20.115100+00'" == PgTimeTz { time: NaiveTime :: from_hms_micro ( 5 , 10 , 20 , 115100 ) , offset: FixedOffset :: east ( 0 ) } ,
305
- "TIMETZ '05:10:20.115100+06:30'" == PgTimeTz { time: NaiveTime :: from_hms_micro ( 5 , 10 , 20 , 115100 ) , offset: FixedOffset :: east ( 60 * 60 * 6 + 1800 ) } ,
306
- "TIMETZ '05:10:20.115100-05'" == PgTimeTz { time: NaiveTime :: from_hms_micro ( 5 , 10 , 20 , 115100 ) , offset: FixedOffset :: west ( 60 * 60 * 5 ) } ,
307
- "TIMETZ '05:10:20+02'" == PgTimeTz { time: NaiveTime :: from_hms ( 5 , 10 , 20 ) , offset: FixedOffset :: east ( 60 * 60 * 2 ) }
302
+ "TIMETZ '05:10:20.115100+00'" == PgTimeTz { time: NaiveTime :: from_hms_micro_opt ( 5 , 10 , 20 , 115100 ) . unwrap ( ) , offset: FixedOffset :: east_opt ( 0 ) . unwrap ( ) } ,
303
+ "TIMETZ '05:10:20.115100+06:30'" == PgTimeTz { time: NaiveTime :: from_hms_micro_opt ( 5 , 10 , 20 , 115100 ) . unwrap ( ) , offset: FixedOffset :: east_opt ( 60 * 60 * 6 + 1800 ) . unwrap ( ) } ,
304
+ "TIMETZ '05:10:20.115100-05'" == PgTimeTz { time: NaiveTime :: from_hms_micro_opt ( 5 , 10 , 20 , 115100 ) . unwrap ( ) , offset: FixedOffset :: west_opt ( 60 * 60 * 5 ) . unwrap ( ) } ,
305
+ "TIMETZ '05:10:20+02'" == PgTimeTz { time: NaiveTime :: from_hms_opt ( 5 , 10 , 20 ) . unwrap ( ) , offset: FixedOffset :: east_opt ( 60 * 60 * 2 ) . unwrap ( ) }
308
306
) ) ;
309
307
}
310
308
@@ -586,7 +584,7 @@ test_prepared_type!(citext_array<Vec<PgCiText>>(Postgres,
586
584
#[ cfg( any( postgres_14, postgres_15) ) ]
587
585
test_type ! ( ltree<sqlx:: postgres:: types:: PgLTree >( Postgres ,
588
586
"'Foo.Bar.Baz.Quux'::ltree" == sqlx:: postgres:: types:: PgLTree :: from_str( "Foo.Bar.Baz.Quux" ) . unwrap( ) ,
589
- "'Alpha.Beta.Delta.Gamma'::ltree" == sqlx:: postgres:: types:: PgLTree :: from_iter ( [ "Alpha" , "Beta" , "Delta" , "Gamma" ] ) . unwrap( ) ,
587
+ "'Alpha.Beta.Delta.Gamma'::ltree" == sqlx:: postgres:: types:: PgLTree :: try_from_iter ( [ "Alpha" , "Beta" , "Delta" , "Gamma" ] ) . unwrap( ) ,
590
588
) ) ;
591
589
592
590
// FIXME: needed to disable `ltree` tests in version that don't have a binary format for it
@@ -596,7 +594,7 @@ test_type!(ltree_vec<Vec<sqlx::postgres::types::PgLTree>>(Postgres,
596
594
"array['Foo.Bar.Baz.Quux', 'Alpha.Beta.Delta.Gamma']::ltree[]" ==
597
595
vec![
598
596
sqlx:: postgres:: types:: PgLTree :: from_str( "Foo.Bar.Baz.Quux" ) . unwrap( ) ,
599
- sqlx:: postgres:: types:: PgLTree :: from_iter ( [ "Alpha" , "Beta" , "Delta" , "Gamma" ] ) . unwrap( )
597
+ sqlx:: postgres:: types:: PgLTree :: try_from_iter ( [ "Alpha" , "Beta" , "Delta" , "Gamma" ] ) . unwrap( )
600
598
]
601
599
) ) ;
602
600
0 commit comments