mirror of
				https://github.com/nsnail/FreeSql.git
				synced 2025-11-04 17:20:49 +08:00 
			
		
		
		
	- 优化 MySql StringLength/MaxLength -2 产生 LongText 映射;
This commit is contained in:
		@@ -125,6 +125,13 @@
 | 
				
			|||||||
            清空状态数据
 | 
					            清空状态数据
 | 
				
			||||||
            </summary>
 | 
					            </summary>
 | 
				
			||||||
        </member>
 | 
					        </member>
 | 
				
			||||||
 | 
					        <member name="M:FreeSql.DbSet`1.RemoveAsync(System.Linq.Expressions.Expression{System.Func{`0,System.Boolean}})">
 | 
				
			||||||
 | 
					            <summary>
 | 
				
			||||||
 | 
					            根据 lambda 条件删除数据
 | 
				
			||||||
 | 
					            </summary>
 | 
				
			||||||
 | 
					            <param name="predicate"></param>
 | 
				
			||||||
 | 
					            <returns></returns>
 | 
				
			||||||
 | 
					        </member>
 | 
				
			||||||
        <member name="M:FreeSql.DbSet`1.Add(`0)">
 | 
					        <member name="M:FreeSql.DbSet`1.Add(`0)">
 | 
				
			||||||
            <summary>
 | 
					            <summary>
 | 
				
			||||||
            添加
 | 
					            添加
 | 
				
			||||||
@@ -479,5 +486,14 @@
 | 
				
			|||||||
            <param name="that"></param>
 | 
					            <param name="that"></param>
 | 
				
			||||||
            <returns></returns>
 | 
					            <returns></returns>
 | 
				
			||||||
        </member>
 | 
					        </member>
 | 
				
			||||||
 | 
					        <member name="M:Microsoft.Extensions.DependencyInjection.FreeSqlRepositoryDependencyInjection.AddFreeRepository(Microsoft.Extensions.DependencyInjection.IServiceCollection,System.Action{FreeSql.FluentDataFilter},System.Reflection.Assembly[])">
 | 
				
			||||||
 | 
					            <summary>
 | 
				
			||||||
 | 
					            批量注入 Repository,可以参考代码自行调整
 | 
				
			||||||
 | 
					            </summary>
 | 
				
			||||||
 | 
					            <param name="services"></param>
 | 
				
			||||||
 | 
					            <param name="globalDataFilter"></param>
 | 
				
			||||||
 | 
					            <param name="assemblies"></param>
 | 
				
			||||||
 | 
					            <returns></returns>
 | 
				
			||||||
 | 
					        </member>
 | 
				
			||||||
    </members>
 | 
					    </members>
 | 
				
			||||||
</doc>
 | 
					</doc>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -10,6 +10,94 @@ namespace FreeSql.Tests.MySqlConnector
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    public class MySqlCodeFirstTest
 | 
					    public class MySqlCodeFirstTest
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					        [Fact]
 | 
				
			||||||
 | 
					        public void Text_StringLength_1()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            var str1 = string.Join(",", Enumerable.Range(0, 1000).Select(a => "<22><><EFBFBD><EFBFBD><EFBFBD>й<EFBFBD><D0B9><EFBFBD>"));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            var item1 = new TS_TEXT02 { Data = str1 };
 | 
				
			||||||
 | 
					            Assert.Equal(1, g.mysql.Insert(item1).ExecuteAffrows());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            var item2 = g.mysql.Select<TS_TEXT02>().Where(a => a.Id == item1.Id).First();
 | 
				
			||||||
 | 
					            Assert.Equal(str1, item2.Data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            //NoneParameter
 | 
				
			||||||
 | 
					            item1 = new TS_TEXT02 { Data = str1 };
 | 
				
			||||||
 | 
					            Assert.Equal(1, g.mysql.Insert(item1).NoneParameter().ExecuteAffrows());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        class TS_TEXT02
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            public Guid Id { get; set; }
 | 
				
			||||||
 | 
					            [Column(StringLength = -1)]
 | 
				
			||||||
 | 
					            public string Data { get; set; }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [Fact]
 | 
				
			||||||
 | 
					        public void Text()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            var str1 = string.Join(",", Enumerable.Range(0, 1000).Select(a => "<22><><EFBFBD><EFBFBD><EFBFBD>й<EFBFBD><D0B9><EFBFBD>"));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            var item1 = new TS_TEXT01 { Data = str1 };
 | 
				
			||||||
 | 
					            Assert.Equal(1, g.mysql.Insert(item1).ExecuteAffrows());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            var item2 = g.mysql.Select<TS_TEXT01>().Where(a => a.Id == item1.Id).First();
 | 
				
			||||||
 | 
					            Assert.Equal(str1, item2.Data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            //NoneParameter
 | 
				
			||||||
 | 
					            item1 = new TS_TEXT01 { Data = str1 };
 | 
				
			||||||
 | 
					            Assert.Equal(1, g.mysql.Insert(item1).NoneParameter().ExecuteAffrows());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        class TS_TEXT01
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            public Guid Id { get; set; }
 | 
				
			||||||
 | 
					            [Column(DbType = "text")]
 | 
				
			||||||
 | 
					            public string Data { get; set; }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [Fact]
 | 
				
			||||||
 | 
					        public void Text_StringLength_2()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            var str1 = string.Join(",", Enumerable.Range(0, 10000).Select(a => "<22><><EFBFBD><EFBFBD><EFBFBD>й<EFBFBD><D0B9><EFBFBD>"));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            var item1 = new TS_TEXT04 { Data = str1 };
 | 
				
			||||||
 | 
					            Assert.Equal(1, g.mysql.Insert(item1).ExecuteAffrows());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            var item2 = g.mysql.Select<TS_TEXT04>().Where(a => a.Id == item1.Id).First();
 | 
				
			||||||
 | 
					            Assert.Equal(str1, item2.Data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            //NoneParameter
 | 
				
			||||||
 | 
					            item1 = new TS_TEXT04 { Data = str1 };
 | 
				
			||||||
 | 
					            Assert.Equal(1, g.mysql.Insert(item1).NoneParameter().ExecuteAffrows());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        class TS_TEXT04
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            public Guid Id { get; set; }
 | 
				
			||||||
 | 
					            [Column(StringLength = -2)]
 | 
				
			||||||
 | 
					            public string Data { get; set; }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [Fact]
 | 
				
			||||||
 | 
					        public void LongText()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            var str1 = string.Join(",", Enumerable.Range(0, 10000).Select(a => "<22><><EFBFBD><EFBFBD><EFBFBD>й<EFBFBD><D0B9><EFBFBD>"));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            var item1 = new TS_TEXT03 { Data = str1 };
 | 
				
			||||||
 | 
					            Assert.Equal(1, g.mysql.Insert(item1).ExecuteAffrows());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            var item2 = g.mysql.Select<TS_TEXT03>().Where(a => a.Id == item1.Id).First();
 | 
				
			||||||
 | 
					            Assert.Equal(str1, item2.Data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            //NoneParameter
 | 
				
			||||||
 | 
					            item1 = new TS_TEXT03 { Data = str1 };
 | 
				
			||||||
 | 
					            Assert.Equal(1, g.mysql.Insert(item1).NoneParameter().ExecuteAffrows());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        class TS_TEXT03
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            public Guid Id { get; set; }
 | 
				
			||||||
 | 
					            [Column(DbType = "longtext")]
 | 
				
			||||||
 | 
					            public string Data { get; set; }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        [Fact]
 | 
					        [Fact]
 | 
				
			||||||
        public void StringLength()
 | 
					        public void StringLength()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,7 +9,7 @@ namespace FreeSql.Tests.Dameng
 | 
				
			|||||||
    public class DamengInsertTest
 | 
					    public class DamengInsertTest
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        IInsert<Topic> insert => g.dameng.Insert<Topic>(); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
					        IInsert<Topic> insert => g.dameng.Insert<Topic>().NoneParameter();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        [Table(Name = "tb_topic_insert")]
 | 
					        [Table(Name = "tb_topic_insert")]
 | 
				
			||||||
        class Topic
 | 
					        class Topic
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,7 +7,7 @@ namespace FreeSql.Tests.Dameng
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    public class DamengUpdateTest
 | 
					    public class DamengUpdateTest
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        IUpdate<Topic> update => g.dameng.Update<Topic>();
 | 
					        IUpdate<Topic> update => g.dameng.Update<Topic>().NoneParameter();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        [Table(Name = "tb_topic")]
 | 
					        [Table(Name = "tb_topic")]
 | 
				
			||||||
        class Topic
 | 
					        class Topic
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -10,6 +10,74 @@ namespace FreeSql.Tests.Dameng
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    public class DamengCodeFirstTest
 | 
					    public class DamengCodeFirstTest
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					        [Fact]
 | 
				
			||||||
 | 
					        public void Text_StringLength_1()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            var str1 = string.Join(",", Enumerable.Range(0, 10000).Select(a => "<22><><EFBFBD><EFBFBD><EFBFBD>й<EFBFBD><D0B9><EFBFBD>"));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            var item1 = new TS_TEXT02 { Data = str1 };
 | 
				
			||||||
 | 
					            Assert.Equal(1, g.dameng.Insert(item1).ExecuteAffrows());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            var item2 = g.dameng.Select<TS_TEXT02>().Where(a => a.Id == item1.Id).First();
 | 
				
			||||||
 | 
					            Assert.Equal(str1, item2.Data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            //NoneParameter
 | 
				
			||||||
 | 
					            item1 = new TS_TEXT02 { Data = str1 };
 | 
				
			||||||
 | 
					            Assert.Equal(1, g.dameng.Insert(item1).NoneParameter().ExecuteAffrows());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        class TS_TEXT02
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            public Guid Id { get; set; }
 | 
				
			||||||
 | 
					            [Column(StringLength = -1)]
 | 
				
			||||||
 | 
					            public string Data { get; set; }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [Fact]
 | 
				
			||||||
 | 
					        public void Text()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            var str1 = string.Join(",", Enumerable.Range(0, 10000).Select(a => "<22><><EFBFBD><EFBFBD><EFBFBD>й<EFBFBD><D0B9><EFBFBD>"));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            var item1 = new TS_TEXT01 { Data = str1 };
 | 
				
			||||||
 | 
					            Assert.Equal(1, g.dameng.Insert(item1).ExecuteAffrows());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            var item2 = g.dameng.Select<TS_TEXT01>().Where(a => a.Id == item1.Id).First();
 | 
				
			||||||
 | 
					            Assert.Equal(str1, item2.Data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            //NoneParameter
 | 
				
			||||||
 | 
					            item1 = new TS_TEXT01 { Data = str1 };
 | 
				
			||||||
 | 
					            Assert.Equal(1, g.dameng.Insert(item1).NoneParameter().ExecuteAffrows());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        class TS_TEXT01
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            public Guid Id { get; set; }
 | 
				
			||||||
 | 
					            [Column(DbType = "text")]
 | 
				
			||||||
 | 
					            public string Data { get; set; }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        [Fact]
 | 
				
			||||||
 | 
					        public void Blob()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            var str1 = string.Join(",", Enumerable.Range(0, 10000).Select(a => "<22><><EFBFBD><EFBFBD><EFBFBD>й<EFBFBD><D0B9><EFBFBD>"));
 | 
				
			||||||
 | 
					            var data1 = Encoding.UTF8.GetBytes(str1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            var item1 = new TS_BLB01 { Data = data1 };
 | 
				
			||||||
 | 
					            Assert.Equal(1, g.dameng.Insert(item1).ExecuteAffrows());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            var item2 = g.dameng.Select<TS_BLB01>().Where(a => a.Id == item1.Id).First();
 | 
				
			||||||
 | 
					            Assert.Equal(item1.Data.Length, item2.Data.Length);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            var str2 = Encoding.UTF8.GetString(item2.Data);
 | 
				
			||||||
 | 
					            Assert.Equal(str1, str2);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            //NoneParameter
 | 
				
			||||||
 | 
					            item1 = new TS_BLB01 { Data = data1 };
 | 
				
			||||||
 | 
					            Assert.Throws<Exception>(() => g.dameng.Insert(item1).NoneParameter().ExecuteAffrows());
 | 
				
			||||||
 | 
					            //DmException: <20>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>ض<EFBFBD>
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        class TS_BLB01
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            public Guid Id { get; set; }
 | 
				
			||||||
 | 
					            public byte[] Data { get; set; }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        [Fact]
 | 
					        [Fact]
 | 
				
			||||||
        public void StringLength()
 | 
					        public void StringLength()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
@@ -238,11 +306,6 @@ namespace FreeSql.Tests.Dameng
 | 
				
			|||||||
        [Fact]
 | 
					        [Fact]
 | 
				
			||||||
        public void CurdAllField()
 | 
					        public void CurdAllField()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            var item = new TableAllType { };
 | 
					 | 
				
			||||||
            item.Id = (int)insert.AppendData(item).ExecuteIdentity();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            var newitem = select.Where(a => a.Id == item.Id).ToOne();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            var item2 = new TableAllType
 | 
					            var item2 = new TableAllType
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                Bool = true,
 | 
					                Bool = true,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1497,15 +1497,6 @@ namespace FreeSql.Tests.DamengMapType
 | 
				
			|||||||
            Assert.Equal(item.tostring, find.tostring);
 | 
					            Assert.Equal(item.tostring, find.tostring);
 | 
				
			||||||
            Assert.Equal(false, find.tostring);
 | 
					            Assert.Equal(false, find.tostring);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            item = new BoolNullableMap { tostring = null };
 | 
					 | 
				
			||||||
            Assert.Equal(1, orm.Insert<BoolNullableMap>().AppendData(item).ExecuteAffrows());
 | 
					 | 
				
			||||||
            Assert.Null(orm.Select<BoolNullableMap>().Where(a => a.id == item.id && a.tostring == false).First());
 | 
					 | 
				
			||||||
            find = orm.Select<BoolNullableMap>().Where(a => a.id == item.id && a.tostring == null).First();
 | 
					 | 
				
			||||||
            Assert.NotNull(find);
 | 
					 | 
				
			||||||
            Assert.Equal(item.id, find.id);
 | 
					 | 
				
			||||||
            Assert.Equal(item.tostring, find.tostring);
 | 
					 | 
				
			||||||
            Assert.Null(find.tostring);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            //update all
 | 
					            //update all
 | 
				
			||||||
            item.tostring = true;
 | 
					            item.tostring = true;
 | 
				
			||||||
            Assert.Equal(1, orm.Update<BoolNullableMap>().SetSource(item).ExecuteAffrows());
 | 
					            Assert.Equal(1, orm.Update<BoolNullableMap>().SetSource(item).ExecuteAffrows());
 | 
				
			||||||
@@ -1523,15 +1514,6 @@ namespace FreeSql.Tests.DamengMapType
 | 
				
			|||||||
            Assert.Equal(item.tostring, find.tostring);
 | 
					            Assert.Equal(item.tostring, find.tostring);
 | 
				
			||||||
            Assert.Equal(false, find.tostring);
 | 
					            Assert.Equal(false, find.tostring);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            item.tostring = null;
 | 
					 | 
				
			||||||
            Assert.Equal(1, orm.Update<BoolNullableMap>().SetSource(item).ExecuteAffrows());
 | 
					 | 
				
			||||||
            Assert.Null(orm.Select<BoolNullableMap>().Where(a => a.id == item.id && a.tostring == false).First());
 | 
					 | 
				
			||||||
            find = orm.Select<BoolNullableMap>().Where(a => a.id == item.id && a.tostring == null).First();
 | 
					 | 
				
			||||||
            Assert.NotNull(find);
 | 
					 | 
				
			||||||
            Assert.Equal(item.id, find.id);
 | 
					 | 
				
			||||||
            Assert.Equal(item.tostring, find.tostring);
 | 
					 | 
				
			||||||
            Assert.Null(find.tostring);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            //update set
 | 
					            //update set
 | 
				
			||||||
            Assert.Equal(1, orm.Update<BoolNullableMap>().Where(a => a.id == item.id).Set(a => a.tostring, true).ExecuteAffrows());
 | 
					            Assert.Equal(1, orm.Update<BoolNullableMap>().Where(a => a.id == item.id).Set(a => a.tostring, true).ExecuteAffrows());
 | 
				
			||||||
            find = orm.Select<BoolNullableMap>().Where(a => a.id == item.id && a.tostring == true).First();
 | 
					            find = orm.Select<BoolNullableMap>().Where(a => a.id == item.id && a.tostring == true).First();
 | 
				
			||||||
@@ -1545,17 +1527,9 @@ namespace FreeSql.Tests.DamengMapType
 | 
				
			|||||||
            Assert.Equal(item.id, find.id);
 | 
					            Assert.Equal(item.id, find.id);
 | 
				
			||||||
            Assert.Equal(false, find.tostring);
 | 
					            Assert.Equal(false, find.tostring);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            Assert.Equal(1, orm.Update<BoolNullableMap>().Where(a => a.id == item.id).Set(a => a.tostring, null).ExecuteAffrows());
 | 
					 | 
				
			||||||
            Assert.Null(orm.Select<BoolNullableMap>().Where(a => a.id == item.id && a.tostring == false).First());
 | 
					 | 
				
			||||||
            find = orm.Select<BoolNullableMap>().Where(a => a.id == item.id && a.tostring == null).First();
 | 
					 | 
				
			||||||
            Assert.NotNull(find);
 | 
					 | 
				
			||||||
            Assert.Equal(item.id, find.id);
 | 
					 | 
				
			||||||
            Assert.Null(find.tostring);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            //delete
 | 
					            //delete
 | 
				
			||||||
            Assert.Equal(0, orm.Delete<BoolNullableMap>().Where(a => a.id == item.id && a.tostring == true).ExecuteAffrows());
 | 
					            Assert.Equal(0, orm.Delete<BoolNullableMap>().Where(a => a.id == item.id && a.tostring == true).ExecuteAffrows());
 | 
				
			||||||
            Assert.Equal(0, orm.Delete<BoolNullableMap>().Where(a => a.id == item.id && a.tostring == false).ExecuteAffrows());
 | 
					            Assert.Equal(1, orm.Delete<BoolNullableMap>().Where(a => a.id == item.id && a.tostring == false).ExecuteAffrows());
 | 
				
			||||||
            Assert.Equal(1, orm.Delete<BoolNullableMap>().Where(a => a.id == item.id && a.tostring == null).ExecuteAffrows());
 | 
					 | 
				
			||||||
            Assert.Null(orm.Select<BoolNullableMap>().Where(a => a.id == item.id).First());
 | 
					            Assert.Null(orm.Select<BoolNullableMap>().Where(a => a.id == item.id).First());
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -84,17 +84,9 @@ namespace FreeSql.Tests.DamengMapType
 | 
				
			|||||||
        {
 | 
					        {
 | 
				
			||||||
            //insert
 | 
					            //insert
 | 
				
			||||||
            var orm = g.dameng;
 | 
					            var orm = g.dameng;
 | 
				
			||||||
            var item = new EnumTestMap { };
 | 
					            var item = new EnumTestMap { enumnullable_to_string = ToStringMapEnum.<EFBFBD>й<EFBFBD><EFBFBD><EFBFBD> };
 | 
				
			||||||
            Assert.Equal(1, orm.Insert<EnumTestMap>().AppendData(item).ExecuteAffrows());
 | 
					            Assert.Equal(1, orm.Insert<EnumTestMap>().AppendData(item).ExecuteAffrows());
 | 
				
			||||||
            var find = orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enumnullable_to_string == null).First();
 | 
					            var find = orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enumnullable_to_string == ToStringMapEnum.<EFBFBD>й<EFBFBD><EFBFBD><EFBFBD>).First();
 | 
				
			||||||
            Assert.NotNull(find);
 | 
					 | 
				
			||||||
            Assert.Equal(item.id, find.id);
 | 
					 | 
				
			||||||
            Assert.Equal(item.enumnullable_to_string, find.enumnullable_to_string);
 | 
					 | 
				
			||||||
            Assert.Null(find.enumnullable_to_string);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            item = new EnumTestMap { enumnullable_to_string = ToStringMapEnum.<EFBFBD>й<EFBFBD><EFBFBD><EFBFBD> };
 | 
					 | 
				
			||||||
            Assert.Equal(1, orm.Insert<EnumTestMap>().AppendData(item).ExecuteAffrows());
 | 
					 | 
				
			||||||
            find = orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enumnullable_to_string == ToStringMapEnum.<EFBFBD>й<EFBFBD><EFBFBD><EFBFBD>).First();
 | 
					 | 
				
			||||||
            Assert.NotNull(find);
 | 
					            Assert.NotNull(find);
 | 
				
			||||||
            Assert.Equal(item.id, find.id);
 | 
					            Assert.Equal(item.id, find.id);
 | 
				
			||||||
            Assert.Equal(item.enumnullable_to_string, find.enumnullable_to_string);
 | 
					            Assert.Equal(item.enumnullable_to_string, find.enumnullable_to_string);
 | 
				
			||||||
@@ -109,15 +101,6 @@ namespace FreeSql.Tests.DamengMapType
 | 
				
			|||||||
            Assert.Equal(item.enumnullable_to_string, find.enumnullable_to_string);
 | 
					            Assert.Equal(item.enumnullable_to_string, find.enumnullable_to_string);
 | 
				
			||||||
            Assert.Equal(ToStringMapEnum.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>, find.enumnullable_to_string);
 | 
					            Assert.Equal(ToStringMapEnum.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>, find.enumnullable_to_string);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            item.enumnullable_to_string = null;
 | 
					 | 
				
			||||||
            Assert.Equal(1, orm.Update<EnumTestMap>().SetSource(item).ExecuteAffrows());
 | 
					 | 
				
			||||||
            Assert.Null(orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enumnullable_to_string == ToStringMapEnum.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>).First());
 | 
					 | 
				
			||||||
            find = orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enumnullable_to_string == null).First();
 | 
					 | 
				
			||||||
            Assert.NotNull(find);
 | 
					 | 
				
			||||||
            Assert.Equal(item.id, find.id);
 | 
					 | 
				
			||||||
            Assert.Equal(item.enumnullable_to_string, find.enumnullable_to_string);
 | 
					 | 
				
			||||||
            Assert.Null(find.enumnullable_to_string);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            //update set
 | 
					            //update set
 | 
				
			||||||
            Assert.Equal(1, orm.Update<EnumTestMap>().Where(a => a.id == item.id).Set(a => a.enumnullable_to_string, ToStringMapEnum.abc).ExecuteAffrows());
 | 
					            Assert.Equal(1, orm.Update<EnumTestMap>().Where(a => a.id == item.id).Set(a => a.enumnullable_to_string, ToStringMapEnum.abc).ExecuteAffrows());
 | 
				
			||||||
            find = orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enumnullable_to_string == ToStringMapEnum.abc).First();
 | 
					            find = orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enumnullable_to_string == ToStringMapEnum.abc).First();
 | 
				
			||||||
@@ -125,19 +108,10 @@ namespace FreeSql.Tests.DamengMapType
 | 
				
			|||||||
            Assert.Equal(item.id, find.id);
 | 
					            Assert.Equal(item.id, find.id);
 | 
				
			||||||
            Assert.Equal(ToStringMapEnum.abc, find.enumnullable_to_string);
 | 
					            Assert.Equal(ToStringMapEnum.abc, find.enumnullable_to_string);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
            Assert.Equal(1, orm.Update<EnumTestMap>().Where(a => a.id == item.id).Set(a => a.enumnullable_to_string, null).ExecuteAffrows());
 | 
					 | 
				
			||||||
            Assert.Null(orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enumnullable_to_string == ToStringMapEnum.abc).First());
 | 
					 | 
				
			||||||
            find = orm.Select<EnumTestMap>().Where(a => a.id == item.id && a.enumnullable_to_string == null).First();
 | 
					 | 
				
			||||||
            Assert.NotNull(find);
 | 
					 | 
				
			||||||
            Assert.Equal(item.id, find.id);
 | 
					 | 
				
			||||||
            Assert.Null(find.enumnullable_to_string);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            //delete
 | 
					            //delete
 | 
				
			||||||
            Assert.Equal(0, orm.Delete<EnumTestMap>().Where(a => a.id == item.id && a.enumnullable_to_string == ToStringMapEnum.<EFBFBD>й<EFBFBD><EFBFBD><EFBFBD>).ExecuteAffrows());
 | 
					            Assert.Equal(0, orm.Delete<EnumTestMap>().Where(a => a.id == item.id && a.enumnullable_to_string == ToStringMapEnum.<EFBFBD>й<EFBFBD><EFBFBD><EFBFBD>).ExecuteAffrows());
 | 
				
			||||||
            Assert.Equal(0, orm.Delete<EnumTestMap>().Where(a => a.id == item.id && a.enumnullable_to_string == ToStringMapEnum.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>).ExecuteAffrows());
 | 
					            Assert.Equal(0, orm.Delete<EnumTestMap>().Where(a => a.id == item.id && a.enumnullable_to_string == ToStringMapEnum.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>).ExecuteAffrows());
 | 
				
			||||||
            Assert.Equal(1, orm.Delete<EnumTestMap>().Where(a => a.id == item.id && a.enumnullable_to_string == null).ExecuteAffrows());
 | 
					            Assert.NotNull(orm.Select<EnumTestMap>().Where(a => a.id == item.id).First());
 | 
				
			||||||
            Assert.Null(orm.Select<EnumTestMap>().Where(a => a.id == item.id).First());
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        [Fact]
 | 
					        [Fact]
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -99,17 +99,9 @@ namespace FreeSql.Tests.DamengMapType
 | 
				
			|||||||
        {
 | 
					        {
 | 
				
			||||||
            //insert
 | 
					            //insert
 | 
				
			||||||
            var orm = g.dameng;
 | 
					            var orm = g.dameng;
 | 
				
			||||||
            var item = new ToStringMap { };
 | 
					            var item = new ToStringMap { enumnullable_to_string = ToStringMapEnum.<EFBFBD>й<EFBFBD><EFBFBD><EFBFBD> };
 | 
				
			||||||
            Assert.Equal(1, orm.Insert<ToStringMap>().AppendData(item).ExecuteAffrows());
 | 
					            Assert.Equal(1, orm.Insert<ToStringMap>().AppendData(item).ExecuteAffrows());
 | 
				
			||||||
            var find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.enumnullable_to_string == null).First();
 | 
					            var find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.enumnullable_to_string == ToStringMapEnum.<EFBFBD>й<EFBFBD><EFBFBD><EFBFBD>).First();
 | 
				
			||||||
            Assert.NotNull(find);
 | 
					 | 
				
			||||||
            Assert.Equal(item.id, find.id);
 | 
					 | 
				
			||||||
            Assert.Equal(item.enumnullable_to_string, find.enumnullable_to_string);
 | 
					 | 
				
			||||||
            Assert.Null(find.enumnullable_to_string);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            item = new ToStringMap { enumnullable_to_string = ToStringMapEnum.<EFBFBD>й<EFBFBD><EFBFBD><EFBFBD> };
 | 
					 | 
				
			||||||
            Assert.Equal(1, orm.Insert<ToStringMap>().AppendData(item).ExecuteAffrows());
 | 
					 | 
				
			||||||
            find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.enumnullable_to_string == ToStringMapEnum.<EFBFBD>й<EFBFBD><EFBFBD><EFBFBD>).First();
 | 
					 | 
				
			||||||
            Assert.NotNull(find);
 | 
					            Assert.NotNull(find);
 | 
				
			||||||
            Assert.Equal(item.id, find.id);
 | 
					            Assert.Equal(item.id, find.id);
 | 
				
			||||||
            Assert.Equal(item.enumnullable_to_string, find.enumnullable_to_string);
 | 
					            Assert.Equal(item.enumnullable_to_string, find.enumnullable_to_string);
 | 
				
			||||||
@@ -124,15 +116,6 @@ namespace FreeSql.Tests.DamengMapType
 | 
				
			|||||||
            Assert.Equal(item.enumnullable_to_string, find.enumnullable_to_string);
 | 
					            Assert.Equal(item.enumnullable_to_string, find.enumnullable_to_string);
 | 
				
			||||||
            Assert.Equal(ToStringMapEnum.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>, find.enumnullable_to_string);
 | 
					            Assert.Equal(ToStringMapEnum.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>, find.enumnullable_to_string);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            item.enumnullable_to_string = null;
 | 
					 | 
				
			||||||
            Assert.Equal(1, orm.Update<ToStringMap>().SetSource(item).ExecuteAffrows());
 | 
					 | 
				
			||||||
            Assert.Null(orm.Select<ToStringMap>().Where(a => a.id == item.id && a.enumnullable_to_string == ToStringMapEnum.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>).First());
 | 
					 | 
				
			||||||
            find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.enumnullable_to_string == null).First();
 | 
					 | 
				
			||||||
            Assert.NotNull(find);
 | 
					 | 
				
			||||||
            Assert.Equal(item.id, find.id);
 | 
					 | 
				
			||||||
            Assert.Equal(item.enumnullable_to_string, find.enumnullable_to_string);
 | 
					 | 
				
			||||||
            Assert.Null(find.enumnullable_to_string);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            //update set
 | 
					            //update set
 | 
				
			||||||
            Assert.Equal(1, orm.Update<ToStringMap>().Where(a => a.id == item.id).Set(a => a.enumnullable_to_string, ToStringMapEnum.abc).ExecuteAffrows());
 | 
					            Assert.Equal(1, orm.Update<ToStringMap>().Where(a => a.id == item.id).Set(a => a.enumnullable_to_string, ToStringMapEnum.abc).ExecuteAffrows());
 | 
				
			||||||
            find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.enumnullable_to_string == ToStringMapEnum.abc).First();
 | 
					            find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.enumnullable_to_string == ToStringMapEnum.abc).First();
 | 
				
			||||||
@@ -140,19 +123,10 @@ namespace FreeSql.Tests.DamengMapType
 | 
				
			|||||||
            Assert.Equal(item.id, find.id);
 | 
					            Assert.Equal(item.id, find.id);
 | 
				
			||||||
            Assert.Equal(ToStringMapEnum.abc, find.enumnullable_to_string);
 | 
					            Assert.Equal(ToStringMapEnum.abc, find.enumnullable_to_string);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
            Assert.Equal(1, orm.Update<ToStringMap>().Where(a => a.id == item.id).Set(a => a.enumnullable_to_string, null).ExecuteAffrows());
 | 
					 | 
				
			||||||
            Assert.Null(orm.Select<ToStringMap>().Where(a => a.id == item.id && a.enumnullable_to_string == ToStringMapEnum.abc).First());
 | 
					 | 
				
			||||||
            find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.enumnullable_to_string == null).First();
 | 
					 | 
				
			||||||
            Assert.NotNull(find);
 | 
					 | 
				
			||||||
            Assert.Equal(item.id, find.id);
 | 
					 | 
				
			||||||
            Assert.Null(find.enumnullable_to_string);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            //delete
 | 
					            //delete
 | 
				
			||||||
            Assert.Equal(0, orm.Delete<ToStringMap>().Where(a => a.id == item.id && a.enumnullable_to_string == ToStringMapEnum.<EFBFBD>й<EFBFBD><EFBFBD><EFBFBD>).ExecuteAffrows());
 | 
					            Assert.Equal(0, orm.Delete<ToStringMap>().Where(a => a.id == item.id && a.enumnullable_to_string == ToStringMapEnum.<EFBFBD>й<EFBFBD><EFBFBD><EFBFBD>).ExecuteAffrows());
 | 
				
			||||||
            Assert.Equal(0, orm.Delete<ToStringMap>().Where(a => a.id == item.id && a.enumnullable_to_string == ToStringMapEnum.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>).ExecuteAffrows());
 | 
					            Assert.Equal(0, orm.Delete<ToStringMap>().Where(a => a.id == item.id && a.enumnullable_to_string == ToStringMapEnum.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>).ExecuteAffrows());
 | 
				
			||||||
            Assert.Equal(1, orm.Delete<ToStringMap>().Where(a => a.id == item.id && a.enumnullable_to_string == null).ExecuteAffrows());
 | 
					            Assert.NotNull(orm.Select<ToStringMap>().Where(a => a.id == item.id).First());
 | 
				
			||||||
            Assert.Null(orm.Select<ToStringMap>().Where(a => a.id == item.id).First());
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        [Fact]
 | 
					        [Fact]
 | 
				
			||||||
        public void BigInteger1()
 | 
					        public void BigInteger1()
 | 
				
			||||||
@@ -216,17 +190,9 @@ namespace FreeSql.Tests.DamengMapType
 | 
				
			|||||||
        {
 | 
					        {
 | 
				
			||||||
            //insert
 | 
					            //insert
 | 
				
			||||||
            var orm = g.dameng;
 | 
					            var orm = g.dameng;
 | 
				
			||||||
            var item = new ToStringMap { };
 | 
					            var item = new ToStringMap { bigintegernullable_to_string = 101 };
 | 
				
			||||||
            Assert.Equal(1, orm.Insert<ToStringMap>().AppendData(item).ExecuteAffrows());
 | 
					            Assert.Equal(1, orm.Insert<ToStringMap>().AppendData(item).ExecuteAffrows());
 | 
				
			||||||
            var find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.bigintegernullable_to_string == null).First();
 | 
					            var find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.bigintegernullable_to_string == 101).First();
 | 
				
			||||||
            Assert.NotNull(find);
 | 
					 | 
				
			||||||
            Assert.Equal(item.id, find.id);
 | 
					 | 
				
			||||||
            Assert.Equal(item.bigintegernullable_to_string, find.bigintegernullable_to_string);
 | 
					 | 
				
			||||||
            Assert.Null(find.bigintegernullable_to_string);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            item = new ToStringMap { bigintegernullable_to_string = 101 };
 | 
					 | 
				
			||||||
            Assert.Equal(1, orm.Insert<ToStringMap>().AppendData(item).ExecuteAffrows());
 | 
					 | 
				
			||||||
            find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.bigintegernullable_to_string == 101).First();
 | 
					 | 
				
			||||||
            Assert.NotNull(find);
 | 
					            Assert.NotNull(find);
 | 
				
			||||||
            Assert.Equal(item.id, find.id);
 | 
					            Assert.Equal(item.id, find.id);
 | 
				
			||||||
            Assert.Equal(item.bigintegernullable_to_string, find.bigintegernullable_to_string);
 | 
					            Assert.Equal(item.bigintegernullable_to_string, find.bigintegernullable_to_string);
 | 
				
			||||||
@@ -241,15 +207,6 @@ namespace FreeSql.Tests.DamengMapType
 | 
				
			|||||||
            Assert.Equal(item.bigintegernullable_to_string, find.bigintegernullable_to_string);
 | 
					            Assert.Equal(item.bigintegernullable_to_string, find.bigintegernullable_to_string);
 | 
				
			||||||
            Assert.Equal(2004, find.bigintegernullable_to_string);
 | 
					            Assert.Equal(2004, find.bigintegernullable_to_string);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            item.bigintegernullable_to_string = null;
 | 
					 | 
				
			||||||
            Assert.Equal(1, orm.Update<ToStringMap>().SetSource(item).ExecuteAffrows());
 | 
					 | 
				
			||||||
            Assert.Null(orm.Select<ToStringMap>().Where(a => a.id == item.id && a.bigintegernullable_to_string == 2004).First());
 | 
					 | 
				
			||||||
            find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.bigintegernullable_to_string == null).First();
 | 
					 | 
				
			||||||
            Assert.NotNull(find);
 | 
					 | 
				
			||||||
            Assert.Equal(item.id, find.id);
 | 
					 | 
				
			||||||
            Assert.Equal(item.bigintegernullable_to_string, find.bigintegernullable_to_string);
 | 
					 | 
				
			||||||
            Assert.Null(find.bigintegernullable_to_string);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            //update set
 | 
					            //update set
 | 
				
			||||||
            Assert.Equal(1, orm.Update<ToStringMap>().Where(a => a.id == item.id).Set(a => a.bigintegernullable_to_string, 998).ExecuteAffrows());
 | 
					            Assert.Equal(1, orm.Update<ToStringMap>().Where(a => a.id == item.id).Set(a => a.bigintegernullable_to_string, 998).ExecuteAffrows());
 | 
				
			||||||
            find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.bigintegernullable_to_string == 998).First();
 | 
					            find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.bigintegernullable_to_string == 998).First();
 | 
				
			||||||
@@ -257,18 +214,9 @@ namespace FreeSql.Tests.DamengMapType
 | 
				
			|||||||
            Assert.Equal(item.id, find.id);
 | 
					            Assert.Equal(item.id, find.id);
 | 
				
			||||||
            Assert.Equal(998, find.bigintegernullable_to_string);
 | 
					            Assert.Equal(998, find.bigintegernullable_to_string);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
            Assert.Equal(1, orm.Update<ToStringMap>().Where(a => a.id == item.id).Set(a => a.bigintegernullable_to_string, null).ExecuteAffrows());
 | 
					 | 
				
			||||||
            Assert.Null(orm.Select<ToStringMap>().Where(a => a.id == item.id && a.bigintegernullable_to_string == 998).First());
 | 
					 | 
				
			||||||
            find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.bigintegernullable_to_string == null).First();
 | 
					 | 
				
			||||||
            Assert.NotNull(find);
 | 
					 | 
				
			||||||
            Assert.Equal(item.id, find.id);
 | 
					 | 
				
			||||||
            Assert.Null(find.bigintegernullable_to_string);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            //delete
 | 
					            //delete
 | 
				
			||||||
            Assert.Equal(0, orm.Delete<ToStringMap>().Where(a => a.id == item.id && a.bigintegernullable_to_string == 998).ExecuteAffrows());
 | 
					            Assert.Equal(1, orm.Delete<ToStringMap>().Where(a => a.id == item.id && a.bigintegernullable_to_string == 998).ExecuteAffrows());
 | 
				
			||||||
            Assert.Equal(0, orm.Delete<ToStringMap>().Where(a => a.id == item.id && a.bigintegernullable_to_string == 2004).ExecuteAffrows());
 | 
					            Assert.Equal(0, orm.Delete<ToStringMap>().Where(a => a.id == item.id && a.bigintegernullable_to_string == 2004).ExecuteAffrows());
 | 
				
			||||||
            Assert.Equal(1, orm.Delete<ToStringMap>().Where(a => a.id == item.id && a.bigintegernullable_to_string == null).ExecuteAffrows());
 | 
					 | 
				
			||||||
            Assert.Null(orm.Select<ToStringMap>().Where(a => a.id == item.id).First());
 | 
					            Assert.Null(orm.Select<ToStringMap>().Where(a => a.id == item.id).First());
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        [Fact]
 | 
					        [Fact]
 | 
				
			||||||
@@ -513,18 +461,10 @@ namespace FreeSql.Tests.DamengMapType
 | 
				
			|||||||
        {
 | 
					        {
 | 
				
			||||||
            //insert
 | 
					            //insert
 | 
				
			||||||
            var orm = g.dameng;
 | 
					            var orm = g.dameng;
 | 
				
			||||||
            var item = new ToStringMap { };
 | 
					 | 
				
			||||||
            Assert.Equal(1, orm.Insert<ToStringMap>().AppendData(item).ExecuteAffrows());
 | 
					 | 
				
			||||||
            var find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.guidnullable_to_string == null).First();
 | 
					 | 
				
			||||||
            Assert.NotNull(find);
 | 
					 | 
				
			||||||
            Assert.Equal(item.id, find.id);
 | 
					 | 
				
			||||||
            Assert.Equal(item.guidnullable_to_string, find.guidnullable_to_string);
 | 
					 | 
				
			||||||
            Assert.Null(find.guidnullable_to_string);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            var newid = Guid.NewGuid();
 | 
					            var newid = Guid.NewGuid();
 | 
				
			||||||
            item = new ToStringMap { guidnullable_to_string = newid };
 | 
					            var item = new ToStringMap { guidnullable_to_string = newid };
 | 
				
			||||||
            Assert.Equal(1, orm.Insert<ToStringMap>().AppendData(item).ExecuteAffrows());
 | 
					            Assert.Equal(1, orm.Insert<ToStringMap>().AppendData(item).ExecuteAffrows());
 | 
				
			||||||
            find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.guidnullable_to_string == newid).First();
 | 
					            var find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.guidnullable_to_string == newid).First();
 | 
				
			||||||
            Assert.NotNull(find);
 | 
					            Assert.NotNull(find);
 | 
				
			||||||
            Assert.Equal(item.id, find.id);
 | 
					            Assert.Equal(item.id, find.id);
 | 
				
			||||||
            Assert.Equal(item.guidnullable_to_string, find.guidnullable_to_string);
 | 
					            Assert.Equal(item.guidnullable_to_string, find.guidnullable_to_string);
 | 
				
			||||||
@@ -540,14 +480,6 @@ namespace FreeSql.Tests.DamengMapType
 | 
				
			|||||||
            Assert.Equal(item.guidnullable_to_string, find.guidnullable_to_string);
 | 
					            Assert.Equal(item.guidnullable_to_string, find.guidnullable_to_string);
 | 
				
			||||||
            Assert.Equal(newid, find.guidnullable_to_string);
 | 
					            Assert.Equal(newid, find.guidnullable_to_string);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            item.guidnullable_to_string = null;
 | 
					 | 
				
			||||||
            Assert.Equal(1, orm.Update<ToStringMap>().SetSource(item).ExecuteAffrows());
 | 
					 | 
				
			||||||
            find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.guidnullable_to_string == null).First();
 | 
					 | 
				
			||||||
            Assert.NotNull(find);
 | 
					 | 
				
			||||||
            Assert.Equal(item.id, find.id);
 | 
					 | 
				
			||||||
            Assert.Equal(item.guidnullable_to_string, find.guidnullable_to_string);
 | 
					 | 
				
			||||||
            Assert.Null(find.guidnullable_to_string);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            //update set
 | 
					            //update set
 | 
				
			||||||
            newid = Guid.NewGuid();
 | 
					            newid = Guid.NewGuid();
 | 
				
			||||||
            Assert.Equal(1, orm.Update<ToStringMap>().Where(a => a.id == item.id).Set(a => a.guidnullable_to_string, newid).ExecuteAffrows());
 | 
					            Assert.Equal(1, orm.Update<ToStringMap>().Where(a => a.id == item.id).Set(a => a.guidnullable_to_string, newid).ExecuteAffrows());
 | 
				
			||||||
@@ -556,14 +488,8 @@ namespace FreeSql.Tests.DamengMapType
 | 
				
			|||||||
            Assert.Equal(item.id, find.id);
 | 
					            Assert.Equal(item.id, find.id);
 | 
				
			||||||
            Assert.Equal(newid, find.guidnullable_to_string);
 | 
					            Assert.Equal(newid, find.guidnullable_to_string);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            Assert.Equal(1, orm.Update<ToStringMap>().Where(a => a.id == item.id).Set(a => a.guidnullable_to_string, null).ExecuteAffrows());
 | 
					 | 
				
			||||||
            find = orm.Select<ToStringMap>().Where(a => a.id == item.id && a.guidnullable_to_string == null).First();
 | 
					 | 
				
			||||||
            Assert.NotNull(find);
 | 
					 | 
				
			||||||
            Assert.Equal(item.id, find.id);
 | 
					 | 
				
			||||||
            Assert.Null(find.guidnullable_to_string);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            //delete
 | 
					            //delete
 | 
				
			||||||
            Assert.Equal(1, orm.Delete<ToStringMap>().Where(a => a.id == item.id && a.guidnullable_to_string == null).ExecuteAffrows());
 | 
					            Assert.Equal(1, orm.Delete<ToStringMap>().Where(a => a.id == item.id).ExecuteAffrows());
 | 
				
			||||||
            Assert.Null(orm.Select<ToStringMap>().Where(a => a.id == item.id).First());
 | 
					            Assert.Null(orm.Select<ToStringMap>().Where(a => a.id == item.id).First());
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -10,6 +10,94 @@ namespace FreeSql.Tests.MySql
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    public class MySqlCodeFirstTest
 | 
					    public class MySqlCodeFirstTest
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					        [Fact]
 | 
				
			||||||
 | 
					        public void Text_StringLength_1()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            var str1 = string.Join(",", Enumerable.Range(0, 1000).Select(a => "<22><><EFBFBD><EFBFBD><EFBFBD>й<EFBFBD><D0B9><EFBFBD>"));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            var item1 = new TS_TEXT02 { Data = str1 };
 | 
				
			||||||
 | 
					            Assert.Equal(1, g.mysql.Insert(item1).ExecuteAffrows());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            var item2 = g.mysql.Select<TS_TEXT02>().Where(a => a.Id == item1.Id).First();
 | 
				
			||||||
 | 
					            Assert.Equal(str1, item2.Data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            //NoneParameter
 | 
				
			||||||
 | 
					            item1 = new TS_TEXT02 { Data = str1 };
 | 
				
			||||||
 | 
					            Assert.Equal(1, g.mysql.Insert(item1).NoneParameter().ExecuteAffrows());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        class TS_TEXT02
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            public Guid Id { get; set; }
 | 
				
			||||||
 | 
					            [Column(StringLength = -1)]
 | 
				
			||||||
 | 
					            public string Data { get; set; }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [Fact]
 | 
				
			||||||
 | 
					        public void Text()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            var str1 = string.Join(",", Enumerable.Range(0, 1000).Select(a => "<22><><EFBFBD><EFBFBD><EFBFBD>й<EFBFBD><D0B9><EFBFBD>"));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            var item1 = new TS_TEXT01 { Data = str1 };
 | 
				
			||||||
 | 
					            Assert.Equal(1, g.mysql.Insert(item1).ExecuteAffrows());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            var item2 = g.mysql.Select<TS_TEXT01>().Where(a => a.Id == item1.Id).First();
 | 
				
			||||||
 | 
					            Assert.Equal(str1, item2.Data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            //NoneParameter
 | 
				
			||||||
 | 
					            item1 = new TS_TEXT01 { Data = str1 };
 | 
				
			||||||
 | 
					            Assert.Equal(1, g.mysql.Insert(item1).NoneParameter().ExecuteAffrows());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        class TS_TEXT01
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            public Guid Id { get; set; }
 | 
				
			||||||
 | 
					            [Column(DbType = "text")]
 | 
				
			||||||
 | 
					            public string Data { get; set; }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [Fact]
 | 
				
			||||||
 | 
					        public void Text_StringLength_2()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            var str1 = string.Join(",", Enumerable.Range(0, 10000).Select(a => "<22><><EFBFBD><EFBFBD><EFBFBD>й<EFBFBD><D0B9><EFBFBD>"));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            var item1 = new TS_TEXT04 { Data = str1 };
 | 
				
			||||||
 | 
					            Assert.Equal(1, g.mysql.Insert(item1).ExecuteAffrows());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            var item2 = g.mysql.Select<TS_TEXT04>().Where(a => a.Id == item1.Id).First();
 | 
				
			||||||
 | 
					            Assert.Equal(str1, item2.Data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            //NoneParameter
 | 
				
			||||||
 | 
					            item1 = new TS_TEXT04 { Data = str1 };
 | 
				
			||||||
 | 
					            Assert.Equal(1, g.mysql.Insert(item1).NoneParameter().ExecuteAffrows());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        class TS_TEXT04
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            public Guid Id { get; set; }
 | 
				
			||||||
 | 
					            [Column(StringLength = -2)]
 | 
				
			||||||
 | 
					            public string Data { get; set; }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [Fact]
 | 
				
			||||||
 | 
					        public void LongText()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            var str1 = string.Join(",", Enumerable.Range(0, 10000).Select(a => "<22><><EFBFBD><EFBFBD><EFBFBD>й<EFBFBD><D0B9><EFBFBD>"));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            var item1 = new TS_TEXT03 { Data = str1 };
 | 
				
			||||||
 | 
					            Assert.Equal(1, g.mysql.Insert(item1).ExecuteAffrows());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            var item2 = g.mysql.Select<TS_TEXT03>().Where(a => a.Id == item1.Id).First();
 | 
				
			||||||
 | 
					            Assert.Equal(str1, item2.Data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            //NoneParameter
 | 
				
			||||||
 | 
					            item1 = new TS_TEXT03 { Data = str1 };
 | 
				
			||||||
 | 
					            Assert.Equal(1, g.mysql.Insert(item1).NoneParameter().ExecuteAffrows());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        class TS_TEXT03
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            public Guid Id { get; set; }
 | 
				
			||||||
 | 
					            [Column(DbType = "longtext")]
 | 
				
			||||||
 | 
					            public string Data { get; set; }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        [Fact]
 | 
					        [Fact]
 | 
				
			||||||
        public void StringLength()
 | 
					        public void StringLength()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -89,11 +89,11 @@ namespace FreeSql.DataAnnotations
 | 
				
			|||||||
        /// Oracle -> nvarchar2(100)<para></para>
 | 
					        /// Oracle -> nvarchar2(100)<para></para>
 | 
				
			||||||
        /// Sqlite -> nvarchar(100)<para></para>
 | 
					        /// Sqlite -> nvarchar(100)<para></para>
 | 
				
			||||||
        /// ---<para></para>
 | 
					        /// ---<para></para>
 | 
				
			||||||
        /// StringLength = -1 时,对应 DbType:<para></para>
 | 
					        /// StringLength < 0 时,对应 DbType:<para></para>
 | 
				
			||||||
        /// MySql -> text<para></para>
 | 
					        /// MySql -> text (StringLength = -2 时,对应 DbType longtext)<para></para>
 | 
				
			||||||
        /// SqlServer -> nvarchar(max)<para></para>
 | 
					        /// SqlServer -> nvarchar(max)<para></para>
 | 
				
			||||||
        /// PostgreSQL -> text<para></para>
 | 
					        /// PostgreSQL -> text<para></para>
 | 
				
			||||||
        /// Oracle -> nvarchar2(4000)<para></para>
 | 
					        /// Oracle -> nclob<para></para>
 | 
				
			||||||
        /// Sqlite -> text<para></para>
 | 
					        /// Sqlite -> text<para></para>
 | 
				
			||||||
        /// </summary>
 | 
					        /// </summary>
 | 
				
			||||||
        public int StringLength { get => _StringLength ?? 0; set => _StringLength = value; }
 | 
					        public int StringLength { get => _StringLength ?? 0; set => _StringLength = value; }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -90,11 +90,11 @@
 | 
				
			|||||||
            Oracle -> nvarchar2(100)<para></para>
 | 
					            Oracle -> nvarchar2(100)<para></para>
 | 
				
			||||||
            Sqlite -> nvarchar(100)<para></para>
 | 
					            Sqlite -> nvarchar(100)<para></para>
 | 
				
			||||||
            ---<para></para>
 | 
					            ---<para></para>
 | 
				
			||||||
            StringLength = -1 时,对应 DbType:<para></para>
 | 
					            StringLength < 0 时,对应 DbType:<para></para>
 | 
				
			||||||
            MySql -> text<para></para>
 | 
					            MySql -> text (StringLength = -2 时,对应 DbType longtext)<para></para>
 | 
				
			||||||
            SqlServer -> nvarchar(max)<para></para>
 | 
					            SqlServer -> nvarchar(max)<para></para>
 | 
				
			||||||
            PostgreSQL -> text<para></para>
 | 
					            PostgreSQL -> text<para></para>
 | 
				
			||||||
            Oracle -> nvarchar2(4000)<para></para>
 | 
					            Oracle -> nclob<para></para>
 | 
				
			||||||
            Sqlite -> text<para></para>
 | 
					            Sqlite -> text<para></para>
 | 
				
			||||||
            </summary>
 | 
					            </summary>
 | 
				
			||||||
        </member>
 | 
					        </member>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1218,12 +1218,12 @@ namespace FreeSql.Internal.CommonProvider
 | 
				
			|||||||
                    break;
 | 
					                    break;
 | 
				
			||||||
                case DataType.Oracle:
 | 
					                case DataType.Oracle:
 | 
				
			||||||
                case DataType.OdbcOracle:
 | 
					                case DataType.OdbcOracle:
 | 
				
			||||||
 | 
					                case DataType.Dameng:
 | 
				
			||||||
 | 
					                case DataType.OdbcDameng:
 | 
				
			||||||
                    _tosqlAppendContent = $" for update{(noawait ? " nowait" : "")}";
 | 
					                    _tosqlAppendContent = $" for update{(noawait ? " nowait" : "")}";
 | 
				
			||||||
                    break;
 | 
					                    break;
 | 
				
			||||||
                case DataType.Sqlite:
 | 
					                case DataType.Sqlite:
 | 
				
			||||||
                    break;
 | 
					                    break;
 | 
				
			||||||
                case DataType.OdbcDameng:
 | 
					 | 
				
			||||||
                case DataType.Dameng:
 | 
					 | 
				
			||||||
                case DataType.OdbcKingbaseES:
 | 
					                case DataType.OdbcKingbaseES:
 | 
				
			||||||
                    _tosqlAppendContent = $" for update{(noawait ? " nowait" : "")}";
 | 
					                    _tosqlAppendContent = $" for update{(noawait ? " nowait" : "")}";
 | 
				
			||||||
                    break;
 | 
					                    break;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -232,7 +232,8 @@ namespace FreeSql.Internal
 | 
				
			|||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        case DataType.MySql:
 | 
					                        case DataType.MySql:
 | 
				
			||||||
                        case DataType.OdbcMySql:
 | 
					                        case DataType.OdbcMySql:
 | 
				
			||||||
                            if (strlen < 0) colattr.DbType = "TEXT";
 | 
					                            if (strlen == -2) colattr.DbType = "LONGTEXT";
 | 
				
			||||||
 | 
					                            else if (strlen < 0) colattr.DbType = "TEXT";
 | 
				
			||||||
                            else colattr.DbType = Regex.Replace(colattr.DbType, charPatten, $"$1({strlen})");
 | 
					                            else colattr.DbType = Regex.Replace(colattr.DbType, charPatten, $"$1({strlen})");
 | 
				
			||||||
                            break;
 | 
					                            break;
 | 
				
			||||||
                        case DataType.SqlServer:
 | 
					                        case DataType.SqlServer:
 | 
				
			||||||
@@ -250,9 +251,13 @@ namespace FreeSql.Internal
 | 
				
			|||||||
                            if (strlen < 0) colattr.DbType = "NCLOB"; //v1.3.2+ https://github.com/dotnetcore/FreeSql/issues/259
 | 
					                            if (strlen < 0) colattr.DbType = "NCLOB"; //v1.3.2+ https://github.com/dotnetcore/FreeSql/issues/259
 | 
				
			||||||
                            else colattr.DbType = Regex.Replace(colattr.DbType, charPatten, $"$1({strlen})");
 | 
					                            else colattr.DbType = Regex.Replace(colattr.DbType, charPatten, $"$1({strlen})");
 | 
				
			||||||
                            break;
 | 
					                            break;
 | 
				
			||||||
 | 
					                        case DataType.Dameng:
 | 
				
			||||||
 | 
					                            if (strlen < 0) colattr.DbType = "TEXT";
 | 
				
			||||||
 | 
					                            else colattr.DbType = Regex.Replace(colattr.DbType, charPatten, $"$1({strlen})");
 | 
				
			||||||
 | 
					                            break;
 | 
				
			||||||
                        case DataType.OdbcOracle:
 | 
					                        case DataType.OdbcOracle:
 | 
				
			||||||
                        case DataType.OdbcDameng:
 | 
					                        case DataType.OdbcDameng:
 | 
				
			||||||
                            if (strlen < 0) colattr.DbType = Regex.Replace(colattr.DbType, charPatten, $"$1(4000)");
 | 
					                            if (strlen < 0) colattr.DbType = Regex.Replace(colattr.DbType, charPatten, $"$1(4000)"); //ODBC 不支持 NCLOB
 | 
				
			||||||
                            else colattr.DbType = Regex.Replace(colattr.DbType, charPatten, $"$1({strlen})");
 | 
					                            else colattr.DbType = Regex.Replace(colattr.DbType, charPatten, $"$1({strlen})");
 | 
				
			||||||
                            break;
 | 
					                            break;
 | 
				
			||||||
                        case DataType.Sqlite:
 | 
					                        case DataType.Sqlite:
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -15,7 +15,6 @@ namespace FreeSql.Dameng
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    class DamengCodeFirst : Internal.CommonProvider.CodeFirstProvider
 | 
					    class DamengCodeFirst : Internal.CommonProvider.CodeFirstProvider
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        public override bool IsNoneCommandParameter { get => true; set => base.IsNoneCommandParameter = true; }
 | 
					 | 
				
			||||||
        public DamengCodeFirst(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression) : base(orm, commonUtils, commonExpression) { }
 | 
					        public DamengCodeFirst(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression) : base(orm, commonUtils, commonExpression) { }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        static object _dicCsToDbLock = new object();
 | 
					        static object _dicCsToDbLock = new object();
 | 
				
			||||||
@@ -310,8 +309,9 @@ and not exists(select 1 from all_constraints where index_name = a.index_name and
 | 
				
			|||||||
                    continue;
 | 
					                    continue;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                var oldpk = _orm.Ado.ExecuteScalar(CommandType.Text, _commonUtils.FormatSql(@" select constraint_name from user_constraints where owner={0} and table_name={1} and constraint_type='P'", tbname))?.ToString();
 | 
					                var oldpk = _orm.Ado.ExecuteScalar(CommandType.Text, _commonUtils.FormatSql(@" select constraint_name from user_constraints where owner={0} and table_name={1} and constraint_type='P'", tbname))?.ToString();
 | 
				
			||||||
                if (string.IsNullOrEmpty(oldpk) == false)
 | 
					                //if (string.IsNullOrEmpty(oldpk) == false)
 | 
				
			||||||
                    sb.Append("execute immediate 'ALTER TABLE ").Append(_commonUtils.QuoteSqlName($"{tbname[0]}.{tbname[1]}")).Append(" DROP CONSTRAINT ").Append(oldpk).Append("';\r\n");
 | 
					                //    sb.Append("execute immediate 'ALTER TABLE ").Append(_commonUtils.QuoteSqlName($"{tbname[0]}.{tbname[1]}")).Append(" DROP CONSTRAINT ").Append(_commonUtils.QuoteSqlName(oldpk)).Append("';\r\n");
 | 
				
			||||||
 | 
					                //执行失败(语句1) 试图删除聚集主键
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                //创建临时表,数据导进临时表,然后删除原表,将临时表改名为原表名
 | 
					                //创建临时表,数据导进临时表,然后删除原表,将临时表改名为原表名
 | 
				
			||||||
                var tablename = tboldname == null ? _commonUtils.QuoteSqlName($"{tbname[0]}.{tbname[1]}") : _commonUtils.QuoteSqlName($"{tboldname[0]}.{tboldname[1]}");
 | 
					                var tablename = tboldname == null ? _commonUtils.QuoteSqlName($"{tbname[0]}.{tbname[1]}") : _commonUtils.QuoteSqlName($"{tboldname[0]}.{tboldname[1]}");
 | 
				
			||||||
@@ -325,7 +325,8 @@ and not exists(select 1 from all_constraints where index_name = a.index_name and
 | 
				
			|||||||
                }
 | 
					                }
 | 
				
			||||||
                if (tb.Primarys.Any())
 | 
					                if (tb.Primarys.Any())
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    var pkname = primaryKeyName ?? $"{tbname[0]}_{tbname[1]}_pk2";
 | 
					                    var pkname = primaryKeyName ?? $"{tbname[0]}_{tbname[1]}_pk1";
 | 
				
			||||||
 | 
					                    if (string.IsNullOrEmpty(oldpk) == false && oldpk == pkname) pkname = $"{pkname}1";
 | 
				
			||||||
                    sb.Append(" \r\n  CONSTRAINT ").Append(_commonUtils.QuoteSqlName(pkname)).Append(" PRIMARY KEY (");
 | 
					                    sb.Append(" \r\n  CONSTRAINT ").Append(_commonUtils.QuoteSqlName(pkname)).Append(" PRIMARY KEY (");
 | 
				
			||||||
                    foreach (var tbcol in tb.Primarys) sb.Append(_commonUtils.QuoteSqlName(tbcol.Attribute.Name)).Append(", ");
 | 
					                    foreach (var tbcol in tb.Primarys) sb.Append(_commonUtils.QuoteSqlName(tbcol.Attribute.Name)).Append(", ");
 | 
				
			||||||
                    sb.Remove(sb.Length - 2, 2).Append("),");
 | 
					                    sb.Remove(sb.Length - 2, 2).Append("),");
 | 
				
			||||||
@@ -457,6 +458,15 @@ and not exists(select 1 from all_constraints where index_name = a.index_name and
 | 
				
			|||||||
            else if (sqlType.StartsWith("BLOB"))
 | 
					            else if (sqlType.StartsWith("BLOB"))
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					            else if (sqlType.StartsWith("CLOB"))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else if (sqlType.StartsWith("NCLOB"))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else if (sqlType.StartsWith("TEXT"))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
            else if (sqlType == "REAL" || sqlType == "DOUBLE" || sqlType == "FLOAT")
 | 
					            else if (sqlType == "REAL" || sqlType == "DOUBLE" || sqlType == "FLOAT")
 | 
				
			||||||
            { 
 | 
					            { 
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -310,8 +310,9 @@ and not exists(select 1 from all_constraints where index_name = a.index_name and
 | 
				
			|||||||
                    continue;
 | 
					                    continue;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                var oldpk = _orm.Ado.ExecuteScalar(CommandType.Text, _commonUtils.FormatSql(@" select constraint_name from user_constraints where owner={0} and table_name={1} and constraint_type='P'", tbname))?.ToString();
 | 
					                var oldpk = _orm.Ado.ExecuteScalar(CommandType.Text, _commonUtils.FormatSql(@" select constraint_name from user_constraints where owner={0} and table_name={1} and constraint_type='P'", tbname))?.ToString();
 | 
				
			||||||
                if (string.IsNullOrEmpty(oldpk) == false)
 | 
					                //if (string.IsNullOrEmpty(oldpk) == false)
 | 
				
			||||||
                    sb.Append("execute immediate 'ALTER TABLE ").Append(_commonUtils.QuoteSqlName($"{tbname[0]}.{tbname[1]}")).Append(" DROP CONSTRAINT ").Append(oldpk).Append("';\r\n");
 | 
					                //    sb.Append("execute immediate 'ALTER TABLE ").Append(_commonUtils.QuoteSqlName($"{tbname[0]}.{tbname[1]}")).Append(" DROP CONSTRAINT ").Append(_commonUtils.QuoteSqlName(oldpk)).Append("';\r\n");
 | 
				
			||||||
 | 
					                //执行失败(语句1) 试图删除聚集主键
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                //创建临时表,数据导进临时表,然后删除原表,将临时表改名为原表名
 | 
					                //创建临时表,数据导进临时表,然后删除原表,将临时表改名为原表名
 | 
				
			||||||
                var tablename = tboldname == null ? _commonUtils.QuoteSqlName($"{tbname[0]}.{tbname[1]}") : _commonUtils.QuoteSqlName($"{tboldname[0]}.{tboldname[1]}");
 | 
					                var tablename = tboldname == null ? _commonUtils.QuoteSqlName($"{tbname[0]}.{tbname[1]}") : _commonUtils.QuoteSqlName($"{tboldname[0]}.{tboldname[1]}");
 | 
				
			||||||
@@ -325,7 +326,8 @@ and not exists(select 1 from all_constraints where index_name = a.index_name and
 | 
				
			|||||||
                }
 | 
					                }
 | 
				
			||||||
                if (tb.Primarys.Any())
 | 
					                if (tb.Primarys.Any())
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    var pkname = primaryKeyName ?? $"{tbname[0]}_{tbname[1]}_pk2";
 | 
					                    var pkname = primaryKeyName ?? $"{tbname[0]}_{tbname[1]}_pk1";
 | 
				
			||||||
 | 
					                    if (string.IsNullOrEmpty(oldpk) == false && oldpk == pkname) pkname = $"{pkname}1";
 | 
				
			||||||
                    sb.Append(" \r\n  CONSTRAINT ").Append(_commonUtils.QuoteSqlName(pkname)).Append(" PRIMARY KEY (");
 | 
					                    sb.Append(" \r\n  CONSTRAINT ").Append(_commonUtils.QuoteSqlName(pkname)).Append(" PRIMARY KEY (");
 | 
				
			||||||
                    foreach (var tbcol in tb.Primarys) sb.Append(_commonUtils.QuoteSqlName(tbcol.Attribute.Name)).Append(", ");
 | 
					                    foreach (var tbcol in tb.Primarys) sb.Append(_commonUtils.QuoteSqlName(tbcol.Attribute.Name)).Append(", ");
 | 
				
			||||||
                    sb.Remove(sb.Length - 2, 2).Append("),");
 | 
					                    sb.Remove(sb.Length - 2, 2).Append("),");
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -309,7 +309,7 @@ and not exists(select 1 from all_constraints where constraint_name = a.index_nam
 | 
				
			|||||||
                }
 | 
					                }
 | 
				
			||||||
                var oldpk = _orm.Ado.ExecuteScalar(CommandType.Text, _commonUtils.FormatSql(@" select constraint_name from user_constraints where owner={0} and table_name={1} and constraint_type='P'", tbname))?.ToString();
 | 
					                var oldpk = _orm.Ado.ExecuteScalar(CommandType.Text, _commonUtils.FormatSql(@" select constraint_name from user_constraints where owner={0} and table_name={1} and constraint_type='P'", tbname))?.ToString();
 | 
				
			||||||
                if (string.IsNullOrEmpty(oldpk) == false)
 | 
					                if (string.IsNullOrEmpty(oldpk) == false)
 | 
				
			||||||
                    sb.Append("execute immediate 'ALTER TABLE ").Append(_commonUtils.QuoteSqlName($"{tbname[0]}.{tbname[1]}")).Append(" DROP CONSTRAINT ").Append(oldpk).Append("';\r\n");
 | 
					                    sb.Append("execute immediate 'ALTER TABLE ").Append(_commonUtils.QuoteSqlName($"{tbname[0]}.{tbname[1]}")).Append(" DROP CONSTRAINT ").Append(_commonUtils.QuoteSqlName(oldpk)).Append("';\r\n");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                //创建临时表,数据导进临时表,然后删除原表,将临时表改名为原表名
 | 
					                //创建临时表,数据导进临时表,然后删除原表,将临时表改名为原表名
 | 
				
			||||||
                var tablename = tboldname == null ? _commonUtils.QuoteSqlName($"{tbname[0]}.{tbname[1]}") : _commonUtils.QuoteSqlName($"{tboldname[0]}.{tboldname[1]}");
 | 
					                var tablename = tboldname == null ? _commonUtils.QuoteSqlName($"{tbname[0]}.{tbname[1]}") : _commonUtils.QuoteSqlName($"{tboldname[0]}.{tboldname[1]}");
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -310,7 +310,7 @@ and not exists(select 1 from all_constraints where constraint_name = a.index_nam
 | 
				
			|||||||
                }
 | 
					                }
 | 
				
			||||||
                var oldpk = _orm.Ado.ExecuteScalar(CommandType.Text, _commonUtils.FormatSql(@" select constraint_name from user_constraints where owner={0} and table_name={1} and constraint_type='P'", tbname))?.ToString();
 | 
					                var oldpk = _orm.Ado.ExecuteScalar(CommandType.Text, _commonUtils.FormatSql(@" select constraint_name from user_constraints where owner={0} and table_name={1} and constraint_type='P'", tbname))?.ToString();
 | 
				
			||||||
                if (string.IsNullOrEmpty(oldpk) == false)
 | 
					                if (string.IsNullOrEmpty(oldpk) == false)
 | 
				
			||||||
                    sb.Append("execute immediate 'ALTER TABLE ").Append(_commonUtils.QuoteSqlName($"{tbname[0]}.{tbname[1]}")).Append(" DROP CONSTRAINT ").Append(oldpk).Append("';\r\n");
 | 
					                    sb.Append("execute immediate 'ALTER TABLE ").Append(_commonUtils.QuoteSqlName($"{tbname[0]}.{tbname[1]}")).Append(" DROP CONSTRAINT ").Append(_commonUtils.QuoteSqlName(oldpk)).Append("';\r\n");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                //创建临时表,数据导进临时表,然后删除原表,将临时表改名为原表名
 | 
					                //创建临时表,数据导进临时表,然后删除原表,将临时表改名为原表名
 | 
				
			||||||
                var tablename = tboldname == null ? _commonUtils.QuoteSqlName($"{tbname[0]}.{tbname[1]}") : _commonUtils.QuoteSqlName($"{tboldname[0]}.{tboldname[1]}");
 | 
					                var tablename = tboldname == null ? _commonUtils.QuoteSqlName($"{tbname[0]}.{tbname[1]}") : _commonUtils.QuoteSqlName($"{tboldname[0]}.{tboldname[1]}");
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user