mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-06-28 13:34:32 +08:00
Update sqlite
This commit is contained in:
parent
41c2371a57
commit
6578a41474
@ -255,6 +255,21 @@ namespace SqlSugar
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Methods
|
#region Methods
|
||||||
|
protected override string GetAddColumnSql(string tableName, DbColumnInfo columnInfo)
|
||||||
|
{
|
||||||
|
var sql= base.GetAddColumnSql(tableName, columnInfo);
|
||||||
|
if (columnInfo.DefaultValue.HasValue()&&this.Context?.CurrentConnectionConfig?.MoreSettings?.SqliteCodeFirstEnableDefaultValue == true)
|
||||||
|
{
|
||||||
|
var value = columnInfo.DefaultValue;
|
||||||
|
if (!value.Contains("(") && !value.EqualCase("CURRENT_TIMESTAMP") && !value.StartsWith("'"))
|
||||||
|
{
|
||||||
|
value = value.ToSqlValue();
|
||||||
|
}
|
||||||
|
value = $" DEFAULT {value}";
|
||||||
|
sql += value;
|
||||||
|
}
|
||||||
|
return sql;
|
||||||
|
}
|
||||||
public override bool UpdateColumn(string tableName, DbColumnInfo column)
|
public override bool UpdateColumn(string tableName, DbColumnInfo column)
|
||||||
{
|
{
|
||||||
var isTran = this.Context.Ado.IsNoTran();
|
var isTran = this.Context.Ado.IsNoTran();
|
||||||
|
@ -13,6 +13,20 @@ namespace OrmTest
|
|||||||
public static void Init()
|
public static void Init()
|
||||||
{
|
{
|
||||||
var db = NewUnitTest.Db;
|
var db = NewUnitTest.Db;
|
||||||
|
db.CodeFirst.InitTables<Unitdfadfsdy>();
|
||||||
|
db.CurrentConnectionConfig.MoreSettings = new ConnMoreSettings()
|
||||||
|
{
|
||||||
|
SqliteCodeFirstEnableDefaultValue=true
|
||||||
|
};
|
||||||
|
db.CodeFirst.InitTables<UNITDFADFSDY>();
|
||||||
|
db.DbMaintenance.DropTable<Unitdfadfsdy>();
|
||||||
|
db.CodeFirst.InitTables<Unitdfadfsdy>();
|
||||||
|
db.Insertable(new Unitdfadfsdy() { Id = 1 }).ExecuteCommand();
|
||||||
|
db.CodeFirst.InitTables<UNITDFADFSDY>();
|
||||||
|
var list=db.Queryable<UNITDFADFSDY>().ToList();
|
||||||
|
db.CodeFirst.InitTables<UNITDFADFSdY>();
|
||||||
|
if (list.First().a != "1") throw new Exception("unit error");
|
||||||
|
db = NewUnitTest.Db;
|
||||||
db.CodeFirst.InitTables(typeof(SqlSugarTestEntity));
|
db.CodeFirst.InitTables(typeof(SqlSugarTestEntity));
|
||||||
db.DbMaintenance.TruncateTable<SqlSugarTestEntity>();
|
db.DbMaintenance.TruncateTable<SqlSugarTestEntity>();
|
||||||
SqlSugarTestEntity entity = new SqlSugarTestEntity { Id=1,BarCode = "1111", PatientName = "小明" };
|
SqlSugarTestEntity entity = new SqlSugarTestEntity { Id=1,BarCode = "1111", PatientName = "小明" };
|
||||||
@ -38,6 +52,24 @@ namespace OrmTest
|
|||||||
}).ToList();//没溢出,但结果,Aa 都是初值即是空??
|
}).ToList();//没溢出,但结果,Aa 都是初值即是空??
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public class Unitdfadfsdy
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
}
|
||||||
|
public class UNITDFADFSDY
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
[SugarColumn(DefaultValue ="1")]
|
||||||
|
public string a { get; set; }
|
||||||
|
}
|
||||||
|
public class UNITDFADFSdY
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
[SugarColumn(DefaultValue = "1")]
|
||||||
|
public string a { get; set; }
|
||||||
|
[SugarColumn(DefaultValue = "10")]
|
||||||
|
public int num { get; set; }
|
||||||
|
}
|
||||||
[SqlSugar.SugarTable("SQLSUGARTEST")]
|
[SqlSugar.SugarTable("SQLSUGARTEST")]
|
||||||
[SqlSugar.SplitTable(SplitType._Custom01, typeof(SplitTableService))]
|
[SqlSugar.SplitTable(SplitType._Custom01, typeof(SplitTableService))]
|
||||||
public class SqlSugarTestEntity
|
public class SqlSugarTestEntity
|
||||||
|
Loading…
Reference in New Issue
Block a user