- 修复 1.7.1 IsNullable 遗留问题;

This commit is contained in:
28810 2020-08-10 12:27:39 +08:00
parent 549d36974d
commit d602dfbaaa
3 changed files with 29 additions and 3 deletions

View File

@ -130,6 +130,13 @@
清空状态数据 清空状态数据
</summary> </summary>
</member> </member>
<member name="M:FreeSql.DbSet`1.RemoveAsync(System.Linq.Expressions.Expression{System.Func{`0,System.Boolean}})">
<summary>
根据 lambda 条件删除数据
</summary>
<param name="predicate"></param>
<returns></returns>
</member>
<member name="M:FreeSql.DbSet`1.Add(`0)"> <member name="M:FreeSql.DbSet`1.Add(`0)">
<summary> <summary>
添加 添加
@ -520,5 +527,14 @@
<param name="that"></param> <param name="that"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Microsoft.Extensions.DependencyInjection.FreeSqlRepositoryDependencyInjection.AddFreeRepository(Microsoft.Extensions.DependencyInjection.IServiceCollection,System.Action{FreeSql.FluentDataFilter},System.Reflection.Assembly[])">
<summary>
批量注入 Repository可以参考代码自行调整
</summary>
<param name="services"></param>
<param name="globalDataFilter"></param>
<param name="assemblies"></param>
<returns></returns>
</member>
</members> </members>
</doc> </doc>

View File

@ -158,20 +158,30 @@ namespace FreeSql.Tests
class testInsertNullable class testInsertNullable
{ {
[Column(IsIdentity = true)] [Column(IsNullable = false, IsIdentity = true)]
public long Id { get; set; } public long Id { get; set; }
[Column(IsNullable = false)] [Column(IsNullable = false)]
public string str1 { get; set; } public string str1 { get; set; }
[Column(IsNullable = false)] [Column(IsNullable = false)]
public int? int1 { get; set; } public int? int1 { get; set; }
[Column(IsNullable = true)]
public int int2 { get; set; }
} }
[Fact] [Fact]
public void Test03() public void Test03()
{ {
g.sqlite.Insert(new testInsertNullable()).NoneParameter().ExecuteAffrows(); g.sqlite.Insert(new testInsertNullable()).NoneParameter().ExecuteAffrows();
var ddlsql = g.sqlite.CodeFirst.GetComparisonDDLStatements(typeof(testInsertNullable), "tb123123");
Assert.Equal(@"CREATE TABLE IF NOT EXISTS ""main"".""tb123123"" (
""Id"" INTEGER PRIMARY KEY AUTOINCREMENT,
""str1"" NVARCHAR(255) NOT NULL,
""int1"" INTEGER NOT NULL,
""int2"" INTEGER
)
;
", ddlsql);
var sqlxx = g.pgsql.InsertOrUpdate<userinfo>().SetSource(new userinfo { userid = 10 }).UpdateColumns(a => new { a.birthday, a.CardNo }).ToSql(); var sqlxx = g.pgsql.InsertOrUpdate<userinfo>().SetSource(new userinfo { userid = 10 }).UpdateColumns(a => new { a.birthday, a.CardNo }).ToSql();

View File

@ -122,7 +122,7 @@ namespace FreeSql.Internal
colattr.DbType = colattr.DbType.ToUpper(); colattr.DbType = colattr.DbType.ToUpper();
if (colattrIsNull == false && colattrIsNullable == true) colattr.DbType = colattr.DbType.Replace("NOT NULL", ""); if (colattrIsNull == false && colattrIsNullable == true) colattr.DbType = colattr.DbType.Replace("NOT NULL", "");
if (colattrIsNull == false && colattrIsNullable == false) colattr.DbType = Regex.Replace(colattr.DbType, @"\bNULL\b", "").Trim() + " NOT NULL"; if (colattrIsNull == false && colattrIsNullable == false && colattr.DbType.Contains("NOT NULL") == false) colattr.DbType = Regex.Replace(colattr.DbType, @"\bNULL\b", "").Trim() + " NOT NULL";
if (colattr._IsNullable == null && tp != null && tp.isnullable == null) colattr.IsNullable = tp.dbtypeFull.Contains("NOT NULL") == false; if (colattr._IsNullable == null && tp != null && tp.isnullable == null) colattr.IsNullable = tp.dbtypeFull.Contains("NOT NULL") == false;
if (colattr.DbType?.Contains("NOT NULL") == true) colattr.IsNullable = false; if (colattr.DbType?.Contains("NOT NULL") == true) colattr.IsNullable = false;
if (string.IsNullOrEmpty(colattr.Name)) colattr.Name = p.Name; if (string.IsNullOrEmpty(colattr.Name)) colattr.Name = p.Name;