File tree Expand file tree Collapse file tree 3 files changed +40
-1
lines changed Expand file tree Collapse file tree 3 files changed +40
-1
lines changed Original file line number Diff line number Diff line change @@ -102,7 +102,7 @@ internal void SetParams()
102
102
for ( var i = 0 ; i < m_outParams . Count ; i ++ )
103
103
{
104
104
var param = m_outParams [ i ] ;
105
- if ( param . HasSetDbType )
105
+ if ( param . HasSetDbType && ! reader . IsDBNull ( i ) )
106
106
{
107
107
var dbTypeMapping = TypeMapper . Instance . GetDbTypeMapping ( param . DbType ) ;
108
108
if ( dbTypeMapping != null )
Original file line number Diff line number Diff line change @@ -55,6 +55,15 @@ OUT value VARCHAR(100)
55
55
BEGIN
56
56
SELECT 'test value' INTO value;
57
57
END" ) ;
58
+ Connection . Execute ( @"DROP PROCEDURE IF EXISTS out_null;
59
+ CREATE PROCEDURE out_null(
60
+ OUT string_value VARCHAR(100),
61
+ OUT int_value INT
62
+ )
63
+ BEGIN
64
+ SELECT NULL INTO string_value;
65
+ SELECT NULL INTO int_value;
66
+ END" ) ;
58
67
Connection . Execute ( @"drop table if exists sproc_multiple_rows;
59
68
create table sproc_multiple_rows (
60
69
value integer not null primary key auto_increment,
Original file line number Diff line number Diff line change @@ -135,6 +135,36 @@ public async Task StoredProcedureOutIncorrectType()
135
135
}
136
136
}
137
137
138
+ [ Fact ]
139
+ public async Task StoredProcedureReturnsNull ( )
140
+ {
141
+ using ( var cmd = m_database . Connection . CreateCommand ( ) )
142
+ {
143
+ cmd . CommandText = "out_null" ;
144
+ cmd . CommandType = CommandType . StoredProcedure ;
145
+ cmd . Parameters . Add ( new MySqlParameter
146
+ {
147
+ ParameterName = "@string_value" ,
148
+ DbType = DbType . String ,
149
+ Direction = ParameterDirection . Output ,
150
+ IsNullable = true ,
151
+ Value = "non null" ,
152
+ } ) ;
153
+ cmd . Parameters . Add ( new MySqlParameter
154
+ {
155
+ ParameterName = "@int_value" ,
156
+ DbType = DbType . Int32 ,
157
+ Direction = ParameterDirection . Output ,
158
+ IsNullable = true ,
159
+ Value = "123" ,
160
+ } ) ;
161
+ await cmd . ExecuteNonQueryAsync ( ) ;
162
+
163
+ Assert . Equal ( DBNull . Value , cmd . Parameters [ "@string_value" ] . Value ) ;
164
+ Assert . Equal ( DBNull . Value , cmd . Parameters [ "@int_value" ] . Value ) ;
165
+ }
166
+ }
167
+
138
168
[ Theory ]
139
169
[ InlineData ( "NonQuery" ) ]
140
170
[ InlineData ( "Scalar" ) ]
You can’t perform that action at this time.
0 commit comments