Browse Source

Update unit test

pull/16/MERGE
sunkaixuan 3 years ago
parent
commit
7ba375ab80
  1. 4
      Src/Asp.NetCore2/SqlSugar/Realization/Sqlite/DbMaintenance/SqliteDbMaintenance.cs
  2. 16
      Src/Asp.NetCore2/SqliteTest/UnitTest/UCodeFirst.cs

4
Src/Asp.NetCore2/SqlSugar/Realization/Sqlite/DbMaintenance/SqliteDbMaintenance.cs

@ -337,7 +337,9 @@ namespace SqlSugar
DbColumnName = dataReader.GetString(1), DbColumnName = dataReader.GetString(1),
DefaultValue = dataReader.GetValue(4).ObjToString(), DefaultValue = dataReader.GetValue(4).ObjToString(),
IsPrimarykey = dataReader.GetBoolean(5).ObjToBool(), IsPrimarykey = dataReader.GetBoolean(5).ObjToBool(),
Length = length Length = length,
DecimalDigits=decimalDigits,
Scale= decimalDigits
}; };
result.Add(column); result.Add(column);
} }

16
Src/Asp.NetCore2/SqliteTest/UnitTest/UCodeFirst.cs

@ -18,16 +18,24 @@ namespace OrmTest
Db.Insertable(new Test00111()).ExecuteCommand(); Db.Insertable(new Test00111()).ExecuteCommand();
var list = Db.Queryable<Test00111>().ToList(); var list = Db.Queryable<Test00111>().ToList();
Db.CodeFirst.InitTables<Test00111121>(); Db.CodeFirst.InitTables<Test00111121>();
Db.CodeFirst.InitTables<UnitByteArray>(); Db.CodeFirst.InitTables<UnitByteArray1>();
Db.Insertable(new UnitByteArray() Db.Insertable(new UnitByteArray1()
{ {
Data = new byte[] { 1, 2, 123, 31, 1 } Data = new byte[] { 1, 2, 123, 31, 1 }
}).ExecuteCommand(); }).ExecuteCommand();
var list2=Db.Queryable<UnitByteArray>().ToDataTable(); var list2=Db.Queryable<UnitByteArray1>().ToDataTable();
var x=Db.DbMaintenance.GetColumnInfosByTableName("`UnitByteArray1`", false);
if (x[0].Length != 18 && x[0].Scale != 0) throw new Exception("unit test error");
if (x[1].Length != 18 && x[1].Scale != 2) throw new Exception("unit test error");
if (x[2].Length != 0 && x[2].Scale != 0) throw new Exception("unit test error");
} }
public class UnitByteArray public class UnitByteArray1
{ {
[SugarColumn(IsNullable = true, ColumnDataType = "varchar(18)")]
public string Aa { get; set; }
[SugarColumn(IsNullable =true, ColumnDataType = "decimal(18,2)")]
public decimal A { get; set; }
public byte[] Data { get; set; } public byte[] Data { get; set; }
} }
public class Test00111121 public class Test00111121

Loading…
Cancel
Save