Skip to content

Commit

Permalink
try MySqlConnector
Browse files Browse the repository at this point in the history
  • Loading branch information
rpkyle committed Oct 29, 2024
1 parent 957a262 commit ec3388f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
26 changes: 13 additions & 13 deletions src/server/Services/Compiler/SqlProviderQueryExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,21 +86,21 @@ public override async Task<ILeafDbDataReader> ExecuteReaderAsync(
*/
public class MySqlQueryExecutor : BaseQueryExecutor
{
MySql.Data.MySqlClient.MySqlDbType ToSqlType(object val)
MySqlConnector.MySqlDbType ToSqlType(object val)
{
if (val is string) return MySql.Data.MySqlClient.MySqlDbType.String;
if (val is decimal) return MySql.Data.MySqlClient.MySqlDbType.Decimal;
if (val is double) return MySql.Data.MySqlClient.MySqlDbType.Double;
if (val is int) return MySql.Data.MySqlClient.MySqlDbType.Int32;
if (val is bool) return MySql.Data.MySqlClient.MySqlDbType.Bit;
if (val is Guid) return MySql.Data.MySqlClient.MySqlDbType.Guid;
if (val is DateTime) return MySql.Data.MySqlClient.MySqlDbType.DateTime;
return MySql.Data.MySqlClient.MySqlDbType.String;
if (val is string) return MySqlConnector.MySqlDbType.String;
if (val is decimal) return MySqlConnector.MySqlDbType.Decimal;
if (val is double) return MySqlConnector.MySqlDbType.Double;
if (val is int) return MySqlConnector.MySqlDbType.Int32;
if (val is bool) return MySqlConnector.MySqlDbType.Bit;
if (val is Guid) return MySqlConnector.MySqlDbType.Guid;
if (val is DateTime) return MySqlConnector.MySqlDbType.DateTime;
return MySqlConnector.MySqlDbType.String;
}

MySql.Data.MySqlClient.MySqlParameter ToSqlParameter(QueryParameter q)
MySqlConnector.MySqlParameter ToSqlParameter(QueryParameter q)
{
var parameter = new MySql.Data.MySqlClient.MySqlParameter($"?{q.Name}", ToSqlType(q.Value));
var parameter = new MySqlConnector.MySqlParameter($"?{q.Name}", ToSqlType(q.Value));
parameter.Value = q.Value;

return parameter;
Expand All @@ -114,11 +114,11 @@ public override async Task<ILeafDbDataReader> ExecuteReaderAsync(
IEnumerable<QueryParameter> parameters)
{
// Open connection
var conn = new MySql.Data.MySqlClient.MySqlConnection(connStr);
var conn = new MySqlConnector.MySqlConnection(connStr);
await conn.OpenAsync();

// Create command
var cmd = new MySql.Data.MySqlClient.MySqlCommand(query, conn);
var cmd = new MySqlConnector.MySqlCommand(query, conn);
cmd.CommandTimeout = timeout;
cmd.Parameters.AddRange(parameters.Select(p => ToSqlParameter(p)).ToArray());

Expand Down
4 changes: 2 additions & 2 deletions src/server/Services/Services.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<PackageReference Include="Microsoft.Extensions.Hosting" Version="2.2.0" />
<PackageReference Include="System.DirectoryServices.AccountManagement" Version="4.5.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="MySql.Data" Version="8.0.28" />
<PackageReference Include="MySqlConnector" Version="2.3.7" />
<PackageReference Include="Npgsql" Version="6.0.2" />
<PackageReference Include="System.Data.OracleClient" Version="1.0.8" />
<PackageReference Include="Google.Cloud.BigQuery.V2" Version="2.3.0" />
Expand All @@ -44,7 +44,7 @@
<ItemGroup>
<None Remove="Admin\Notification\" />
<None Remove="Compiler\" />
<None Remove="MySql.Data" />
<None Remove="MySqlConnector" />
<None Remove="Npgsql" />
<None Remove="System.Data.OracleClient" />
<None Remove="Google.Cloud.BigQuery.V2" />
Expand Down

0 comments on commit ec3388f

Please sign in to comment.