mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-05-07 22:27:58 +08:00
Create table support CharSet=utf8mb4
This commit is contained in:
parent
f86b1ccd3f
commit
3efeb591b0
@ -405,6 +405,7 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
sql = sql.Replace("$PrimaryKey", primaryKeyInfo);
|
sql = sql.Replace("$PrimaryKey", primaryKeyInfo);
|
||||||
this.Context.Ado.ExecuteCommand(sql);
|
this.Context.Ado.ExecuteCommand(sql);
|
||||||
|
SetCharSet(tableName, "utf8mb4");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
public override bool AddRemark(EntityInfo entity)
|
public override bool AddRemark(EntityInfo entity)
|
||||||
@ -591,5 +592,15 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
#region Helper
|
||||||
|
private void SetCharSet(string tableName, string charset)
|
||||||
|
{
|
||||||
|
if (this.Context.CurrentConnectionConfig.ConnectionString.ObjToString().ToLower().Contains(charset))
|
||||||
|
{
|
||||||
|
var name = this.SqlBuilder.GetTranslationTableName(tableName);
|
||||||
|
this.Context.Ado.ExecuteCommand($"ALTER TABLE {name} CONVERT TO CHARACTER SET utf8mb4;");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -406,6 +406,7 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
sql = sql.Replace("$PrimaryKey", primaryKeyInfo);
|
sql = sql.Replace("$PrimaryKey", primaryKeyInfo);
|
||||||
this.Context.Ado.ExecuteCommand(sql);
|
this.Context.Ado.ExecuteCommand(sql);
|
||||||
|
SetCharSet(tableName, "utf8mb4");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
public override bool AddRemark(EntityInfo entity)
|
public override bool AddRemark(EntityInfo entity)
|
||||||
@ -627,5 +628,16 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Helper
|
||||||
|
private void SetCharSet(string tableName, string charset)
|
||||||
|
{
|
||||||
|
if (this.Context.CurrentConnectionConfig.ConnectionString.ObjToString().ToLower().Contains(charset))
|
||||||
|
{
|
||||||
|
var name = this.SqlBuilder.GetTranslationTableName(tableName);
|
||||||
|
this.Context.Ado.ExecuteCommand($"ALTER TABLE {name} CONVERT TO CHARACTER SET utf8mb4;");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user