mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-24 18:04:52 +08:00
Update MySqlConnector
This commit is contained in:
parent
4919022178
commit
1c81b67871
@ -25,6 +25,10 @@ namespace SqlSugar.MySqlConnector
|
||||
DbColumnInfo dbColumnInfo = this.EntityColumnToDbColumn(entityInfo, tableName, item);
|
||||
columns.Add(dbColumnInfo);
|
||||
}
|
||||
if (entityInfo.IsCreateTableFiledSort)
|
||||
{
|
||||
columns = columns.OrderBy(c => c.CreateTableFieldSort).ToList();
|
||||
}
|
||||
}
|
||||
this.Context.DbMaintenance.CreateTable(tableName, columns,true);
|
||||
}
|
||||
@ -42,7 +46,8 @@ namespace SqlSugar.MySqlConnector
|
||||
DefaultValue = item.DefaultValue,
|
||||
ColumnDescription = item.ColumnDescription,
|
||||
Length = item.Length,
|
||||
DecimalDigits=item.DecimalDigits
|
||||
DecimalDigits=item.DecimalDigits,
|
||||
CreateTableFieldSort = item.CreateTableFieldSort
|
||||
};
|
||||
GetDbType(item, propertyType, result);
|
||||
if (result.DataType.Equals("varchar", StringComparison.CurrentCultureIgnoreCase) && result.Length == 0)
|
||||
|
@ -269,7 +269,7 @@ namespace SqlSugar.MySqlConnector
|
||||
{
|
||||
get
|
||||
{
|
||||
return "SELECT count(*) FROM information_schema.statistics WHERE index_name = '{0}'";
|
||||
return "SELECT count(*) FROM information_schema.statistics WHERE index_name = '{0}' and index_schema = '{1}'";
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
@ -308,7 +308,9 @@ namespace SqlSugar.MySqlConnector
|
||||
}
|
||||
var oldDatabaseName = this.Context.Ado.Connection.Database;
|
||||
var connection = this.Context.CurrentConnectionConfig.ConnectionString;
|
||||
Check.Exception(Regex.Split(connection,oldDatabaseName).Length > 2, "The user name and password cannot be the same as the database name ");
|
||||
Check.ExceptionEasy(Regex.Split(connection,oldDatabaseName).Length > 2
|
||||
, "The user name and password cannot be the same as the database name ",
|
||||
" 创建数据库失败, 请换一个库名,库名不能 password 或者 username 有重叠 ");
|
||||
connection = connection.Replace(oldDatabaseName, "mysql");
|
||||
var newDb = new SqlSugarClient(new ConnectionConfig()
|
||||
{
|
||||
|
@ -176,7 +176,7 @@ 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)
|
||||
else if (row[colum] == null || row[colum] == DBNull.Value)
|
||||
{
|
||||
sb.Append("NULL");
|
||||
}
|
||||
|
@ -14,6 +14,10 @@ namespace SqlSugar.MySqlConnector
|
||||
}
|
||||
public class MySqlMethod : DefaultDbMethod, IDbMethods
|
||||
{
|
||||
public override string GetStringJoinSelector(string result, string separator)
|
||||
{
|
||||
return $"group_concat({result} separator '{separator}') ";
|
||||
}
|
||||
public override string DateDiff(MethodCallExpressionModel model)
|
||||
{
|
||||
var parameter = model.Args[0];
|
||||
@ -146,7 +150,14 @@ namespace SqlSugar.MySqlConnector
|
||||
{
|
||||
var parameter = model.Args[0];
|
||||
var parameter1 = model.Args[1];
|
||||
return string.Format("IFNULL({0},{1})", parameter.MemberName, parameter1.MemberName);
|
||||
if (parameter1.MemberValue is bool)
|
||||
{
|
||||
return string.Format("IFNULL(CAST({0} as SIGNED),{1})", parameter.MemberName, parameter1.MemberName);
|
||||
}
|
||||
else
|
||||
{
|
||||
return string.Format("IFNULL({0},{1})", parameter.MemberName, parameter1.MemberName);
|
||||
}
|
||||
}
|
||||
public override string GetDate()
|
||||
{
|
||||
|
@ -53,6 +53,10 @@ namespace SqlSugar.MySqlConnector
|
||||
}
|
||||
else if (Skip != null && Take != null)
|
||||
{
|
||||
if (Skip == 0 && Take == 1 && this.OrderByValue == "ORDER BY NOW() ")
|
||||
{
|
||||
this.OrderByValue = null;
|
||||
}
|
||||
if (this.OrderByValue == "ORDER BY ") this.OrderByValue += GetSelectValue.Split(',')[0];
|
||||
result = string.Format(PageTempalte, GetSelectValue, GetTableNameString, GetWhereValueString, GetGroupByString + HavingInfos, GetOrderByString, Skip.ObjToInt() > 0 ? Skip.ObjToInt() : 0, Take);
|
||||
}
|
||||
@ -111,7 +115,7 @@ namespace SqlSugar.MySqlConnector
|
||||
}
|
||||
public override string ToCountSql(string sql)
|
||||
{
|
||||
if (this.GroupByValue.HasValue())
|
||||
if (this.GroupByValue.HasValue()||this.IsDistinct)
|
||||
{
|
||||
return base.ToCountSql(sql);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user