Skip to content

Commit

Permalink
- 修复 MySqlEnum CHAR/BYTE 替换后前面多个空格的问题;#1737
Browse files Browse the repository at this point in the history
  • Loading branch information
2881099 committed Feb 27, 2024
1 parent e37a043 commit 773d6fd
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions FreeSql/Internal/UtilsExpressionTree.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,8 @@ public static ColumnInfo ColumnAttributeToInfo(TableInfo trytb, object entityDef
};
if (colattr._IsNullable == null) colattr._IsNullable = tp?.isnullable;
if (string.IsNullOrEmpty(colattr.DbType)) colattr.DbType = tp?.dbtypeFull ?? "varchar(255)";
if (colattr.DbType.StartsWith("set(") || colattr.DbType.StartsWith("enum("))
var isMySqlEnum = colattr.DbType.StartsWith("set(") || colattr.DbType.StartsWith("enum(");
if (isMySqlEnum)
{
var leftBt = colattr.DbType.IndexOf('(');
colattr.DbType = colattr.DbType.Substring(0, leftBt).ToUpper() + colattr.DbType.Substring(leftBt);
Expand All @@ -232,7 +233,7 @@ public static ColumnInfo ColumnAttributeToInfo(TableInfo trytb, object entityDef
}
if (colattr.IsNullable == true && colattr.DbType.Contains("NOT NULL")) colattr.DbType = colattr.DbType.Replace("NOT NULL", "");
else if (colattr.IsNullable == true && !colattr.DbType.Contains("Nullable") && common._orm.Ado.DataType == DataType.ClickHouse) colattr.DbType = $"Nullable({colattr.DbType})";
colattr.DbType = Regex.Replace(colattr.DbType, @"\([^\)]+\)", m =>
if (isMySqlEnum == false) colattr.DbType = Regex.Replace(colattr.DbType, @"\([^\)]+\)", m =>
{
var tmpLt = Regex.Replace(m.Groups[0].Value, @"\s", "");
if (tmpLt.Contains("CHAR")) tmpLt = tmpLt.Replace("CHAR", " CHAR");
Expand Down

0 comments on commit 773d6fd

Please sign in to comment.