File tree Expand file tree Collapse file tree 1 file changed +8
-9
lines changed
sqlx-core/src/mssql/types Expand file tree Collapse file tree 1 file changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -7,28 +7,27 @@ use crate::types::Type;
77
88impl Type < Mssql > for u8 {
99 fn type_info ( ) -> MssqlTypeInfo {
10- < i8 as Type < Mssql > > :: type_info ( )
10+ MssqlTypeInfo ( TypeInfo :: new ( DataType :: IntN , 1 ) )
1111 }
1212
1313 fn compatible ( ty : & MssqlTypeInfo ) -> bool {
14- < i8 as Type < Mssql > > :: compatible ( ty )
14+ matches ! ( ty . 0 . ty , DataType :: TinyInt | DataType :: IntN ) && ty . 0 . size == 1
1515 }
1616}
1717
1818impl Encode < ' _ , Mssql > for u8 {
1919 fn encode_by_ref ( & self , buf : & mut Vec < u8 > ) -> IsNull {
20- let v = i8:: try_from ( * self ) . unwrap_or_else ( |_e| {
21- log:: warn!( "cannot encode {self} as a signed mssql tinyint" ) ;
22- i8:: MAX
23- } ) ;
24- <i8 as Encode < ' _ , Mssql > >:: encode_by_ref ( & v, buf)
20+ buf. extend ( & [ * self ] ) ;
21+ IsNull :: No
2522 }
2623}
2724
2825impl Decode < ' _ , Mssql > for u8 {
2926 fn decode ( value : MssqlValueRef < ' _ > ) -> Result < Self , BoxDynError > {
30- let v = <i8 as Decode < ' _ , Mssql > >:: decode ( value) ?;
31- Ok ( u8:: try_from ( v) ?)
27+ Ok ( * value
28+ . as_bytes ( ) ?
29+ . get ( 0 )
30+ . ok_or ( "Invalid numeric value length" ) ?)
3231 }
3332}
3433
You can’t perform that action at this time.
0 commit comments