mirror of
				https://github.com/nsnail/FreeSql.git
				synced 2025-11-01 00:05:28 +08:00 
			
		
		
		
	- 优化 DbFirst 模式长内容未设置 StringLength = -1 写入问题;
This commit is contained in:
		| @@ -11,6 +11,31 @@ namespace FreeSql.Tests.MySqlConnector | ||||
| { | ||||
|     public class MySqlCodeFirstTest | ||||
|     { | ||||
|         [Fact] | ||||
|         public void InsertUpdateParameter() | ||||
|         { | ||||
|             var fsql = g.mysql; | ||||
|             fsql.CodeFirst.SyncStructure<ts_iupstr_bak>(); | ||||
|             var item = new ts_iupstr { id = Guid.NewGuid(), title = string.Join(",", Enumerable.Range(0, 2000).Select(a => "<22><><EFBFBD><EFBFBD><EFBFBD>й<EFBFBD><D0B9><EFBFBD>")) }; | ||||
|             Assert.Equal(1, fsql.Insert(item).ExecuteAffrows()); | ||||
|             var find = fsql.Select<ts_iupstr>().Where(a => a.id == item.id).First(); | ||||
|             Assert.NotNull(find); | ||||
|             Assert.Equal(find.id, item.id); | ||||
|             Assert.Equal(find.title, item.title); | ||||
|         } | ||||
|         [Table(Name = "ts_iupstr_bak", DisableSyncStructure = true)] | ||||
|         class ts_iupstr | ||||
|         { | ||||
|             public Guid id { get; set; } | ||||
|             public string title { get; set; } | ||||
|         } | ||||
|         class ts_iupstr_bak | ||||
|         { | ||||
|             public Guid id { get; set; } | ||||
|             [Column(StringLength = -1)] | ||||
|             public string title { get; set; } | ||||
|         } | ||||
|  | ||||
|         [Fact] | ||||
|         public void Timestamp01() | ||||
|         { | ||||
|   | ||||
| @@ -12,6 +12,31 @@ namespace FreeSql.Tests.Dameng | ||||
| { | ||||
|     public class DamengCodeFirstTest | ||||
|     { | ||||
|         [Fact] | ||||
|         public void InsertUpdateParameter() | ||||
|         { | ||||
|             var fsql = g.dameng; | ||||
|             fsql.CodeFirst.SyncStructure<ts_iupstr_bak>(); | ||||
|             var item = new ts_iupstr { id = Guid.NewGuid(), title = string.Join(",", Enumerable.Range(0, 2000).Select(a => "<22><><EFBFBD><EFBFBD><EFBFBD>й<EFBFBD><D0B9><EFBFBD>")) }; | ||||
|             Assert.Equal(1, fsql.Insert(item).ExecuteAffrows()); | ||||
|             var find = fsql.Select<ts_iupstr>().Where(a => a.id == item.id).First(); | ||||
|             Assert.NotNull(find); | ||||
|             Assert.Equal(find.id, item.id); | ||||
|             Assert.Equal(find.title, item.title); | ||||
|         } | ||||
|         [Table(Name = "ts_iupstr_bak", DisableSyncStructure = true)] | ||||
|         class ts_iupstr | ||||
|         { | ||||
|             public Guid id { get; set; } | ||||
|             public string title { get; set; } | ||||
|         } | ||||
|         class ts_iupstr_bak | ||||
|         { | ||||
|             public Guid id { get; set; } | ||||
|             [Column(StringLength = -1)] | ||||
|             public string title { get; set; } | ||||
|         } | ||||
|  | ||||
|         [Fact] | ||||
|         public void StringLength36() | ||||
|         { | ||||
|   | ||||
| @@ -10,6 +10,31 @@ namespace FreeSql.Tests.Firebird | ||||
| { | ||||
|     public class FirebirdCodeFirstTest | ||||
|     { | ||||
|         [Fact] | ||||
|         public void InsertUpdateParameter() | ||||
|         { | ||||
|             var fsql = g.firebird; | ||||
|             fsql.CodeFirst.SyncStructure<ts_iupstr_bak>(); | ||||
|             var item = new ts_iupstr { id = Guid.NewGuid(), title = string.Join(",", Enumerable.Range(0, 2000).Select(a => "<22><><EFBFBD><EFBFBD><EFBFBD>й<EFBFBD><D0B9><EFBFBD>")) }; | ||||
|             Assert.Equal(1, fsql.Insert(item).ExecuteAffrows()); | ||||
|             var find = fsql.Select<ts_iupstr>().Where(a => a.id == item.id).First(); | ||||
|             Assert.NotNull(find); | ||||
|             Assert.Equal(find.id, item.id); | ||||
|             Assert.Equal(find.title, item.title); | ||||
|         } | ||||
|         [Table(Name = "ts_iupstr_bak", DisableSyncStructure = true)] | ||||
|         class ts_iupstr | ||||
|         { | ||||
|             public Guid id { get; set; } | ||||
|             public string title { get; set; } | ||||
|         } | ||||
|         class ts_iupstr_bak | ||||
|         { | ||||
|             public Guid id { get; set; } | ||||
|             [Column(StringLength = -1)] | ||||
|             public string title { get; set; } | ||||
|         } | ||||
|  | ||||
|         [Fact] | ||||
|         public void Text_StringLength_1() | ||||
|         { | ||||
|   | ||||
| @@ -10,6 +10,31 @@ namespace FreeSql.Tests.KingbaseES | ||||
| { | ||||
|     public class KingbaseESCodeFirstTest | ||||
|     { | ||||
|         [Fact] | ||||
|         public void InsertUpdateParameter() | ||||
|         { | ||||
|             var fsql = g.kingbaseES; | ||||
|             fsql.CodeFirst.SyncStructure<ts_iupstr_bak>(); | ||||
|             var item = new ts_iupstr { id = Guid.NewGuid(), title = string.Join(",", Enumerable.Range(0, 2000).Select(a => "<22><><EFBFBD><EFBFBD><EFBFBD>й<EFBFBD><D0B9><EFBFBD>")) }; | ||||
|             Assert.Equal(1, fsql.Insert(item).ExecuteAffrows()); | ||||
|             var find = fsql.Select<ts_iupstr>().Where(a => a.id == item.id).First(); | ||||
|             Assert.NotNull(find); | ||||
|             Assert.Equal(find.id, item.id); | ||||
|             Assert.Equal(find.title, item.title); | ||||
|         } | ||||
|         [Table(Name = "ts_iupstr_bak", DisableSyncStructure = true)] | ||||
|         class ts_iupstr | ||||
|         { | ||||
|             public Guid id { get; set; } | ||||
|             public string title { get; set; } | ||||
|         } | ||||
|         class ts_iupstr_bak | ||||
|         { | ||||
|             public Guid id { get; set; } | ||||
|             [Column(StringLength = -1)] | ||||
|             public string title { get; set; } | ||||
|         } | ||||
|  | ||||
|         [Fact] | ||||
|         public void StringLength() | ||||
|         { | ||||
|   | ||||
| @@ -10,6 +10,31 @@ namespace FreeSql.Tests.MsAccess | ||||
| { | ||||
|     public class MsAccessCodeFirstTest | ||||
|     { | ||||
|         [Fact] | ||||
|         public void InsertUpdateParameter() | ||||
|         { | ||||
|             var fsql = g.msaccess; | ||||
|             fsql.CodeFirst.SyncStructure<ts_iupstr_bak>(); | ||||
|             var item = new ts_iupstr { id = Guid.NewGuid(), title = string.Join(",", Enumerable.Range(0, 2000).Select(a => "<22><><EFBFBD><EFBFBD><EFBFBD>й<EFBFBD><D0B9><EFBFBD>")) }; | ||||
|             Assert.Equal(1, fsql.Insert(item).ExecuteAffrows()); | ||||
|             var find = fsql.Select<ts_iupstr>().Where(a => a.id == item.id).First(); | ||||
|             Assert.NotNull(find); | ||||
|             Assert.Equal(find.id, item.id); | ||||
|             Assert.Equal(find.title, item.title); | ||||
|         } | ||||
|         [Table(Name = "ts_iupstr_bak", DisableSyncStructure = true)] | ||||
|         class ts_iupstr | ||||
|         { | ||||
|             public Guid id { get; set; } | ||||
|             public string title { get; set; } | ||||
|         } | ||||
|         class ts_iupstr_bak | ||||
|         { | ||||
|             public Guid id { get; set; } | ||||
|             [Column(StringLength = -1)] | ||||
|             public string title { get; set; } | ||||
|         } | ||||
|  | ||||
|         [Fact] | ||||
|         public void StringLength() | ||||
|         { | ||||
|   | ||||
| @@ -11,6 +11,31 @@ namespace FreeSql.Tests.MySql | ||||
| { | ||||
|     public class MySqlCodeFirstTest | ||||
|     { | ||||
|         [Fact] | ||||
|         public void InsertUpdateParameter() | ||||
|         { | ||||
|             var fsql = g.mysql; | ||||
|             fsql.CodeFirst.SyncStructure<ts_iupstr_bak>(); | ||||
|             var item = new ts_iupstr { id = Guid.NewGuid(), title = string.Join(",", Enumerable.Range(0, 2000).Select(a => "<22><><EFBFBD><EFBFBD><EFBFBD>й<EFBFBD><D0B9><EFBFBD>")) }; | ||||
|             Assert.Equal(1, fsql.Insert(item).ExecuteAffrows()); | ||||
|             var find = fsql.Select<ts_iupstr>().Where(a => a.id == item.id).First(); | ||||
|             Assert.NotNull(find); | ||||
|             Assert.Equal(find.id, item.id); | ||||
|             Assert.Equal(find.title, item.title); | ||||
|         } | ||||
|         [Table(Name = "ts_iupstr_bak", DisableSyncStructure = true)] | ||||
|         class ts_iupstr | ||||
|         { | ||||
|             public Guid id { get; set; } | ||||
|             public string title { get; set; } | ||||
|         } | ||||
|         class ts_iupstr_bak | ||||
|         { | ||||
|             public Guid id { get; set; } | ||||
|             [Column(StringLength = -1)] | ||||
|             public string title { get; set; } | ||||
|         } | ||||
|  | ||||
|         [Fact] | ||||
|         public void Timestamp01() | ||||
|         { | ||||
|   | ||||
| @@ -15,6 +15,31 @@ namespace FreeSql.Tests.Oracle | ||||
| { | ||||
|     public class OracleCodeFirstTest | ||||
|     { | ||||
|         [Fact] | ||||
|         public void InsertUpdateParameter() | ||||
|         { | ||||
|             var fsql = g.oracle; | ||||
|             fsql.CodeFirst.SyncStructure<ts_iupstr_bak>(); | ||||
|             var item = new ts_iupstr { id = Guid.NewGuid(), title = string.Join(",", Enumerable.Range(0, 2000).Select(a => "<22><><EFBFBD><EFBFBD><EFBFBD>й<EFBFBD><D0B9><EFBFBD>")) }; | ||||
|             Assert.Equal(1, fsql.Insert(item).ExecuteAffrows()); | ||||
|             var find = fsql.Select<ts_iupstr>().Where(a => a.id == item.id).First(); | ||||
|             Assert.NotNull(find); | ||||
|             Assert.Equal(find.id, item.id); | ||||
|             Assert.Equal(find.title, item.title); | ||||
|         } | ||||
|         [Table(Name = "ts_iupstr_bak", DisableSyncStructure = true)] | ||||
|         class ts_iupstr | ||||
|         { | ||||
|             public Guid id { get; set; } | ||||
|             public string title { get; set; } | ||||
|         } | ||||
|         class ts_iupstr_bak | ||||
|         { | ||||
|             public Guid id { get; set; } | ||||
|             [Column(StringLength = -1)] | ||||
|             public string title { get; set; } | ||||
|         } | ||||
|  | ||||
|         [Fact] | ||||
|         public void StringNullToEmpty() | ||||
|         { | ||||
|   | ||||
| @@ -18,6 +18,31 @@ namespace FreeSql.Tests.PostgreSQL | ||||
| { | ||||
|     public class PostgreSQLCodeFirstTest | ||||
|     { | ||||
|         [Fact] | ||||
|         public void InsertUpdateParameter() | ||||
|         { | ||||
|             var fsql = g.pgsql; | ||||
|             fsql.CodeFirst.SyncStructure<ts_iupstr_bak>(); | ||||
|             var item = new ts_iupstr { id = Guid.NewGuid(), title = string.Join(",", Enumerable.Range(0, 2000).Select(a => "<22><><EFBFBD><EFBFBD><EFBFBD>й<EFBFBD><D0B9><EFBFBD>")) }; | ||||
|             Assert.Equal(1, fsql.Insert(item).ExecuteAffrows()); | ||||
|             var find = fsql.Select<ts_iupstr>().Where(a => a.id == item.id).First(); | ||||
|             Assert.NotNull(find); | ||||
|             Assert.Equal(find.id, item.id); | ||||
|             Assert.Equal(find.title, item.title); | ||||
|         } | ||||
|         [Table(Name = "ts_iupstr_bak", DisableSyncStructure = true)] | ||||
|         class ts_iupstr | ||||
|         { | ||||
|             public Guid id { get; set; } | ||||
|             public string title { get; set; } | ||||
|         } | ||||
|         class ts_iupstr_bak | ||||
|         { | ||||
|             public Guid id { get; set; } | ||||
|             [Column(StringLength = -1)] | ||||
|             public string title { get; set; } | ||||
|         } | ||||
|  | ||||
|         [Fact] | ||||
|         public void DateTime_1() | ||||
|         { | ||||
|   | ||||
| @@ -13,6 +13,30 @@ namespace FreeSql.Tests.ShenTong | ||||
| { | ||||
|     public class ShenTongCodeFirstTest | ||||
|     { | ||||
|         [Fact] | ||||
|         public void InsertUpdateParameter() | ||||
|         { | ||||
|             var fsql = g.shentong; | ||||
|             fsql.CodeFirst.SyncStructure<ts_iupstr_bak>(); | ||||
|             var item = new ts_iupstr { id = Guid.NewGuid(), title = string.Join(",", Enumerable.Range(0, 2000).Select(a => "<22><><EFBFBD><EFBFBD><EFBFBD>й<EFBFBD><D0B9><EFBFBD>")) }; | ||||
|             Assert.Equal(1, fsql.Insert(item).ExecuteAffrows()); | ||||
|             var find = fsql.Select<ts_iupstr>().Where(a => a.id == item.id).First(); | ||||
|             Assert.NotNull(find); | ||||
|             Assert.Equal(find.id, item.id); | ||||
|             Assert.Equal(find.title, item.title); | ||||
|         } | ||||
|         [Table(Name = "ts_iupstr_bak", DisableSyncStructure = true)] | ||||
|         class ts_iupstr | ||||
|         { | ||||
|             public Guid id { get; set; } | ||||
|             public string title { get; set; } | ||||
|         } | ||||
|         class ts_iupstr_bak | ||||
|         { | ||||
|             public Guid id { get; set; } | ||||
|             [Column(StringLength = -1)] | ||||
|             public string title { get; set; } | ||||
|         } | ||||
|  | ||||
|         [Fact] | ||||
|         public void StringLength() | ||||
|   | ||||
| @@ -12,6 +12,31 @@ namespace FreeSql.Tests.SqlServer | ||||
| { | ||||
|     public class SqlServerCodeFirstTest | ||||
|     { | ||||
|         [Fact] | ||||
|         public void InsertUpdateParameter() | ||||
|         { | ||||
|             var fsql = g.sqlserver; | ||||
|             fsql.CodeFirst.SyncStructure<ts_iupstr_bak>(); | ||||
|             var item = new ts_iupstr { id = Guid.NewGuid(), title = string.Join(",", Enumerable.Range(0, 2000).Select(a => "<22><><EFBFBD><EFBFBD><EFBFBD>й<EFBFBD><D0B9><EFBFBD>")) }; | ||||
|             Assert.Equal(1, fsql.Insert(item).ExecuteAffrows()); | ||||
|             var find = fsql.Select<ts_iupstr>().Where(a => a.id == item.id).First(); | ||||
|             Assert.NotNull(find); | ||||
|             Assert.Equal(find.id, item.id); | ||||
|             Assert.Equal(find.title, item.title); | ||||
|         } | ||||
|         [Table(Name = "ts_iupstr_bak", DisableSyncStructure = true)] | ||||
|         class ts_iupstr | ||||
|         { | ||||
|             public Guid id { get; set; } | ||||
|             public string title { get; set; } | ||||
|         } | ||||
|         class ts_iupstr_bak | ||||
|         { | ||||
|             public Guid id { get; set; } | ||||
|             [Column(StringLength = -1)] | ||||
|             public string title { get; set; } | ||||
|         } | ||||
|  | ||||
|         [Fact]  | ||||
|         public void EnumStartValue1() | ||||
|         { | ||||
|   | ||||
| @@ -11,6 +11,31 @@ namespace FreeSql.Tests.Sqlite | ||||
| { | ||||
|     public class SqliteCodeFirstTest | ||||
|     { | ||||
|         [Fact] | ||||
|         public void InsertUpdateParameter() | ||||
|         { | ||||
|             var fsql = g.sqlite; | ||||
|             fsql.CodeFirst.SyncStructure<ts_iupstr_bak>(); | ||||
|             var item = new ts_iupstr { id = Guid.NewGuid(), title = string.Join(",", Enumerable.Range(0, 2000).Select(a => "<22><><EFBFBD><EFBFBD><EFBFBD>й<EFBFBD><D0B9><EFBFBD>")) }; | ||||
|             Assert.Equal(1, fsql.Insert(item).ExecuteAffrows()); | ||||
|             var find = fsql.Select<ts_iupstr>().Where(a => a.id == item.id).First(); | ||||
|             Assert.NotNull(find); | ||||
|             Assert.Equal(find.id, item.id); | ||||
|             Assert.Equal(find.title, item.title); | ||||
|         } | ||||
|         [Table(Name = "ts_iupstr_bak", DisableSyncStructure = true)] | ||||
|         class ts_iupstr | ||||
|         { | ||||
|             public Guid id { get; set; } | ||||
|             public string title { get; set; } | ||||
|         } | ||||
|         class ts_iupstr_bak | ||||
|         { | ||||
|             public Guid id { get; set; } | ||||
|             [Column(StringLength = -1)] | ||||
|             public string title { get; set; } | ||||
|         } | ||||
|  | ||||
|         [Fact] | ||||
|         public void Blob() | ||||
|         { | ||||
|   | ||||
| @@ -23,7 +23,7 @@ namespace FreeSql.Dameng | ||||
|             { | ||||
|                 case DmDbType.Bit: | ||||
|                     if (value == null) value = null; | ||||
|                     else value = (bool)value == true ? 1 : 0; | ||||
|                     else value = (bool) value == true ? 1 : 0; | ||||
|                     dbtype = DmDbType.Int32; | ||||
|                     break; | ||||
|                 | ||||
|   | ||||
| @@ -29,7 +29,7 @@ namespace FreeSql.Firebird | ||||
|                         break; | ||||
|                     default: | ||||
|                         dbtype = dbtype2; | ||||
|                         if (col.DbSize != 0) ret.Size = col.DbSize; | ||||
|                         //if (col.DbSize != 0) ret.Size = col.DbSize; | ||||
|                         if (col.DbPrecision != 0) ret.Precision = col.DbPrecision; | ||||
|                         if (col.DbScale != 0) ret.Scale = col.DbScale; | ||||
|                         break; | ||||
|   | ||||
| @@ -34,7 +34,7 @@ namespace FreeSql.MySql | ||||
|                         break; | ||||
|                     default: | ||||
|                         dbtype = dbtype2; | ||||
|                         if (col.DbSize != 0) ret.Size = col.DbSize; | ||||
|                         //if (col.DbSize != 0) ret.Size = col.DbSize; | ||||
|                         if (col.DbPrecision != 0) ret.Precision = col.DbPrecision; | ||||
|                         if (col.DbScale != 0) ret.Scale = col.DbScale; | ||||
|                         break; | ||||
|   | ||||
| @@ -31,7 +31,7 @@ namespace FreeSql.MySql | ||||
|                     //    break; | ||||
|                     default: | ||||
|                         dbtype = dbtype2; | ||||
|                         if (col.DbSize != 0) ret.Size = col.DbSize; | ||||
|                         //if (col.DbSize != 0) ret.Size = col.DbSize; | ||||
|                         if (col.DbPrecision != 0) ret.Precision = col.DbPrecision; | ||||
|                         if (col.DbScale != 0) ret.Scale = col.DbScale; | ||||
|                         break; | ||||
|   | ||||
| @@ -37,7 +37,7 @@ namespace FreeSql.Oracle | ||||
|                     case OracleDbType.NVarchar2: | ||||
|                     case OracleDbType.Decimal: | ||||
|                         dbtype = dbtype2; | ||||
|                         if (col.DbSize != 0) ret.Size = col.DbSize; | ||||
|                         //if (col.DbSize != 0) ret.Size = col.DbSize; | ||||
|                         if (col.DbPrecision != 0) ret.Precision = col.DbPrecision; | ||||
|                         if (col.DbScale != 0) ret.Scale = col.DbScale; | ||||
|                         break; | ||||
|   | ||||
| @@ -105,7 +105,7 @@ namespace FreeSql.PostgreSQL | ||||
|                 if (dbtype != NpgsqlDbType.Unknown) | ||||
|                 { | ||||
|                     ret.NpgsqlDbType = dbtype; | ||||
|                     if (col.DbSize != 0) ret.Size = col.DbSize; | ||||
|                     //if (col.DbSize != 0) ret.Size = col.DbSize; | ||||
|                     if (col.DbPrecision != 0) ret.Precision = col.DbPrecision; | ||||
|                     if (col.DbScale != 0) ret.Scale = col.DbScale; | ||||
|                 } | ||||
|   | ||||
| @@ -80,7 +80,7 @@ namespace FreeSql.ShenTong | ||||
|                 if (dbtype != OscarDbType.Oidvector) | ||||
|                 { | ||||
|                     ret.OscarDbType = dbtype; | ||||
|                     if (col.DbSize != 0) ret.Size = col.DbSize; | ||||
|                     //if (col.DbSize != 0) ret.Size = col.DbSize; | ||||
|                     if (col.DbPrecision != 0) ret.Precision = col.DbPrecision; | ||||
|                     if (col.DbScale != 0) ret.Scale = col.DbScale; | ||||
|                 } | ||||
|   | ||||
| @@ -39,7 +39,7 @@ namespace FreeSql.SqlServer | ||||
|                 if (dbtype != SqlDbType.Variant) | ||||
|                 { | ||||
|                     ret.SqlDbType = dbtype; | ||||
|                     if (col.DbSize != 0) ret.Size = col.DbSize; | ||||
|                     //if (col.DbSize != 0) ret.Size = col.DbSize; | ||||
|                     if (col.DbPrecision != 0) ret.Precision = col.DbPrecision; | ||||
|                     if (col.DbScale != 0) ret.Scale = col.DbScale; | ||||
|                 } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 2881099
					2881099