Skip to content

Commit e61a50c

Browse files
committed
- 优化 DbFirst 模式长内容未设置 StringLength = -1 写入问题;
1 parent 4358566 commit e61a50c

File tree

19 files changed

+282
-8
lines changed

19 files changed

+282
-8
lines changed

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,31 @@ namespace FreeSql.Tests.MySqlConnector
1111
{
1212
public class MySqlCodeFirstTest
1313
{
14+
[Fact]
15+
public void InsertUpdateParameter()
16+
{
17+
var fsql = g.mysql;
18+
fsql.CodeFirst.SyncStructure<ts_iupstr_bak>();
19+
var item = new ts_iupstr { id = Guid.NewGuid(), title = string.Join(",", Enumerable.Range(0, 2000).Select(a => "我是中国人")) };
20+
Assert.Equal(1, fsql.Insert(item).ExecuteAffrows());
21+
var find = fsql.Select<ts_iupstr>().Where(a => a.id == item.id).First();
22+
Assert.NotNull(find);
23+
Assert.Equal(find.id, item.id);
24+
Assert.Equal(find.title, item.title);
25+
}
26+
[Table(Name = "ts_iupstr_bak", DisableSyncStructure = true)]
27+
class ts_iupstr
28+
{
29+
public Guid id { get; set; }
30+
public string title { get; set; }
31+
}
32+
class ts_iupstr_bak
33+
{
34+
public Guid id { get; set; }
35+
[Column(StringLength = -1)]
36+
public string title { get; set; }
37+
}
38+
1439
[Fact]
1540
public void Timestamp01()
1641
{

FreeSql.Tests/FreeSql.Tests/Dameng/DamengCodeFirstTest.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,31 @@ namespace FreeSql.Tests.Dameng
1212
{
1313
public class DamengCodeFirstTest
1414
{
15+
[Fact]
16+
public void InsertUpdateParameter()
17+
{
18+
var fsql = g.dameng;
19+
fsql.CodeFirst.SyncStructure<ts_iupstr_bak>();
20+
var item = new ts_iupstr { id = Guid.NewGuid(), title = string.Join(",", Enumerable.Range(0, 2000).Select(a => "我是中国人")) };
21+
Assert.Equal(1, fsql.Insert(item).ExecuteAffrows());
22+
var find = fsql.Select<ts_iupstr>().Where(a => a.id == item.id).First();
23+
Assert.NotNull(find);
24+
Assert.Equal(find.id, item.id);
25+
Assert.Equal(find.title, item.title);
26+
}
27+
[Table(Name = "ts_iupstr_bak", DisableSyncStructure = true)]
28+
class ts_iupstr
29+
{
30+
public Guid id { get; set; }
31+
public string title { get; set; }
32+
}
33+
class ts_iupstr_bak
34+
{
35+
public Guid id { get; set; }
36+
[Column(StringLength = -1)]
37+
public string title { get; set; }
38+
}
39+
1540
[Fact]
1641
public void StringLength36()
1742
{

FreeSql.Tests/FreeSql.Tests/Firebird/FirebirdCodeFirstTest.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,31 @@ namespace FreeSql.Tests.Firebird
1010
{
1111
public class FirebirdCodeFirstTest
1212
{
13+
[Fact]
14+
public void InsertUpdateParameter()
15+
{
16+
var fsql = g.firebird;
17+
fsql.CodeFirst.SyncStructure<ts_iupstr_bak>();
18+
var item = new ts_iupstr { id = Guid.NewGuid(), title = string.Join(",", Enumerable.Range(0, 2000).Select(a => "我是中国人")) };
19+
Assert.Equal(1, fsql.Insert(item).ExecuteAffrows());
20+
var find = fsql.Select<ts_iupstr>().Where(a => a.id == item.id).First();
21+
Assert.NotNull(find);
22+
Assert.Equal(find.id, item.id);
23+
Assert.Equal(find.title, item.title);
24+
}
25+
[Table(Name = "ts_iupstr_bak", DisableSyncStructure = true)]
26+
class ts_iupstr
27+
{
28+
public Guid id { get; set; }
29+
public string title { get; set; }
30+
}
31+
class ts_iupstr_bak
32+
{
33+
public Guid id { get; set; }
34+
[Column(StringLength = -1)]
35+
public string title { get; set; }
36+
}
37+
1338
[Fact]
1439
public void Text_StringLength_1()
1540
{

FreeSql.Tests/FreeSql.Tests/KingbaseES/KingbaseESCodeFirstTest.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,31 @@ namespace FreeSql.Tests.KingbaseES
1010
{
1111
public class KingbaseESCodeFirstTest
1212
{
13+
[Fact]
14+
public void InsertUpdateParameter()
15+
{
16+
var fsql = g.kingbaseES;
17+
fsql.CodeFirst.SyncStructure<ts_iupstr_bak>();
18+
var item = new ts_iupstr { id = Guid.NewGuid(), title = string.Join(",", Enumerable.Range(0, 2000).Select(a => "我是中国人")) };
19+
Assert.Equal(1, fsql.Insert(item).ExecuteAffrows());
20+
var find = fsql.Select<ts_iupstr>().Where(a => a.id == item.id).First();
21+
Assert.NotNull(find);
22+
Assert.Equal(find.id, item.id);
23+
Assert.Equal(find.title, item.title);
24+
}
25+
[Table(Name = "ts_iupstr_bak", DisableSyncStructure = true)]
26+
class ts_iupstr
27+
{
28+
public Guid id { get; set; }
29+
public string title { get; set; }
30+
}
31+
class ts_iupstr_bak
32+
{
33+
public Guid id { get; set; }
34+
[Column(StringLength = -1)]
35+
public string title { get; set; }
36+
}
37+
1338
[Fact]
1439
public void StringLength()
1540
{

FreeSql.Tests/FreeSql.Tests/MsAccess/MsAccessCodeFirstTest.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,31 @@ namespace FreeSql.Tests.MsAccess
1010
{
1111
public class MsAccessCodeFirstTest
1212
{
13+
[Fact]
14+
public void InsertUpdateParameter()
15+
{
16+
var fsql = g.msaccess;
17+
fsql.CodeFirst.SyncStructure<ts_iupstr_bak>();
18+
var item = new ts_iupstr { id = Guid.NewGuid(), title = string.Join(",", Enumerable.Range(0, 2000).Select(a => "我是中国人")) };
19+
Assert.Equal(1, fsql.Insert(item).ExecuteAffrows());
20+
var find = fsql.Select<ts_iupstr>().Where(a => a.id == item.id).First();
21+
Assert.NotNull(find);
22+
Assert.Equal(find.id, item.id);
23+
Assert.Equal(find.title, item.title);
24+
}
25+
[Table(Name = "ts_iupstr_bak", DisableSyncStructure = true)]
26+
class ts_iupstr
27+
{
28+
public Guid id { get; set; }
29+
public string title { get; set; }
30+
}
31+
class ts_iupstr_bak
32+
{
33+
public Guid id { get; set; }
34+
[Column(StringLength = -1)]
35+
public string title { get; set; }
36+
}
37+
1338
[Fact]
1439
public void StringLength()
1540
{

FreeSql.Tests/FreeSql.Tests/MySql/MySqlCodeFirstTest.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,31 @@ namespace FreeSql.Tests.MySql
1111
{
1212
public class MySqlCodeFirstTest
1313
{
14+
[Fact]
15+
public void InsertUpdateParameter()
16+
{
17+
var fsql = g.mysql;
18+
fsql.CodeFirst.SyncStructure<ts_iupstr_bak>();
19+
var item = new ts_iupstr { id = Guid.NewGuid(), title = string.Join(",", Enumerable.Range(0, 2000).Select(a => "我是中国人")) };
20+
Assert.Equal(1, fsql.Insert(item).ExecuteAffrows());
21+
var find = fsql.Select<ts_iupstr>().Where(a => a.id == item.id).First();
22+
Assert.NotNull(find);
23+
Assert.Equal(find.id, item.id);
24+
Assert.Equal(find.title, item.title);
25+
}
26+
[Table(Name = "ts_iupstr_bak", DisableSyncStructure = true)]
27+
class ts_iupstr
28+
{
29+
public Guid id { get; set; }
30+
public string title { get; set; }
31+
}
32+
class ts_iupstr_bak
33+
{
34+
public Guid id { get; set; }
35+
[Column(StringLength = -1)]
36+
public string title { get; set; }
37+
}
38+
1439
[Fact]
1540
public void Timestamp01()
1641
{

FreeSql.Tests/FreeSql.Tests/Oracle/OracleCodeFirstTest.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,31 @@ namespace FreeSql.Tests.Oracle
1515
{
1616
public class OracleCodeFirstTest
1717
{
18+
[Fact]
19+
public void InsertUpdateParameter()
20+
{
21+
var fsql = g.oracle;
22+
fsql.CodeFirst.SyncStructure<ts_iupstr_bak>();
23+
var item = new ts_iupstr { id = Guid.NewGuid(), title = string.Join(",", Enumerable.Range(0, 2000).Select(a => "我是中国人")) };
24+
Assert.Equal(1, fsql.Insert(item).ExecuteAffrows());
25+
var find = fsql.Select<ts_iupstr>().Where(a => a.id == item.id).First();
26+
Assert.NotNull(find);
27+
Assert.Equal(find.id, item.id);
28+
Assert.Equal(find.title, item.title);
29+
}
30+
[Table(Name = "ts_iupstr_bak", DisableSyncStructure = true)]
31+
class ts_iupstr
32+
{
33+
public Guid id { get; set; }
34+
public string title { get; set; }
35+
}
36+
class ts_iupstr_bak
37+
{
38+
public Guid id { get; set; }
39+
[Column(StringLength = -1)]
40+
public string title { get; set; }
41+
}
42+
1843
[Fact]
1944
public void StringNullToEmpty()
2045
{

FreeSql.Tests/FreeSql.Tests/PostgreSQL/PostgreSQLCodeFirstTest.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,31 @@ namespace FreeSql.Tests.PostgreSQL
1818
{
1919
public class PostgreSQLCodeFirstTest
2020
{
21+
[Fact]
22+
public void InsertUpdateParameter()
23+
{
24+
var fsql = g.pgsql;
25+
fsql.CodeFirst.SyncStructure<ts_iupstr_bak>();
26+
var item = new ts_iupstr { id = Guid.NewGuid(), title = string.Join(",", Enumerable.Range(0, 2000).Select(a => "我是中国人")) };
27+
Assert.Equal(1, fsql.Insert(item).ExecuteAffrows());
28+
var find = fsql.Select<ts_iupstr>().Where(a => a.id == item.id).First();
29+
Assert.NotNull(find);
30+
Assert.Equal(find.id, item.id);
31+
Assert.Equal(find.title, item.title);
32+
}
33+
[Table(Name = "ts_iupstr_bak", DisableSyncStructure = true)]
34+
class ts_iupstr
35+
{
36+
public Guid id { get; set; }
37+
public string title { get; set; }
38+
}
39+
class ts_iupstr_bak
40+
{
41+
public Guid id { get; set; }
42+
[Column(StringLength = -1)]
43+
public string title { get; set; }
44+
}
45+
2146
[Fact]
2247
public void DateTime_1()
2348
{

FreeSql.Tests/FreeSql.Tests/ShenTong/ShenTongCodeFirstTest.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,30 @@ namespace FreeSql.Tests.ShenTong
1313
{
1414
public class ShenTongCodeFirstTest
1515
{
16+
[Fact]
17+
public void InsertUpdateParameter()
18+
{
19+
var fsql = g.shentong;
20+
fsql.CodeFirst.SyncStructure<ts_iupstr_bak>();
21+
var item = new ts_iupstr { id = Guid.NewGuid(), title = string.Join(",", Enumerable.Range(0, 2000).Select(a => "我是中国人")) };
22+
Assert.Equal(1, fsql.Insert(item).ExecuteAffrows());
23+
var find = fsql.Select<ts_iupstr>().Where(a => a.id == item.id).First();
24+
Assert.NotNull(find);
25+
Assert.Equal(find.id, item.id);
26+
Assert.Equal(find.title, item.title);
27+
}
28+
[Table(Name = "ts_iupstr_bak", DisableSyncStructure = true)]
29+
class ts_iupstr
30+
{
31+
public Guid id { get; set; }
32+
public string title { get; set; }
33+
}
34+
class ts_iupstr_bak
35+
{
36+
public Guid id { get; set; }
37+
[Column(StringLength = -1)]
38+
public string title { get; set; }
39+
}
1640

1741
[Fact]
1842
public void StringLength()

FreeSql.Tests/FreeSql.Tests/SqlServer/SqlServerCodeFirstTest.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,31 @@ namespace FreeSql.Tests.SqlServer
1212
{
1313
public class SqlServerCodeFirstTest
1414
{
15+
[Fact]
16+
public void InsertUpdateParameter()
17+
{
18+
var fsql = g.sqlserver;
19+
fsql.CodeFirst.SyncStructure<ts_iupstr_bak>();
20+
var item = new ts_iupstr { id = Guid.NewGuid(), title = string.Join(",", Enumerable.Range(0, 2000).Select(a => "我是中国人")) };
21+
Assert.Equal(1, fsql.Insert(item).ExecuteAffrows());
22+
var find = fsql.Select<ts_iupstr>().Where(a => a.id == item.id).First();
23+
Assert.NotNull(find);
24+
Assert.Equal(find.id, item.id);
25+
Assert.Equal(find.title, item.title);
26+
}
27+
[Table(Name = "ts_iupstr_bak", DisableSyncStructure = true)]
28+
class ts_iupstr
29+
{
30+
public Guid id { get; set; }
31+
public string title { get; set; }
32+
}
33+
class ts_iupstr_bak
34+
{
35+
public Guid id { get; set; }
36+
[Column(StringLength = -1)]
37+
public string title { get; set; }
38+
}
39+
1540
[Fact]
1641
public void EnumStartValue1()
1742
{

0 commit comments

Comments
 (0)