Skip to content

Commit 3520024

Browse files
committed
Update 2.3.9
1 parent 62548cb commit 3520024

File tree

27 files changed

+287
-181
lines changed

27 files changed

+287
-181
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace Devart.Data.MySql.InfoObjects
2+
{
3+
public class ColumnWithValue
4+
{
5+
public string TableName { get; set; }
6+
public string ColumnName { get; set; }
7+
public string MySqlDataType { get; set; }
8+
public object Value { get; set; }
9+
}
10+
}

source code/MySqlBackup(Devart-Express)/InfoObjects/ExportInformations.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System;
1+
using Devart.Data.MySql.InfoObjects;
2+
using System;
23
using System.Collections.Generic;
34
using System.Text;
45

@@ -267,6 +268,11 @@ public Dictionary<string, string> TablesToBeExportedDic
267268
/// </summary>
268269
public bool InsertLineBreakBetweenInserts = false;
269270

271+
/// <summary>
272+
/// Returns the row's default column value. Set this value if you wish to change the row's column value before exporting.
273+
/// </summary>
274+
public Func<ColumnWithValue, object> AdjustColumnValue = (ColumnWithValue columnInfo) => columnInfo.Value;
275+
270276
public ExportInformations()
271277
{
272278

source code/MySqlBackup(Devart-Express)/Methods/QueryExpress.cs

Lines changed: 40 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -310,64 +310,54 @@ public static string ConvertToSqlFormat(object ob, bool wrapStringWithSingleQuot
310310
if (wrapStringWithSingleQuote)
311311
sb.AppendFormat("'");
312312
}
313-
//else if (ob is MySql.Data.Types.MySqlDateTime)
313+
//else if (ob is MySqlDateTime mdt)
314314
//{
315-
// MySql.Data.Types.MySqlDateTime mdt = (MySql.Data.Types.MySqlDateTime)ob;
316-
317-
// if (mdt.IsNull)
315+
// if (mdt.IsValidDateTime)
318316
// {
319-
// sb.AppendFormat("NULL");
317+
// DateTime dtime = mdt.GetDateTime();
318+
319+
// if (wrapStringWithSingleQuote)
320+
// sb.AppendFormat("'");
321+
322+
// if (col.MySqlDataType == "datetime")
323+
// sb.AppendFormat(dtime.ToString("yyyy-MM-dd HH:mm:ss", _dateFormatInfo));
324+
// else if (col.MySqlDataType == "date")
325+
// sb.AppendFormat(dtime.ToString("yyyy-MM-dd", _dateFormatInfo));
326+
// else if (col.MySqlDataType == "time")
327+
// sb.AppendFormat("{0}:{1}:{2}", mdt.Hour, mdt.Minute, mdt.Second);
328+
// else
329+
// sb.AppendFormat(dtime.ToString("yyyy-MM-dd HH:mm:ss", _dateFormatInfo));
330+
331+
// if (col.TimeFractionLength > 0)
332+
// {
333+
// sb.Append(".");
334+
// sb.Append(((MySqlDateTime)ob).Microsecond.ToString().PadLeft(col.TimeFractionLength, '0'));
335+
// }
336+
337+
// if (wrapStringWithSingleQuote)
338+
// sb.AppendFormat("'");
320339
// }
321340
// else
322341
// {
323-
// if (mdt.IsValidDateTime)
324-
// {
325-
// DateTime dtime = mdt.Value;
326-
327-
// if (wrapStringWithSingleQuote)
328-
// sb.AppendFormat("'");
329-
330-
// if (col.MySqlDataType == "datetime")
331-
// sb.AppendFormat(dtime.ToString("yyyy-MM-dd HH:mm:ss", _dateFormatInfo));
332-
// else if (col.MySqlDataType == "date")
333-
// sb.AppendFormat(dtime.ToString("yyyy-MM-dd", _dateFormatInfo));
334-
// else if (col.MySqlDataType == "time")
335-
// sb.AppendFormat("{0}:{1}:{2}", mdt.Hour, mdt.Minute, mdt.Second);
336-
// //sb.AppendFormat(dtime.ToString("HH:mm:ss", _dateFormatInfo));
337-
// else
338-
// sb.AppendFormat(dtime.ToString("yyyy-MM-dd HH:mm:ss", _dateFormatInfo));
339-
340-
// if (col.TimeFractionLength > 0)
341-
// {
342-
// sb.Append(".");
343-
// sb.Append(((MySql.Data.Types.MySqlDateTime)ob).Microsecond.ToString().PadLeft(col.TimeFractionLength, '0'));
344-
// }
345-
346-
// if (wrapStringWithSingleQuote)
347-
// sb.AppendFormat("'");
348-
// }
342+
// if (wrapStringWithSingleQuote)
343+
// sb.AppendFormat("'");
344+
345+
// if (col.MySqlDataType == "datetime")
346+
// sb.AppendFormat("0000-00-00 00:00:00");
347+
// else if (col.MySqlDataType == "date")
348+
// sb.AppendFormat("0000-00-00");
349+
// else if (col.MySqlDataType == "time")
350+
// sb.AppendFormat("00:00:00");
349351
// else
352+
// sb.AppendFormat("0000-00-00 00:00:00");
353+
354+
// if (col.TimeFractionLength > 0)
350355
// {
351-
// if (wrapStringWithSingleQuote)
352-
// sb.AppendFormat("'");
353-
354-
// if (col.MySqlDataType == "datetime")
355-
// sb.AppendFormat("0000-00-00 00:00:00");
356-
// else if (col.MySqlDataType == "date")
357-
// sb.AppendFormat("0000-00-00");
358-
// else if (col.MySqlDataType == "time")
359-
// sb.AppendFormat("00:00:00");
360-
// else
361-
// sb.AppendFormat("0000-00-00 00:00:00");
362-
363-
// if (col.TimeFractionLength > 0)
364-
// {
365-
// sb.Append(".".PadRight(col.TimeFractionLength, '0'));
366-
// }
367-
368-
// if (wrapStringWithSingleQuote)
369-
// sb.AppendFormat("'");
356+
// sb.Append(".".PadRight(col.TimeFractionLength, '0'));
370357
// }
358+
359+
// if (wrapStringWithSingleQuote)
360+
// sb.AppendFormat("'");
371361
// }
372362
//}
373363
else if (ob is System.Guid)

source code/MySqlBackup(Devart-Express)/MySqlBackup(Devart-Express).csproj

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net46;net47;net48;net481</TargetFrameworks>
4+
<TargetFrameworks>net40;net45;net46;net47;net48;net481</TargetFrameworks>
55
<RootNamespace>Devart.Data.MySql</RootNamespace>
66
<AssemblyName>MySqlBackupNet.DevartExpress</AssemblyName>
77
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
@@ -15,10 +15,11 @@
1515
<RepositoryUrl>https://github.com/MySqlBackupNET/MySqlBackup.Net.git</RepositoryUrl>
1616
<RepositoryType>git</RepositoryType>
1717
<PackageTags>mysqlbackup;devart;mysql</PackageTags>
18-
<Version>2.3.8</Version>
19-
<AssemblyVersion>2.3.8</AssemblyVersion>
20-
<FileVersion>2.3.8</FileVersion>
18+
<Version>2.3.9</Version>
19+
<AssemblyVersion>2.3.9</AssemblyVersion>
20+
<FileVersion>2.3.9</FileVersion>
2121
<PackageLicenseExpression>Unlicense</PackageLicenseExpression>
22+
<Title>MySqlBackup.Net for dotConnect.Express.for.MySQL (Devart)</Title>
2223
</PropertyGroup>
2324

2425
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|netstandard2.0|AnyCPU'">
@@ -86,7 +87,7 @@
8687
</PropertyGroup>
8788

8889
<ItemGroup>
89-
<PackageReference Include="dotConnect.Express.for.MySQL" Version="9.1.134" />
90+
<PackageReference Include="dotConnect.Express.for.MySQL" Version="9.4.193" />
9091
</ItemGroup>
9192

9293
</Project>

source code/MySqlBackup(Devart-Express)/MySqlBackup.cs

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Linq;
55
using System.Text;
66
using System.Timers;
7+
using Devart.Data.MySql.InfoObjects;
78

89
namespace Devart.Data.MySql
910
{
@@ -804,8 +805,15 @@ private string Export_GetValueString(MySqlDataReader rdr, MySqlTable table)
804805
object ob = rdr[i];
805806
var col = table.Columns[columnName];
806807

808+
var adjustedValue = ExportInfo.AdjustColumnValue(new InfoObjects.ColumnWithValue
809+
{
810+
TableName = table.Name,
811+
Value = ob,
812+
ColumnName = columnName,
813+
MySqlDataType = col.MySqlDataType
814+
});
807815
//sb.Append(QueryExpress.ConvertToSqlFormat(rdr, i, true, true, col));
808-
sb.Append(QueryExpress.ConvertToSqlFormat(ob, true, true, col, ExportInfo.BlobExportMode));
816+
sb.Append(QueryExpress.ConvertToSqlFormat(adjustedValue, true, true, col, ExportInfo.BlobExportMode));
809817
}
810818

811819
sb.AppendFormat(")");
@@ -832,8 +840,16 @@ private void Export_GetUpdateString(MySqlDataReader rdr, MySqlTable table, Strin
832840
sb.Append("`");
833841
sb.Append(colName);
834842
sb.Append("`=");
843+
844+
var adjustedValue = ExportInfo.AdjustColumnValue(new InfoObjects.ColumnWithValue
845+
{
846+
TableName = table.Name,
847+
Value = rdr[i],
848+
ColumnName = colName,
849+
MySqlDataType = col.MySqlDataType
850+
});
835851
//sb.Append(QueryExpress.ConvertToSqlFormat(rdr, i, true, true, col));
836-
sb.Append(QueryExpress.ConvertToSqlFormat(rdr[i], true, true, col, ExportInfo.BlobExportMode));
852+
sb.Append(QueryExpress.ConvertToSqlFormat(adjustedValue, true, true, col, ExportInfo.BlobExportMode));
837853
}
838854
}
839855
}
@@ -858,8 +874,16 @@ private void Export_GetConditionString(MySqlDataReader rdr, MySqlTable table, St
858874
sb.Append("`");
859875
sb.Append(colName);
860876
sb.Append("`=");
877+
878+
var adjustedValue = ExportInfo.AdjustColumnValue(new InfoObjects.ColumnWithValue
879+
{
880+
TableName = table.Name,
881+
Value = rdr[i],
882+
ColumnName = colName,
883+
MySqlDataType = col.MySqlDataType
884+
});
861885
//sb.Append(QueryExpress.ConvertToSqlFormat(rdr, i, true, true, col));
862-
sb.Append(QueryExpress.ConvertToSqlFormat(rdr[i], true, true, col, ExportInfo.BlobExportMode));
886+
sb.Append(QueryExpress.ConvertToSqlFormat(adjustedValue, true, true, col, ExportInfo.BlobExportMode));
863887
}
864888
}
865889
}

source code/MySqlBackup(Devart-Express)/MySqlObjects/MySqlFunction.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{
33
public class MySqlFunction
44
{
5-
string _name = string.Empty;
5+
string _name;
66
string _createFunctionSQL = string.Empty;
77
string _createFunctionSqlWithoutDefiner = string.Empty;
88

source code/MySqlBackup(Devart-Express)/MySqlObjects/MySqlProcedureList.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,4 @@ public void Dispose()
8282
_lst = null;
8383
}
8484
}
85-
}
85+
}

source code/MySqlBackup(Devart-Express)/MySqlObjects/MySqlViewList.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,4 @@ public void Dispose()
8282
_lst = null;
8383
}
8484
}
85-
}
85+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace MySql.Data.MySqlClient.InfoObjects
2+
{
3+
public class ColumnWithValue
4+
{
5+
public string TableName { get; set; }
6+
public string ColumnName { get; set; }
7+
public string MySqlDataType { get; set; }
8+
public object Value { get; set; }
9+
}
10+
}

source code/MySqlBackup(MySql.Data)/InfoObjects/ExportInformations.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System;
1+
using MySql.Data.MySqlClient.InfoObjects;
2+
using System;
23
using System.Collections.Generic;
34
using System.Text;
45

@@ -267,6 +268,11 @@ public Dictionary<string, string> TablesToBeExportedDic
267268
/// </summary>
268269
public bool InsertLineBreakBetweenInserts = false;
269270

271+
/// <summary>
272+
/// Returns the row's default column value. Set this value if you wish to change the row's column value before exporting.
273+
/// </summary>
274+
public Func<ColumnWithValue, object> AdjustColumnValue = (ColumnWithValue columnInfo) => columnInfo.Value;
275+
270276
public ExportInformations()
271277
{
272278

0 commit comments

Comments
 (0)