File tree Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ pub(super) struct ToSqlHelper {
12
12
fn to_value ( ( metadata, bind) : ( MysqlType , Option < Vec < u8 > > ) ) -> Value {
13
13
match bind {
14
14
Some ( bind) => match metadata {
15
- MysqlType :: Tiny => Value :: Int ( bind[ 0 ] as _ ) ,
15
+ MysqlType :: Tiny => Value :: Int ( ( bind[ 0 ] as i8 ) as i64 ) ,
16
16
MysqlType :: Short => Value :: Int ( i16:: from_ne_bytes ( bind. try_into ( ) . unwrap ( ) ) as _ ) ,
17
17
MysqlType :: Long => Value :: Int ( i32:: from_ne_bytes ( bind. try_into ( ) . unwrap ( ) ) as _ ) ,
18
18
MysqlType :: LongLong => Value :: Int ( i64:: from_ne_bytes ( bind. try_into ( ) . unwrap ( ) ) ) ,
Original file line number Diff line number Diff line change @@ -67,6 +67,36 @@ async fn check_tiny_int() {
67
67
type_check :: < _ , sql_types:: TinyInt > ( conn, -1_i8 ) . await ;
68
68
type_check :: < _ , sql_types:: TinyInt > ( conn, i8:: MIN ) . await ;
69
69
type_check :: < _ , sql_types:: TinyInt > ( conn, i8:: MAX ) . await ;
70
+
71
+ #[ derive( QueryableByName , Debug ) ]
72
+ #[ diesel( table_name = test_small) ]
73
+ struct Test {
74
+ id : i8 ,
75
+ }
76
+
77
+ table ! ( test_small( id) {
78
+ id -> TinyInt ,
79
+ } ) ;
80
+
81
+ // test case for https://github.com/weiznich/diesel_async/issues/91
82
+ diesel:: sql_query ( "drop table if exists test_small" )
83
+ . execute ( conn)
84
+ . await
85
+ . unwrap ( ) ;
86
+ diesel:: sql_query ( "create table test_small(id smallint primary key)" )
87
+ . execute ( conn)
88
+ . await
89
+ . unwrap ( ) ;
90
+ diesel:: sql_query ( "insert into test_small(id) values(-1)" )
91
+ . execute ( conn)
92
+ . await
93
+ . unwrap ( ) ;
94
+ let got = diesel:: sql_query ( "select id from test_small where id = ?" )
95
+ . bind :: < sql_types:: TinyInt , _ > ( -1 )
96
+ . load :: < Test > ( conn)
97
+ . await
98
+ . unwrap ( ) ;
99
+ assert_eq ! ( got[ 0 ] . id, -1 ) ;
70
100
}
71
101
72
102
#[ cfg( feature = "mysql" ) ]
You can’t perform that action at this time.
0 commit comments