@@ -12,6 +12,13 @@ use std::ops::Bound;
1212#[ sqlx( transparent) ]
1313struct Transparent ( i32 ) ;
1414
15+ // Also possible for single-field named structs
16+ #[ derive( PartialEq , Debug , sqlx:: Type ) ]
17+ #[ sqlx( transparent) ]
18+ struct TransparentNamed {
19+ field : i32 ,
20+ }
21+
1522#[ derive( PartialEq , Debug , sqlx:: Type ) ]
1623// https://github.com/launchbadge/sqlx/issues/2611
1724// Previously, the derive would generate a `PgHasArrayType` impl that errored on an
@@ -143,11 +150,16 @@ struct FloatRange(PgRange<f64>);
143150#[ sqlx( type_name = "int4rangeL0pC" ) ]
144151struct RangeInclusive ( PgRange < i32 > ) ;
145152
146- test_type ! ( transparent <Transparent >( Postgres ,
153+ test_type ! ( transparent_tuple <Transparent >( Postgres ,
147154 "0" == Transparent ( 0 ) ,
148155 "23523" == Transparent ( 23523 )
149156) ) ;
150157
158+ test_type ! ( transparent_named<TransparentNamed >( Postgres ,
159+ "0" == TransparentNamed { field: 0 } ,
160+ "23523" == TransparentNamed { field: 23523 } ,
161+ ) ) ;
162+
151163test_type ! ( transparent_array<TransparentArray >( Postgres ,
152164 "'{}'::int8[]" == TransparentArray ( vec![ ] ) ,
153165 "'{ 23523, 123456, 789 }'::int8[]" == TransparentArray ( vec![ 23523 , 123456 , 789 ] )
0 commit comments