Skip to content

Commit 773d6fd

Browse files
committed
- 修复 MySqlEnum CHAR/BYTE 替换后前面多个空格的问题;#1737
1 parent e37a043 commit 773d6fd

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

FreeSql/Internal/UtilsExpressionTree.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,8 @@ public static ColumnInfo ColumnAttributeToInfo(TableInfo trytb, object entityDef
209209
};
210210
if (colattr._IsNullable == null) colattr._IsNullable = tp?.isnullable;
211211
if (string.IsNullOrEmpty(colattr.DbType)) colattr.DbType = tp?.dbtypeFull ?? "varchar(255)";
212-
if (colattr.DbType.StartsWith("set(") || colattr.DbType.StartsWith("enum("))
212+
var isMySqlEnum = colattr.DbType.StartsWith("set(") || colattr.DbType.StartsWith("enum(");
213+
if (isMySqlEnum)
213214
{
214215
var leftBt = colattr.DbType.IndexOf('(');
215216
colattr.DbType = colattr.DbType.Substring(0, leftBt).ToUpper() + colattr.DbType.Substring(leftBt);
@@ -232,7 +233,7 @@ public static ColumnInfo ColumnAttributeToInfo(TableInfo trytb, object entityDef
232233
}
233234
if (colattr.IsNullable == true && colattr.DbType.Contains("NOT NULL")) colattr.DbType = colattr.DbType.Replace("NOT NULL", "");
234235
else if (colattr.IsNullable == true && !colattr.DbType.Contains("Nullable") && common._orm.Ado.DataType == DataType.ClickHouse) colattr.DbType = $"Nullable({colattr.DbType})";
235-
colattr.DbType = Regex.Replace(colattr.DbType, @"\([^\)]+\)", m =>
236+
if (isMySqlEnum == false) colattr.DbType = Regex.Replace(colattr.DbType, @"\([^\)]+\)", m =>
236237
{
237238
var tmpLt = Regex.Replace(m.Groups[0].Value, @"\s", "");
238239
if (tmpLt.Contains("CHAR")) tmpLt = tmpLt.Replace("CHAR", " CHAR");

0 commit comments

Comments
 (0)