- 修复 CodeFirst IsNullable 迁移脚本重复 NOT NULL 语法错误;

This commit is contained in:
28810 2020-03-27 17:35:59 +08:00
parent d4e73641a4
commit dbc323a22c
13 changed files with 37 additions and 1 deletions

View File

@ -21,6 +21,9 @@ namespace FreeSql.Tests.MySqlConnector
public Guid Id { get; set; }
[Column(StringLength = 50)]
public string Title { get; set; }
[Column(IsNullable = false, StringLength = 50)]
public string TitleSub { get; set; }
}
[Fact]

View File

@ -21,6 +21,9 @@ namespace FreeSql.Tests.Odbc.Dameng
public Guid Id { get; set; }
[Column(StringLength = 50)]
public string Title { get; set; }
[Column(IsNullable = false, StringLength = 50)]
public string TitleSub { get; set; }
}
[Fact]

View File

@ -21,6 +21,9 @@ namespace FreeSql.Tests.Odbc.MySql
public Guid Id { get; set; }
[Column(StringLength = 50)]
public string Title { get; set; }
[Column(IsNullable = false, StringLength = 50)]
public string TitleSub { get; set; }
}
[Fact]

View File

@ -21,6 +21,9 @@ namespace FreeSql.Tests.Odbc.Oracle
public Guid Id { get; set; }
[Column(StringLength = 50)]
public string Title { get; set; }
[Column(IsNullable = false, StringLength = 50)]
public string TitleSub { get; set; }
}
[Fact]

View File

@ -25,6 +25,9 @@ namespace FreeSql.Tests.Odbc.PostgreSQL
public Guid Id { get; set; }
[Column(StringLength = 50)]
public string Title { get; set; }
[Column(IsNullable = false, StringLength = 50)]
public string TitleSub { get; set; }
}
[Fact]

View File

@ -23,6 +23,9 @@ namespace FreeSql.Tests.Odbc.SqlServer
public Guid Id { get; set; }
[Column(StringLength = 50)]
public string Title { get; set; }
[Column(IsNullable = false, StringLength = 50)]
public string TitleSub { get; set; }
}
[Fact]

View File

@ -21,6 +21,9 @@ namespace FreeSql.Tests.MsAccess
public Guid Id { get; set; }
[Column(StringLength = 50)]
public string Title { get; set; }
[Column(IsNullable = false, StringLength = 50)]
public string TitleSub { get; set; }
}
[Fact]

View File

@ -21,6 +21,9 @@ namespace FreeSql.Tests.MySql
public Guid Id { get; set; }
[Column(StringLength = 50)]
public string Title { get; set; }
[Column(IsNullable = false, StringLength = 50)]
public string TitleSub { get; set; }
}
[Fact]

View File

@ -21,6 +21,9 @@ namespace FreeSql.Tests.Oracle
public Guid Id { get; set; }
[Column(StringLength = 50)]
public string Title { get; set; }
[Column(IsNullable = false, StringLength = 50)]
public string TitleSub { get; set; }
}
[Fact]

View File

@ -28,6 +28,9 @@ namespace FreeSql.Tests.PostgreSQL
public Guid Id { get; set; }
[Column(StringLength = 50)]
public string Title { get; set; }
[Column(IsNullable = false, StringLength = 50)]
public string TitleSub { get; set; }
}
[Fact]

View File

@ -22,6 +22,9 @@ namespace FreeSql.Tests.SqlServer
public Guid Id { get; set; }
[Column(StringLength = 50)]
public string Title { get; set; }
[Column(IsNullable = false, StringLength = 50)]
public string TitleSub { get; set; }
}
[Fact]

View File

@ -21,6 +21,9 @@ namespace FreeSql.Tests.Sqlite
public Guid Id { get; set; }
[Column(StringLength = 50)]
public string Title { get; set; }
[Column(IsNullable = false, StringLength = 50)]
public string TitleSub { get; set; }
}
[Fact]

View File

@ -124,7 +124,7 @@ namespace FreeSql.Internal
if ((colattr.IsNullable != true || colattr.IsIdentity == true || colattr.IsPrimary == true) && colattr.DbType.Contains("NOT NULL") == false)
{
colattr.IsNullable = false;
colattr.DbType += " NOT NULL";
colattr.DbType = Regex.Replace(colattr.DbType, @"\bNULL\b", "").Trim() + " NOT NULL";
}
if (colattr.IsNullable == true && colattr.DbType.Contains("NOT NULL")) colattr.DbType = colattr.DbType.Replace("NOT NULL", "");
colattr.DbType = Regex.Replace(colattr.DbType, @"\([^\)]+\)", m =>