Skip to content

Commit

Permalink
Fix syntax error when executing stored procedures in MySQL using mysq…
Browse files Browse the repository at this point in the history
…lconnector. (#873)

(cherry picked from commit 2d21345)
  • Loading branch information
claudiamurialdo committed Sep 15, 2023
1 parent e90f512 commit 68e5cea
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 32 deletions.
43 changes: 12 additions & 31 deletions dotnet/src/dotnetframework/GxClasses/Data/GXDataMysqlConnector.cs
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
using System;
using System.Data;
using System.Data.Common;
using System.Linq;
using System.Reflection;
using System.Security;
using System.Text;
using GeneXus.Application;
using GeneXus.Cache;
using GeneXus.Utils;
using GxClasses.Helpers;
using log4net;
using MySQLCommand = MySqlConnector.MySqlCommand;
using MySQLParameter = MySqlConnector.MySqlParameter;
using MySQLConnection = MySqlConnector.MySqlConnection;
using MySQLException = MySqlConnector.MySqlException;
using MySQLDbType = MySqlConnector.MySqlDbType;
using MySQLDataAdapter = MySqlConnector.MySqlDataAdapter;
using System.IO;
using GxClasses.Helpers;
using System.Reflection;
using System;
using System.Data;
using System.Data.Common;
using System.Text;
using System.Collections.Generic;
using System.Security;
using MySQLDbType = MySqlConnector.MySqlDbType;
using MySQLException = MySqlConnector.MySqlException;
using MySQLParameter = MySqlConnector.MySqlParameter;

namespace GeneXus.Data
{

public class GxMySqlConnector : GxDataRecord
{
static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Data.GxMySqlConnector));
Expand Down Expand Up @@ -49,27 +48,9 @@ public override GxAbstractConnectionWrapper GetConnection(bool showPrompt, strin
return new MySqlConnectorConnectionWrapper(m_connectionString, connectionCache, isolationLevel);
}

string convertToMySqlCall(string stmt, GxParameterCollection parameters)
{
if (parameters == null)
return "";
string pname;
StringBuilder sBld = new StringBuilder();
for (int i = 0; i < parameters.Count; i++)
{
if (i > 0)
sBld.Append(", ");
pname = "@" + parameters[i].ParameterName;
sBld.Append(pname);
parameters[i].ParameterName = pname;
}
return "CALL " + stmt + "(" + sBld.ToString() + ")";
}
[SecuritySafeCritical]
public override IDbCommand GetCommand(IGxConnection con, string stmt, GxParameterCollection parameters, bool isCursor, bool forFirst, bool isRpc)
{
if (isRpc)
stmt = convertToMySqlCall(stmt, parameters);
MySQLCommand mysqlcmd = (MySQLCommand)base.GetCommand(con, stmt, parameters.Distinct());
if (isCursor && !isRpc)
{
Expand Down
6 changes: 5 additions & 1 deletion dotnet/src/dotnetframework/GxClasses/Domain/GxCollections.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ public int Add(IDataParameter value)
{
return parameters.Add(value);
}

internal void Reverse()
{
parameters.Reverse();
}
public void Clear()
{
parameters.Clear();
Expand Down Expand Up @@ -158,6 +161,7 @@ public GxParameterCollection Distinct()
parms.Add(this[j].ParameterName);
}
}
uniqueParms.Reverse();
return uniqueParms;
}
else
Expand Down

0 comments on commit 68e5cea

Please sign in to comment.