mirror of
				https://github.com/nsnail/FreeSql.git
				synced 2025-11-04 09:15:27 +08:00 
			
		
		
		
	- 修复 MySql CodeFirst DateTime 同步结构条件判断的 bug,导致每次都执行 alter;
This commit is contained in:
		@@ -217,8 +217,12 @@ where a.table_schema in ({0}) and a.table_name in ({1})", tboldname ?? tbname);
 | 
				
			|||||||
                                string.IsNullOrEmpty(tbcol.Attribute.OldName) == false && tbstruct.TryGetValue(tbcol.Attribute.OldName, out tbstructcol))
 | 
					                                string.IsNullOrEmpty(tbcol.Attribute.OldName) == false && tbstruct.TryGetValue(tbcol.Attribute.OldName, out tbstructcol))
 | 
				
			||||||
                            {
 | 
					                            {
 | 
				
			||||||
                                var isCommentChanged = tbstructcol.comment != (tbcol.Comment ?? "");
 | 
					                                var isCommentChanged = tbstructcol.comment != (tbcol.Comment ?? "");
 | 
				
			||||||
 | 
					                                var isDbTypeChanged = tbcol.Attribute.DbType.StartsWith(tbstructcol.sqlType, StringComparison.CurrentCultureIgnoreCase) == false;
 | 
				
			||||||
 | 
					                                if (tbstructcol.sqlType == "datetime(0)" && Regex.IsMatch(tbcol.Attribute.DbType, @"datetime\s+\(", RegexOptions.IgnoreCase) == false)
 | 
				
			||||||
 | 
					                                    isDbTypeChanged = tbcol.Attribute.DbType.StartsWith("datetime", StringComparison.CurrentCultureIgnoreCase) == false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                                if ((tbcol.Attribute.DbType.IndexOf(" unsigned", StringComparison.CurrentCultureIgnoreCase) != -1) != tbstructcol.is_unsigned ||
 | 
					                                if ((tbcol.Attribute.DbType.IndexOf(" unsigned", StringComparison.CurrentCultureIgnoreCase) != -1) != tbstructcol.is_unsigned ||
 | 
				
			||||||
                                tbcol.Attribute.DbType.StartsWith(tbstructcol.sqlType, StringComparison.CurrentCultureIgnoreCase) == false ||
 | 
					                                isDbTypeChanged ||
 | 
				
			||||||
                                tbcol.Attribute.IsNullable != tbstructcol.is_nullable ||
 | 
					                                tbcol.Attribute.IsNullable != tbstructcol.is_nullable ||
 | 
				
			||||||
                                tbcol.Attribute.IsIdentity != tbstructcol.is_identity ||
 | 
					                                tbcol.Attribute.IsIdentity != tbstructcol.is_identity ||
 | 
				
			||||||
                                isCommentChanged)
 | 
					                                isCommentChanged)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,6 +5,7 @@ using System.Data;
 | 
				
			|||||||
using System.Data.Odbc;
 | 
					using System.Data.Odbc;
 | 
				
			||||||
using System.Linq;
 | 
					using System.Linq;
 | 
				
			||||||
using System.Text;
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Text.RegularExpressions;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace FreeSql.Odbc.MySql
 | 
					namespace FreeSql.Odbc.MySql
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@@ -205,8 +206,12 @@ where a.table_schema in ({0}) and a.table_name in ({1})", tboldname ?? tbname);
 | 
				
			|||||||
                                string.IsNullOrEmpty(tbcol.Attribute.OldName) == false && tbstruct.TryGetValue(tbcol.Attribute.OldName, out tbstructcol))
 | 
					                                string.IsNullOrEmpty(tbcol.Attribute.OldName) == false && tbstruct.TryGetValue(tbcol.Attribute.OldName, out tbstructcol))
 | 
				
			||||||
                            {
 | 
					                            {
 | 
				
			||||||
                                var isCommentChanged = tbstructcol.comment != (tbcol.Comment ?? "");
 | 
					                                var isCommentChanged = tbstructcol.comment != (tbcol.Comment ?? "");
 | 
				
			||||||
 | 
					                                var isDbTypeChanged = tbcol.Attribute.DbType.StartsWith(tbstructcol.sqlType, StringComparison.CurrentCultureIgnoreCase) == false;
 | 
				
			||||||
 | 
					                                if (tbstructcol.sqlType == "datetime(0)" && Regex.IsMatch(tbcol.Attribute.DbType, @"datetime\s+\(", RegexOptions.IgnoreCase) == false)
 | 
				
			||||||
 | 
					                                    isDbTypeChanged = tbcol.Attribute.DbType.StartsWith("datetime", StringComparison.CurrentCultureIgnoreCase) == false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                                if ((tbcol.Attribute.DbType.IndexOf(" unsigned", StringComparison.CurrentCultureIgnoreCase) != -1) != tbstructcol.is_unsigned ||
 | 
					                                if ((tbcol.Attribute.DbType.IndexOf(" unsigned", StringComparison.CurrentCultureIgnoreCase) != -1) != tbstructcol.is_unsigned ||
 | 
				
			||||||
                                tbcol.Attribute.DbType.StartsWith(tbstructcol.sqlType, StringComparison.CurrentCultureIgnoreCase) == false ||
 | 
					                                isDbTypeChanged ||
 | 
				
			||||||
                                tbcol.Attribute.IsNullable != tbstructcol.is_nullable ||
 | 
					                                tbcol.Attribute.IsNullable != tbstructcol.is_nullable ||
 | 
				
			||||||
                                tbcol.Attribute.IsIdentity != tbstructcol.is_identity ||
 | 
					                                tbcol.Attribute.IsIdentity != tbstructcol.is_identity ||
 | 
				
			||||||
                                isCommentChanged)
 | 
					                                isCommentChanged)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user