mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-24 07:22:57 +08:00
MySqlConnectorCore
This commit is contained in:
parent
7785b9d203
commit
ecbf9901c3
@ -1,8 +1,8 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<package >
|
<package >
|
||||||
<metadata>
|
<metadata>
|
||||||
<id>SqlSugar.MySqlConnector</id>
|
<id>SqlSugar.MySqlConnector</id>
|
||||||
<version>1.0</version>
|
<version>5.0.9.1</version>
|
||||||
<title>SqlSugar.MySqlConnector Framework</title>
|
<title>SqlSugar.MySqlConnector Framework</title>
|
||||||
<authors>sun kaixuan</authors>
|
<authors>sun kaixuan</authors>
|
||||||
<owners>landa</owners>
|
<owners>landa</owners>
|
||||||
|
@ -34,7 +34,8 @@ namespace SqlSugar.MySqlConnector
|
|||||||
CASE WHEN is_nullable = 'YES'
|
CASE WHEN is_nullable = 'YES'
|
||||||
THEN true ELSE false END AS `IsNullable`,
|
THEN true ELSE false END AS `IsNullable`,
|
||||||
numeric_scale as Scale,
|
numeric_scale as Scale,
|
||||||
numeric_scale as DecimalDigits
|
numeric_scale as DecimalDigits,
|
||||||
|
LOCATE( 'unsigned',COLUMN_type ) >0 as IsUnsigned
|
||||||
FROM
|
FROM
|
||||||
Information_schema.columns where TABLE_NAME='{0}' and TABLE_SCHEMA=(select database()) ORDER BY ordinal_position";
|
Information_schema.columns where TABLE_NAME='{0}' and TABLE_SCHEMA=(select database()) ORDER BY ordinal_position";
|
||||||
return sql;
|
return sql;
|
||||||
@ -274,6 +275,23 @@ namespace SqlSugar.MySqlConnector
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Methods
|
#region Methods
|
||||||
|
public override bool IsAnyColumnRemark(string columnName, string tableName)
|
||||||
|
{
|
||||||
|
var isAny=this.Context.DbMaintenance.GetColumnInfosByTableName(tableName, false)
|
||||||
|
.Any(it => it.ColumnDescription.HasValue() && it.DbColumnName.ToLower()==columnName.ToLower());
|
||||||
|
return isAny;
|
||||||
|
}
|
||||||
|
public override bool AddColumnRemark(string columnName, string tableName, string description)
|
||||||
|
{
|
||||||
|
//base.AddColumnRemark(columnName, tableName, description);
|
||||||
|
var message= @"db.DbMaintenance.UpdateColumn(""tablename"", new DbColumnInfo()
|
||||||
|
{{
|
||||||
|
DataType = ""VARCHAR(30) NOT NULL COMMENT 'xxxxx'"",
|
||||||
|
DbColumnName = ""columnname""
|
||||||
|
}})" ;
|
||||||
|
Check.Exception(true,"MySql no support AddColumnRemark , use " + message);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///by current connection string
|
///by current connection string
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -58,7 +58,14 @@ namespace SqlSugar.MySqlConnector
|
|||||||
}
|
}
|
||||||
catch (MySqlException ex)
|
catch (MySqlException ex)
|
||||||
{
|
{
|
||||||
throw ex;
|
if (ex.Message == "The used command is not allowed with this MySQL version")
|
||||||
|
{
|
||||||
|
Check.ExceptionEasy("connection string add : AllowLoadLocalInfile=true", "BulkCopy MySql连接字符串需要添加 AllowLoadLocalInfile=true; 添加后如果还不行Mysql数据库执行一下 SET GLOBAL local_infile=1 ");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -45,9 +45,9 @@ namespace SqlSugar.MySqlConnector
|
|||||||
if (type == UtilConstants.DateType)
|
if (type == UtilConstants.DateType)
|
||||||
{
|
{
|
||||||
var date = value.ObjToDate();
|
var date = value.ObjToDate();
|
||||||
if (date < Convert.ToDateTime("1900-1-1"))
|
if (date < UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig))
|
||||||
{
|
{
|
||||||
date = Convert.ToDateTime("1900-1-1");
|
date = UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig);
|
||||||
}
|
}
|
||||||
return "'" + date.ToString("yyyy-MM-dd HH:mm:ss.fff") + "'";
|
return "'" + date.ToString("yyyy-MM-dd HH:mm:ss.fff") + "'";
|
||||||
}
|
}
|
||||||
@ -106,6 +106,7 @@ namespace SqlSugar.MySqlConnector
|
|||||||
if (isSingle)
|
if (isSingle)
|
||||||
{
|
{
|
||||||
string columnParametersString = string.Join(",", this.DbColumnInfoList.Select(it => Builder.SqlParameterKeyWord + it.DbColumnName));
|
string columnParametersString = string.Join(",", this.DbColumnInfoList.Select(it => Builder.SqlParameterKeyWord + it.DbColumnName));
|
||||||
|
ActionMinDate();
|
||||||
return string.Format(SqlTemplate, GetTableNameString, columnsString, columnParametersString);
|
return string.Format(SqlTemplate, GetTableNameString, columnsString, columnParametersString);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -107,9 +107,9 @@ namespace SqlSugar.MySqlConnector
|
|||||||
if (type == UtilConstants.DateType)
|
if (type == UtilConstants.DateType)
|
||||||
{
|
{
|
||||||
var date = value.ObjToDate();
|
var date = value.ObjToDate();
|
||||||
if (date < Convert.ToDateTime("1900-1-1"))
|
if (date < UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig))
|
||||||
{
|
{
|
||||||
date = Convert.ToDateTime("1900-1-1");
|
date = UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig);
|
||||||
}
|
}
|
||||||
return "'" + date.ToString("yyyy-MM-dd HH:mm:ss.fff") + "'";
|
return "'" + date.ToString("yyyy-MM-dd HH:mm:ss.fff") + "'";
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netstandard2.1</TargetFramework>
|
<TargetFramework>netstandard2.1</TargetFramework>
|
||||||
<Version>1.3</Version>
|
<Version>5.9.1</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<package >
|
<package >
|
||||||
<metadata>
|
<metadata>
|
||||||
<id>SqlSugar.MySqlConnectorCore</id>
|
<id>SqlSugar.MySqlConnectorCore</id>
|
||||||
<version>1.3</version>
|
<version>5.9.1</version>
|
||||||
<authors>sunkaixuan</authors>
|
<authors>sunkaixuan</authors>
|
||||||
<owners>Landa</owners>
|
<owners>Landa</owners>
|
||||||
<licenseUrl>http://www.apache.org/licenses/LICENSE-2.0.html</licenseUrl>
|
<licenseUrl>http://www.apache.org/licenses/LICENSE-2.0.html</licenseUrl>
|
||||||
|
@ -16,7 +16,21 @@ namespace SqlSugar.MySqlConnector
|
|||||||
{
|
{
|
||||||
public class UtilMethods
|
public class UtilMethods
|
||||||
{
|
{
|
||||||
|
internal static DateTime GetMinDate(ConnectionConfig currentConnectionConfig)
|
||||||
|
{
|
||||||
|
if (currentConnectionConfig.MoreSettings == null)
|
||||||
|
{
|
||||||
|
return Convert.ToDateTime("1900-01-01");
|
||||||
|
}
|
||||||
|
else if (currentConnectionConfig.MoreSettings.DbMinDate == null)
|
||||||
|
{
|
||||||
|
return Convert.ToDateTime("1900-01-01");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return currentConnectionConfig.MoreSettings.DbMinDate.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
internal static DateTime ConvertFromDateTimeOffset(DateTimeOffset dateTime)
|
internal static DateTime ConvertFromDateTimeOffset(DateTimeOffset dateTime)
|
||||||
{
|
{
|
||||||
if (dateTime.Offset.Equals(TimeSpan.Zero))
|
if (dateTime.Offset.Equals(TimeSpan.Zero))
|
||||||
|
Loading…
Reference in New Issue
Block a user