Skip to content

Commit

Permalink
Merge pull request #42 from Soar360/fix-negative-underline
Browse files Browse the repository at this point in the history
优化 CheckColumnsChange 方法中的列名处理逻辑
  • Loading branch information
nnhy authored Sep 20, 2024
2 parents e67e5ce + 8f1ccd2 commit 15a4ac9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions XCode/DataAccessLayer/MetaData/DbMetaData_Negative.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,13 +201,13 @@ protected virtual void CheckTable(IDataTable entitytable, IDataTable? dbtable, M
protected virtual String CheckColumnsChange(IDataTable entitytable, IDataTable dbtable, Boolean @readonly, Boolean onlyCreate)
{
var sb = new StringBuilder();
var etdic = entitytable.Columns.ToDictionary(e => e.ColumnName.ToLower(), e => e, StringComparer.OrdinalIgnoreCase);
var etdic = entitytable.Columns.ToDictionary(e => this.FormatName(e), e => e, StringComparer.OrdinalIgnoreCase);
var dbdic = dbtable.Columns.ToDictionary(e => e.ColumnName.ToLower(), e => e, StringComparer.OrdinalIgnoreCase);

#region 新增列
foreach (var item in entitytable.Columns)
{
if (!dbdic.ContainsKey(item.ColumnName.ToLower()))
if (!dbdic.ContainsKey(this.FormatName(item)))
{
// 非空字段需要重建表
if (!item.Nullable)
Expand Down Expand Up @@ -237,7 +237,7 @@ protected virtual String CheckColumnsChange(IDataTable entitytable, IDataTable d
for (var i = dbtable.Columns.Count - 1; i >= 0; i--)
{
var item = dbtable.Columns[i];
if (!etdic.ContainsKey(item.ColumnName.ToLower()))
if (!etdic.ContainsKey(item.ColumnName))
{
if (!String.IsNullOrEmpty(item.Description)) PerformSchema(sb, @readonly || onlyCreate, DDLSchema.DropColumnDescription, item);
PerformSchema(sbDelete, @readonly || onlyCreate, DDLSchema.DropColumn, item);
Expand Down Expand Up @@ -265,7 +265,7 @@ protected virtual String CheckColumnsChange(IDataTable entitytable, IDataTable d

foreach (var item in entitytable.Columns)
{
if (!dbdic.TryGetValue(item.ColumnName, out var dbf)) continue;
if (!dbdic.TryGetValue(this.FormatName(item), out var dbf)) continue;

// 对于修改列,只读或者只创建,都只要sql
if (IsColumnTypeChanged(item, dbf))
Expand Down

0 comments on commit 15a4ac9

Please sign in to comment.