8000 Update CachedProcedure.cs (#1432) · mysql-net/MySqlConnector@8fffc06 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8fffc06

Browse files
Update CachedProcedure.cs (#1432)
Fix InvalidCastException when using StoredProcedure with MySQL 5.0 Signed-off-by: Yong Yao <yong.yao@comtechtel.com> Signed-off-by: Bradley Grainger <bgrainger@gmail.com> Co-authored-by: Bradley Grainger <bgrainger@gmail.com>
1 parent 77479f0 commit 8fffc06

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/MySqlConnector/Core/CachedProcedure.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,15 @@ internal sealed class CachedProcedure
3030
if (!exists)
3131
return null;
3232

33-
var parametersSqlBytes = (byte[]) reader.GetValue(0);
34-
var returnsSqlBytes = (byte[]) reader.GetValue(1);
35-
3633
// ASSUME this is UTF-8 encoded; it's possible that the `character_set_client` column would need to be used?
34+
var parametersSqlBytes = (byte[]) reader.GetValue(0);
3735
var parametersSql = Encoding.UTF8.GetString(parametersSqlBytes);
38-
var returnsSql = Encoding.UTF8.GetString(returnsSqlBytes);
36+
37+
var returnsSql = reader.GetValue(1) switch
38+
{
39+
string s => s,
40+
object o => Encoding.UTF8.GetString((byte[]) o),
41+
};
3942

4043
var parsedParameters = ParseParameters(parametersSql);
4144
if (returnsSql.Length != 0)

0 commit comments

Comments
 (0)
0