- 增加 实体属性 char 类型的映射#381 #235;

This commit is contained in:
28810
2020-07-22 09:44:12 +08:00
parent cd60c9dbd9
commit 72739a27c6
53 changed files with 232 additions and 502 deletions

View File

@ -153,57 +153,7 @@ namespace FreeSql.Tests.Odbc.MySql
{
var sql = g.mysql.CodeFirst.GetComparisonDDLStatements<TableAllType>();
if (string.IsNullOrEmpty(sql) == false)
{
Assert.Equal(@"CREATE TABLE IF NOT EXISTS `cccddd`.`tb_alltype` (
`Id` INT(11) NOT NULL AUTO_INCREMENT,
`testFieldBool` BIT(1) NOT NULL,
`testFieldSByte` TINYINT(3) NOT NULL,
`testFieldShort` SMALLINT(6) NOT NULL,
`testFieldInt` INT(11) NOT NULL,
`testFieldLong` BIGINT(20) NOT NULL,
`testFieldByte` TINYINT(3) UNSIGNED NOT NULL,
`testFieldUShort` SMALLINT(5) UNSIGNED NOT NULL,
`testFieldUInt` INT(10) UNSIGNED NOT NULL,
`testFieldULong` BIGINT(20) UNSIGNED NOT NULL,
`testFieldDouble` DOUBLE NOT NULL,
`testFieldFloat` FLOAT NOT NULL,
`testFieldDecimal` DECIMAL(10,2) NOT NULL,
`testFieldTimeSpan` TIME NOT NULL,
`testFieldDateTime` DATETIME(3) NOT NULL,
`testFieldBytes` VARBINARY(255),
`testFieldString` VARCHAR(255),
`testFieldGuid` VARCHAR(36),
`testFieldBoolNullable` BIT(1),
`testFieldSByteNullable` TINYINT(3),
`testFieldShortNullable` SMALLINT(6),
`testFieldIntNullable` INT(11),
`testFielLongNullable` BIGINT(20),
`testFieldByteNullable` TINYINT(3) UNSIGNED,
`testFieldUShortNullable` SMALLINT(5) UNSIGNED,
`testFieldUIntNullable` INT(10) UNSIGNED,
`testFieldULongNullable` BIGINT(20) UNSIGNED,
`testFieldDoubleNullable` DOUBLE,
`testFieldFloatNullable` FLOAT,
`testFieldDecimalNullable` DECIMAL(10,2),
`testFieldTimeSpanNullable` TIME,
`testFieldDateTimeNullable` DATETIME(3),
`testFieldGuidNullable` VARCHAR(36),
`testFieldPoint` POINT,
`testFieldLineString` LINESTRING,
`testFieldPolygon` POLYGON,
`testFieldMultiPoint` MULTIPOINT,
`testFieldMultiLineString` MULTILINESTRING,
`testFieldMultiPolygon` MULTIPOLYGON,
`testFieldEnum1` ENUM('E1','E2','E3') NOT NULL,
`testFieldEnum1Nullable` ENUM('E1','E2','E3'),
`testFieldEnum2` SET('F1','F2','F3') NOT NULL,
`testFieldEnum2Nullable` SET('F1','F2','F3'),
PRIMARY KEY (`Id`)
) Engine=InnoDB;
", sql);
}
Assert.True(string.IsNullOrEmpty(sql)); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>κ<EFBFBD>
sql = g.mysql.CodeFirst.GetComparisonDDLStatements<Tb_alltype>();
}
@ -246,6 +196,7 @@ namespace FreeSql.Tests.Odbc.MySql
testFieldShort = short.MaxValue,
testFieldShortNullable = short.MinValue,
testFieldString = "<22><><EFBFBD><EFBFBD><EFBFBD>й<EFBFBD><D0B9><EFBFBD>string'\\?!@#$%^&*()_+{}}{~?><<>",
testFieldChar = 'X',
testFieldTimeSpan = TimeSpan.FromSeconds(999),
testFieldTimeSpanNullable = TimeSpan.FromSeconds(60),
testFieldUInt = uint.MaxValue,
@ -265,10 +216,12 @@ namespace FreeSql.Tests.Odbc.MySql
item2.Id = (int)insert.AppendData(item2).ExecuteIdentity();
var newitem2 = select.Where(a => a.Id == item2.Id).ToOne();
Assert.Equal(item2.testFieldString, newitem2.testFieldString);
Assert.Equal(item2.testFieldChar, newitem2.testFieldChar);
item2.Id = (int)insert.NoneParameter().AppendData(item2).ExecuteIdentity();
newitem2 = select.Where(a => a.Id == item2.Id).ToOne();
Assert.Equal(item2.testFieldString, newitem2.testFieldString);
Assert.Equal(item2.testFieldChar, newitem2.testFieldChar);
var items = select.ToList();
var itemstb = select.ToDataTable();
@ -391,6 +344,10 @@ namespace FreeSql.Tests.Odbc.MySql
public string TestFieldString { get; set; }
[JsonProperty, Column(Name = "testFieldChar", DbType = "char(1)", IsNullable = true)]
public char testFieldChar { get; set; }
[JsonProperty, Column(Name = "testFieldTimeSpan", DbType = "time")]
public TimeSpan TestFieldTimeSpan { get; set; }
@ -492,6 +449,7 @@ namespace FreeSql.Tests.Odbc.MySql
public DateTime testFieldDateTime { get; set; }
public byte[] testFieldBytes { get; set; }
public string testFieldString { get; set; }
public char testFieldChar { get; set; }
public Guid testFieldGuid { get; set; }
public bool? testFieldBoolNullable { get; set; }