Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix syntax error executing stored procedures in MySQL using mysqconnector #873

Merged
merged 1 commit into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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