Update MySqlConnector

This commit is contained in:
sunkaixuan 2022-07-10 22:33:45 +08:00
parent 81fceb8247
commit e57e37e006
4 changed files with 60 additions and 12 deletions

View File

@ -176,6 +176,10 @@ namespace SqlSugar.MySqlConnector
{
sb.Append(row[colum].ObjToDate().ToString("yyyy-MM-dd HH:mm:ss.fff"));
}
else if (colum.DataType == UtilConstants.DateType && row[colum] != null && row[colum] == DBNull.Value)
{
sb.Append("NULL");
}
else sb.Append(row[colum].ToString());
}
sb.AppendLine();

View File

@ -44,12 +44,11 @@ namespace SqlSugar.MySqlConnector
var type = UtilMethods.GetUnderType(value.GetType());
if (type == UtilConstants.DateType)
{
var date = value.ObjToDate();
if (date < UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig))
{
date = UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig);
}
return "'" + date.ToString("yyyy-MM-dd HH:mm:ss.fff") + "'";
return GetDateTimeString(value);
}
else if (value is DateTimeOffset)
{
return GetDateTimeOffsetString(value);
}
else if (type == UtilConstants.ByteArrayType)
{
@ -84,6 +83,27 @@ namespace SqlSugar.MySqlConnector
}
}
}
private object GetDateTimeOffsetString(object value)
{
var date = UtilMethods.ConvertFromDateTimeOffset((DateTimeOffset)value);
if (date < UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig))
{
date = UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig);
}
return "'" + date.ToString("yyyy-MM-dd HH:mm:ss.fff") + "'";
}
private object GetDateTimeString(object value)
{
var date = value.ObjToDate();
if (date < UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig))
{
date = UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig);
}
return "'" + date.ToString("yyyy-MM-dd HH:mm:ss.fff") + "'";
}
private string GetString(object value)
{
var result = value.ToString();

View File

@ -66,6 +66,10 @@ namespace SqlSugar.MySqlConnector
{
return "-- No table";
}
if (TranLock != null)
{
result = result + TranLock;
}
return result;
}
private string ToCountSqlString()

View File

@ -106,12 +106,11 @@ namespace SqlSugar.MySqlConnector
var type = UtilMethods.GetUnderType(value.GetType());
if (type == UtilConstants.DateType)
{
var date = value.ObjToDate();
if (date < UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig))
{
date = UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig);
}
return "'" + date.ToString("yyyy-MM-dd HH:mm:ss.fff") + "'";
return GetDateTimeString(value);
}
else if (value is DateTimeOffset)
{
return GetDateTimeOffsetString(value);
}
else if (type == UtilConstants.ByteArrayType)
{
@ -154,6 +153,27 @@ namespace SqlSugar.MySqlConnector
}
}
}
private object GetDateTimeString(object value)
{
var date = value.ObjToDate();
if (date < UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig))
{
date = UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig);
}
return "'" + date.ToString("yyyy-MM-dd HH:mm:ss.fff") + "'";
}
private object GetDateTimeOffsetString(object value)
{
var date = UtilMethods.ConvertFromDateTimeOffset((DateTimeOffset)value);
if (date < UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig))
{
date = UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig);
}
return "'" + date.ToString("yyyy-MM-dd HH:mm:ss.fff") + "'";
}
private string GetString(object value)
{
var result = value.ToString();