Update PgSql

This commit is contained in:
skx 2020-10-14 12:25:15 +08:00
parent 0dda259d6d
commit 1f4217876c
4 changed files with 56 additions and 0 deletions

View File

@ -0,0 +1,46 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OrmTest.Test
{
public class BugTest
{
public static void Init()
{
SqlSugarClient Db = new SqlSugarClient(new ConnectionConfig()
{
ConnectionString = @"PORT=5433;DATABASE=x;HOST=localhost;PASSWORD=haosql;USER ID=postgres",
DbType = DbType.PostgreSQL,
IsAutoCloseConnection = true,
InitKeyType = InitKeyType.Attribute,
});
//调式代码 用来打印SQL
Db.Aop.OnLogExecuting = (sql, pars) =>
{
Console.WriteLine(sql);
};
Db.CodeFirst.InitTables(typeof(testmmmm12));
var id = Db.Insertable(new testmmmm12 { name="a", isok=true }).ExecuteReturnIdentity();
var list = Db.Queryable<testmmmm12>().InSingle(id);
var x = Db.Queryable<testmmmm12>().Where(it => !it.isok).ToList();
}
}
public class testmmmm12
{
[SugarColumn(IsPrimaryKey =true,IsIdentity =true)]
public int id { get; set; }
public string name { get; set; }
public bool isok { get; set; }
}
}

View File

@ -61,6 +61,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Bugs\BugTest.cs" /> <Compile Include="Bugs\BugTest.cs" />
<Compile Include="Bugs\BugTest3.cs" />
<Compile Include="Bugs\BugTest2.cs" /> <Compile Include="Bugs\BugTest2.cs" />
<Compile Include="Demo\Demo0_SqlSugarClient.cs" /> <Compile Include="Demo\Demo0_SqlSugarClient.cs" />
<Compile Include="Demo\Demo1_Queryable.cs" /> <Compile Include="Demo\Demo1_Queryable.cs" />

View File

@ -322,6 +322,10 @@ namespace SqlSugar
properyTypeName = this.Context.Ado.DbBind.GetDbTypeName(propertyType.Name); properyTypeName = this.Context.Ado.DbBind.GetDbTypeName(propertyType.Name);
} }
var dataType = dc.DataType; var dataType = dc.DataType;
if (properyTypeName == "boolean" && dataType == "bool")
{
return false;
}
return properyTypeName != dataType; return properyTypeName != dataType;
} }
#endregion #endregion

View File

@ -253,5 +253,10 @@ namespace SqlSugar
{ {
return "RANDOM()"; return "RANDOM()";
} }
public override string EqualTrue(string fieldName)
{
return "( " + fieldName + "=true )";
}
} }
} }