Skip to content

Commit 72739a2

Browse files
2881028810
authored andcommitted
- 增加 实体属性 char 类型的映射#381 #235
1 parent cd60c9d commit 72739a2

File tree

53 files changed

+232
-502
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+232
-502
lines changed

FreeSql.Tests/FreeSql.Tests.Provider.MySqlConnector/MySqlConnector/MySqlCodeFirstTest.cs

Lines changed: 9 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -282,57 +282,7 @@ public void GetComparisonDDLStatements()
282282
{
283283

284284
var sql = g.mysql.CodeFirst.GetComparisonDDLStatements<TableAllType>();
285-
if (string.IsNullOrEmpty(sql) == false)
286-
{
287-
Assert.Equal(@"CREATE TABLE IF NOT EXISTS `cccddd`.`tb_alltype` (
288-
`Id` INT(11) NOT NULL AUTO_INCREMENT,
289-
`testFieldBool` BIT(1) NOT NULL,
290-
`testFieldSByte` TINYINT(3) NOT NULL,
291-
`testFieldShort` SMALLINT(6) NOT NULL,
292-
`testFieldInt` INT(11) NOT NULL,
293-
`testFieldLong` BIGINT(20) NOT NULL,
294-
`testFieldByte` TINYINT(3) UNSIGNED NOT NULL,
295-
`testFieldUShort` SMALLINT(5) UNSIGNED NOT NULL,
296-
`testFieldUInt` INT(10) UNSIGNED NOT NULL,
297-
`testFieldULong` BIGINT(20) UNSIGNED NOT NULL,
298-
`testFieldDouble` DOUBLE NOT NULL,
299-
`testFieldFloat` FLOAT NOT NULL,
300-
`testFieldDecimal` DECIMAL(10,2) NOT NULL,
301-
`testFieldTimeSpan` TIME NOT NULL,
302-
`testFieldDateTime` DATETIME(3) NOT NULL,
303-
`testFieldBytes` VARBINARY(255),
304-
`testFieldString` VARCHAR(255),
305-
`testFieldGuid` VARCHAR(36),
306-
`testFieldBoolNullable` BIT(1),
307-
`testFieldSByteNullable` TINYINT(3),
308-
`testFieldShortNullable` SMALLINT(6),
309-
`testFieldIntNullable` INT(11),
310-
`testFielLongNullable` BIGINT(20),
311-
`testFieldByteNullable` TINYINT(3) UNSIGNED,
312-
`testFieldUShortNullable` SMALLINT(5) UNSIGNED,
313-
`testFieldUIntNullable` INT(10) UNSIGNED,
314-
`testFieldULongNullable` BIGINT(20) UNSIGNED,
315-
`testFieldDoubleNullable` DOUBLE,
316-
`testFieldFloatNullable` FLOAT,
317-
`testFieldDecimalNullable` DECIMAL(10,2),
318-
`testFieldTimeSpanNullable` TIME,
319-
`testFieldDateTimeNullable` DATETIME(3),
320-
`testFieldGuidNullable` VARCHAR(36),
321-
`testFieldPoint` POINT,
322-
`testFieldLineString` LINESTRING,
323-
`testFieldPolygon` POLYGON,
324-
`testFieldMultiPoint` MULTIPOINT,
325-
`testFieldMultiLineString` MULTILINESTRING,
326-
`testFieldMultiPolygon` MULTIPOLYGON,
327-
`testFieldEnum1` ENUM('E1','E2','E3') NOT NULL,
328-
`testFieldEnum1Nullable` ENUM('E1','E2','E3'),
329-
`testFieldEnum2` SET('F1','F2','F3') NOT NULL,
330-
`testFieldEnum2Nullable` SET('F1','F2','F3'),
331-
PRIMARY KEY (`Id`)
332-
) Engine=InnoDB;
333-
", sql);
334-
}
335-
285+
Assert.True(string.IsNullOrEmpty(sql)); //测试运行两次后
336286
sql = g.mysql.CodeFirst.GetComparisonDDLStatements<Tb_alltype>();
337287
}
338288

@@ -398,6 +348,7 @@ public void CurdAllField()
398348
testFieldShort = short.MaxValue,
399349
testFieldShortNullable = short.MinValue,
400350
testFieldString = "我是中国人string'\\?!@#$%^&*()_+{}}{~?><<>",
351+
testFieldChar = 'X',
401352
testFieldTimeSpan = TimeSpan.FromSeconds(999),
402353
testFieldTimeSpanNullable = TimeSpan.FromSeconds(60),
403354
testFieldUInt = uint.MaxValue,
@@ -411,10 +362,12 @@ public void CurdAllField()
411362
item2.Id = (int)insert.AppendData(item2).ExecuteIdentity();
412363
var newitem2 = select.Where(a => a.Id == item2.Id).ToOne();
413364
Assert.Equal(item2.testFieldString, newitem2.testFieldString);
365+
Assert.Equal(item2.testFieldChar, newitem2.testFieldChar);
414366

415367
item2.Id = (int)insert.NoneParameter().AppendData(item2).ExecuteIdentity();
416368
newitem2 = select.Where(a => a.Id == item2.Id).ToOne();
417369
Assert.Equal(item2.testFieldString, newitem2.testFieldString);
370+
Assert.Equal(item2.testFieldChar, newitem2.testFieldChar);
418371

419372
var items = select.ToList();
420373
var itemstb = select.ToDataTable();
@@ -561,6 +514,10 @@ public partial class Tb_alltype
561514
public string TestFieldString { get; set; }
562515

563516

517+
[JsonProperty, Column(Name = "testFieldChar", DbType = "char(1)", IsNullable = true)]
518+
public char testFieldChar { get; set; }
519+
520+
564521
[JsonProperty, Column(Name = "testFieldTimeSpan", DbType = "time")]
565522
public TimeSpan TestFieldTimeSpan { get; set; }
566523

@@ -665,6 +622,7 @@ class TableAllType
665622

666623
public byte[] testFieldBytes { get; set; }
667624
public string testFieldString { get; set; }
625+
public char testFieldChar { get; set; }
668626
public Guid testFieldGuid { get; set; }
669627

670628
public bool? testFieldBoolNullable { get; set; }

FreeSql.Tests/FreeSql.Tests.Provider.Odbc/Dameng/DamengCodeFirstTest.cs

Lines changed: 5 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -179,57 +179,7 @@ public void GetComparisonDDLStatements()
179179
{
180180

181181
var sql = g.dameng.CodeFirst.GetComparisonDDLStatements<TableAllType>();
182-
if (string.IsNullOrEmpty(sql) == false)
183-
{
184-
Assert.Equal(@"CREATE TABLE IF NOT EXISTS `cccddd`.`tb_alltype` (
185-
`Id` INT(11) NOT NULL AUTO_INCREMENT,
186-
`Bool` BIT(1) NOT NULL,
187-
`SByte` TINYINT(3) NOT NULL,
188-
`Short` SMALLINT(6) NOT NULL,
189-
`Int` INT(11) NOT NULL,
190-
`Long` BIGINT(20) NOT NULL,
191-
`Byte` TINYINT(3) UNSIGNED NOT NULL,
192-
`UShort` SMALLINT(5) UNSIGNED NOT NULL,
193-
`UInt` INT(10) UNSIGNED NOT NULL,
194-
`ULong` BIGINT(20) UNSIGNED NOT NULL,
195-
`Double` DOUBLE NOT NULL,
196-
`Float` FLOAT NOT NULL,
197-
`Decimal` DECIMAL(10,2) NOT NULL,
198-
`TimeSpan` TIME NOT NULL,
199-
`DateTime` DATETIME NOT NULL,
200-
`Bytes` VARBINARY(255),
201-
`String` VARCHAR(255),
202-
`Guid` VARCHAR(36),
203-
`BoolNullable` BIT(1),
204-
`SByteNullable` TINYINT(3),
205-
`ShortNullable` SMALLINT(6),
206-
`IntNullable` INT(11),
207-
`testFielLongNullable` BIGINT(20),
208-
`ByteNullable` TINYINT(3) UNSIGNED,
209-
`UShortNullable` SMALLINT(5) UNSIGNED,
210-
`UIntNullable` INT(10) UNSIGNED,
211-
`ULongNullable` BIGINT(20) UNSIGNED,
212-
`DoubleNullable` DOUBLE,
213-
`FloatNullable` FLOAT,
214-
`DecimalNullable` DECIMAL(10,2),
215-
`TimeSpanNullable` TIME,
216-
`DateTimeNullable` DATETIME,
217-
`GuidNullable` VARCHAR(36),
218-
`Point` POINT,
219-
`LineString` LINESTRING,
220-
`Polygon` POLYGON,
221-
`MultiPoint` MULTIPOINT,
222-
`MultiLineString` MULTILINESTRING,
223-
`MultiPolygon` MULTIPOLYGON,
224-
`Enum1` ENUM('E1','E2','E3') NOT NULL,
225-
`Enum1Nullable` ENUM('E1','E2','E3'),
226-
`Enum2` SET('F1','F2','F3') NOT NULL,
227-
`Enum2Nullable` SET('F1','F2','F3'),
228-
PRIMARY KEY (`Id`)
229-
) Engine=InnoDB;
230-
", sql);
231-
}
232-
182+
Assert.True(string.IsNullOrEmpty(sql)); //测试运行两次后
233183
//sql = g.dameng.CodeFirst.GetComparisonDDLStatements<Tb_alltype>();
234184
}
235185

@@ -272,6 +222,7 @@ public void CurdAllField()
272222
Short = short.MaxValue,
273223
ShortNullable = short.MinValue,
274224
String = "我是中国人string'\\?!@#$%^&*()_+{}}{~?><<>",
225+
Char = 'X',
275226
TimeSpan = TimeSpan.FromSeconds(999),
276227
TimeSpanNullable = TimeSpan.FromSeconds(60),
277228
UInt = uint.MaxValue,
@@ -289,10 +240,12 @@ public void CurdAllField()
289240
item2.Id = (int)insert.AppendData(item2).ExecuteIdentity();
290241
var newitem2 = select.Where(a => a.Id == item2.Id).ToOne();
291242
Assert.Equal(item2.String, newitem2.String);
243+
Assert.Equal(item2.Char, newitem2.Char);
292244

293245
item2.Id = (int)insert.NoneParameter().AppendData(item2).ExecuteIdentity();
294246
newitem2 = select.Where(a => a.Id == item2.Id).ToOne();
295247
Assert.Equal(item2.String, newitem2.String);
248+
Assert.Equal(item2.Char, newitem2.Char);
296249

297250
var items = select.ToList();
298251
var itemstb = select.ToDataTable();
@@ -323,6 +276,7 @@ class TableAllType
323276
public DateTime DateTimeOffSet { get; set; }
324277
public byte[] Bytes { get; set; }
325278
public string String { get; set; }
279+
public char Char { get; set; }
326280
public Guid Guid { get; set; }
327281

328282
public bool? BoolNullable { get; set; }

FreeSql.Tests/FreeSql.Tests.Provider.Odbc/Default/OdbcCodeFirstTest.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ public void CurdAllField()
9999
testFieldShort = short.MaxValue,
100100
testFieldShortNullable = short.MinValue,
101101
testFieldString = "我是中国人string'\\?!@#$%^&*()_+{}}{~?><<>",
102+
testFieldChar = 'X',
102103
testFieldUInt = uint.MaxValue,
103104
testFieldUIntNullable = uint.MinValue,
104105
testFieldULong = ulong.MaxValue,
@@ -117,10 +118,12 @@ public void CurdAllField()
117118
var item3 = insert.AppendData(item2).ExecuteIdentity();
118119
var newitem2 = select.Where(a => a.Id == item2.Id).ToOne();
119120
Assert.Equal(item2.testFieldString, newitem2.testFieldString);
121+
Assert.Equal(item2.testFieldChar, newitem2.testFieldChar);
120122

121123
item2.Id = (int)insert.NoneParameter().AppendData(item2).ExecuteIdentity();
122124
newitem2 = select.Where(a => a.Id == item2.Id).ToOne();
123125
Assert.Equal(item2.testFieldString, newitem2.testFieldString);
126+
Assert.Equal(item2.testFieldChar, newitem2.testFieldChar);
124127

125128
var items = select.ToList();
126129
var itemstb = select.ToDataTable();
@@ -148,6 +151,7 @@ class tb_alltype_notime
148151
public DateTime testFieldDateTime { get; set; }
149152
public byte[] testFieldBytes { get; set; }
150153
public string testFieldString { get; set; }
154+
public char testFieldChar { get; set; }
151155
public Guid testFieldGuid { get; set; }
152156

153157
public bool? testFieldBoolNullable { get; set; }

FreeSql.Tests/FreeSql.Tests.Provider.Odbc/KingbaseES/KingbaseESCodeFirstTest.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,8 @@ public class TopicAddField
177177
[Fact]
178178
public void GetComparisonDDLStatements()
179179
{
180-
181180
var sql = g.kingbaseES.CodeFirst.GetComparisonDDLStatements<TableAllType>();
181+
Assert.True(string.IsNullOrEmpty(sql)); //测试运行两次后
182182
//sql = g.kingbaseES.CodeFirst.GetComparisonDDLStatements<Tb_alltype>();
183183
}
184184

@@ -221,6 +221,7 @@ public void CurdAllField()
221221
Short = short.MaxValue,
222222
ShortNullable = short.MinValue,
223223
String = "我是中国人string'\\?!@#$%^&*()_+{}}{~?><<>",
224+
Char = 'X',
224225
TimeSpan = TimeSpan.FromSeconds(999),
225226
TimeSpanNullable = TimeSpan.FromSeconds(60),
226227
UInt = uint.MaxValue,
@@ -255,19 +256,22 @@ public void CurdAllField()
255256
a.DateTimeOffSet,
256257
a.Bytes,
257258
a.String,
259+
a.Char,
258260
a.Guid
259261
});
260262
var newitem22 = select.Where(a => a.Id == item2.Id).First(a => new
261263
{
262-
a.Id, a.id2, a.SByte, a.Short, a.Int, a.Long, a.Byte, a.UShort, a.UInt, a.ULong, a.Double, a.Float, a.Decimal, a.TimeSpan, a.DateTime, a.DateTimeOffSet, a.Bytes, a.String, a.Guid
264+
a.Id, a.id2, a.SByte, a.Short, a.Int, a.Long, a.Byte, a.UShort, a.UInt, a.ULong, a.Double, a.Float, a.Decimal, a.TimeSpan, a.DateTime, a.DateTimeOffSet, a.Bytes, a.String, a.Char, a.Guid
263265
});
264266

265267
var newitem2 = select.Where(a => a.Id == item2.Id).ToOne();
266268
Assert.Equal(item2.String, newitem2.String);
269+
Assert.Equal(item2.Char, newitem2.Char);
267270

268271
item2.Id = (int)insert.NoneParameter().AppendData(item2).ExecuteIdentity();
269272
newitem2 = select.Where(a => a.Id == item2.Id).ToOne();
270273
Assert.Equal(item2.String, newitem2.String);
274+
Assert.Equal(item2.Char, newitem2.Char);
271275

272276
var items = select.ToList();
273277
var itemstb = select.ToDataTable();
@@ -298,6 +302,7 @@ class TableAllType
298302
public DateTime DateTimeOffSet { get; set; }
299303
public byte[] Bytes { get; set; }
300304
public string String { get; set; }
305+
public char Char { get; set; }
301306
public Guid Guid { get; set; }
302307

303308
public bool? BoolNullable { get; set; }

FreeSql.Tests/FreeSql.Tests.Provider.Odbc/MySql/MySqlCodeFirstTest.cs

Lines changed: 9 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -153,57 +153,7 @@ public void GetComparisonDDLStatements()
153153
{
154154

155155
var sql = g.mysql.CodeFirst.GetComparisonDDLStatements<TableAllType>();
156-
if (string.IsNullOrEmpty(sql) == false)
157-
{
158-
Assert.Equal(@"CREATE TABLE IF NOT EXISTS `cccddd`.`tb_alltype` (
159-
`Id` INT(11) NOT NULL AUTO_INCREMENT,
160-
`testFieldBool` BIT(1) NOT NULL,
161-
`testFieldSByte` TINYINT(3) NOT NULL,
162-
`testFieldShort` SMALLINT(6) NOT NULL,
163-
`testFieldInt` INT(11) NOT NULL,
164-
`testFieldLong` BIGINT(20) NOT NULL,
165-
`testFieldByte` TINYINT(3) UNSIGNED NOT NULL,
166-
`testFieldUShort` SMALLINT(5) UNSIGNED NOT NULL,
167-
`testFieldUInt` INT(10) UNSIGNED NOT NULL,
168-
`testFieldULong` BIGINT(20) UNSIGNED NOT NULL,
169-
`testFieldDouble` DOUBLE NOT NULL,
170-
`testFieldFloat` FLOAT NOT NULL,
171-
`testFieldDecimal` DECIMAL(10,2) NOT NULL,
172-
`testFieldTimeSpan` TIME NOT NULL,
173-
`testFieldDateTime` DATETIME(3) NOT NULL,
174-
`testFieldBytes` VARBINARY(255),
175-
`testFieldString` VARCHAR(255),
176-
`testFieldGuid` VARCHAR(36),
177-
`testFieldBoolNullable` BIT(1),
178-
`testFieldSByteNullable` TINYINT(3),
179-
`testFieldShortNullable` SMALLINT(6),
180-
`testFieldIntNullable` INT(11),
181-
`testFielLongNullable` BIGINT(20),
182-
`testFieldByteNullable` TINYINT(3) UNSIGNED,
183-
`testFieldUShortNullable` SMALLINT(5) UNSIGNED,
184-
`testFieldUIntNullable` INT(10) UNSIGNED,
185-
`testFieldULongNullable` BIGINT(20) UNSIGNED,
186-
`testFieldDoubleNullable` DOUBLE,
187-
`testFieldFloatNullable` FLOAT,
188-
`testFieldDecimalNullable` DECIMAL(10,2),
189-
`testFieldTimeSpanNullable` TIME,
190-
`testFieldDateTimeNullable` DATETIME(3),
191-
`testFieldGuidNullable` VARCHAR(36),
192-
`testFieldPoint` POINT,
193-
`testFieldLineString` LINESTRING,
194-
`testFieldPolygon` POLYGON,
195-
`testFieldMultiPoint` MULTIPOINT,
196-
`testFieldMultiLineString` MULTILINESTRING,
197-
`testFieldMultiPolygon` MULTIPOLYGON,
198-
`testFieldEnum1` ENUM('E1','E2','E3') NOT NULL,
199-
`testFieldEnum1Nullable` ENUM('E1','E2','E3'),
200-
`testFieldEnum2` SET('F1','F2','F3') NOT NULL,
201-
`testFieldEnum2Nullable` SET('F1','F2','F3'),
202-
PRIMARY KEY (`Id`)
203-
) Engine=InnoDB;
204-
", sql);
205-
}
206-
156+
Assert.True(string.IsNullOrEmpty(sql)); //测试运行两次后
207157
sql = g.mysql.CodeFirst.GetComparisonDDLStatements<Tb_alltype>();
208158
}
209159

@@ -246,6 +196,7 @@ public void CurdAllField()
246196
testFieldShort = short.MaxValue,
247197
testFieldShortNullable = short.MinValue,
248198
testFieldString = "我是中国人string'\\?!@#$%^&*()_+{}}{~?><<>",
199+
testFieldChar = 'X',
249200
testFieldTimeSpan = TimeSpan.FromSeconds(999),
250201
testFieldTimeSpanNullable = TimeSpan.FromSeconds(60),
251202
testFieldUInt = uint.MaxValue,
@@ -265,10 +216,12 @@ public void CurdAllField()
265216
item2.Id = (int)insert.AppendData(item2).ExecuteIdentity();
266217
var newitem2 = select.Where(a => a.Id == item2.Id).ToOne();
267218
Assert.Equal(item2.testFieldString, newitem2.testFieldString);
219+
Assert.Equal(item2.testFieldChar, newitem2.testFieldChar);
268220

269221
item2.Id = (int)insert.NoneParameter().AppendData(item2).ExecuteIdentity();
270222
newitem2 = select.Where(a => a.Id == item2.Id).ToOne();
271223
Assert.Equal(item2.testFieldString, newitem2.testFieldString);
224+
Assert.Equal(item2.testFieldChar, newitem2.testFieldChar);
272225

273226
var items = select.ToList();
274227
var itemstb = select.ToDataTable();
@@ -391,6 +344,10 @@ public partial class Tb_alltype
391344
public string TestFieldString { get; set; }
392345

393346

347+
[JsonProperty, Column(Name = "testFieldChar", DbType = "char(1)", IsNullable = true)]
348+
public char testFieldChar { get; set; }
349+
350+
394351
[JsonProperty, Column(Name = "testFieldTimeSpan", DbType = "time")]
395352
public TimeSpan TestFieldTimeSpan { get; set; }
396353

@@ -492,6 +449,7 @@ class TableAllType
492449
public DateTime testFieldDateTime { get; set; }
493450
public byte[] testFieldBytes { get; set; }
494451
public string testFieldString { get; set; }
452+
public char testFieldChar { get; set; }
495453
public Guid testFieldGuid { get; set; }
496454

497455
public bool? testFieldBoolNullable { get; set; }

0 commit comments

Comments
 (0)