From 773d6fdd396bff8ef677802d60f1968dd59f1c53 Mon Sep 17 00:00:00 2001 From: 2881099 <2881099@qq.com> Date: Tue, 27 Feb 2024 12:44:47 +0800 Subject: [PATCH] =?UTF-8?q?-=20=E4=BF=AE=E5=A4=8D=20MySqlEnum=20CHAR/BYTE?= =?UTF-8?q?=20=E6=9B=BF=E6=8D=A2=E5=90=8E=E5=89=8D=E9=9D=A2=E5=A4=9A?= =?UTF-8?q?=E4=B8=AA=E7=A9=BA=E6=A0=BC=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=9B?= =?UTF-8?q?#1737?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FreeSql/Internal/UtilsExpressionTree.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/FreeSql/Internal/UtilsExpressionTree.cs b/FreeSql/Internal/UtilsExpressionTree.cs index 954e2c1c..ad6cc5f9 100644 --- a/FreeSql/Internal/UtilsExpressionTree.cs +++ b/FreeSql/Internal/UtilsExpressionTree.cs @@ -209,7 +209,8 @@ namespace FreeSql.Internal }; 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); @@ -232,7 +233,7 @@ namespace FreeSql.Internal } 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");