mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-17 19:43:21 +08:00
- 测试 KingbaseES 数组等特殊类型;
This commit is contained in:
parent
d33109c3b1
commit
5b2ff93ecd
@ -1,8 +1,14 @@
|
||||
using FreeSql.DataAnnotations;
|
||||
using FreeSql.DataAnnotations;
|
||||
using KdbndpTypes;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Text;
|
||||
using Xunit;
|
||||
|
||||
@ -10,12 +16,33 @@ namespace FreeSql.Tests.KingbaseES
|
||||
{
|
||||
public class KingbaseESCodeFirstTest
|
||||
{
|
||||
|
||||
[Fact]
|
||||
public void Test_0String()
|
||||
{
|
||||
var fsql = g.kingbaseES;
|
||||
fsql.Delete<test_0string01>().Where("1=1").ExecuteAffrows();
|
||||
|
||||
Assert.Equal(1, fsql.Insert(new test_0string01 { name = @"1.0000\0.0000\0.0000\0.0000\1.0000\0.0000" }).ExecuteAffrows());
|
||||
Assert.Equal(1, fsql.Insert(new test_0string01 { name = @"1.0000\0.0000\0.0000\0.0000\1.0000\0.0000" }).NoneParameter().ExecuteAffrows());
|
||||
|
||||
var list = fsql.Select<test_0string01>().ToList();
|
||||
Assert.Equal(2, list.Count);
|
||||
Assert.Equal(@"1.0000\0.0000\0.0000\0.0000\1.0000\0.0000", list[0].name);
|
||||
Assert.Equal(@"1.0000\0.0000\0.0000\0.0000\1.0000\0.0000", list[1].name);
|
||||
}
|
||||
class test_0string01
|
||||
{
|
||||
public Guid id { get; set; }
|
||||
public string name { get; set; }
|
||||
}
|
||||
|
||||
[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 => "我是中国人")) };
|
||||
var item = new ts_iupstr { id = Guid.NewGuid(), title = string.Join(",", Enumerable.Range(0, 2000).Select(a => "我是中国人")) };
|
||||
Assert.Equal(1, fsql.Insert(item).ExecuteAffrows());
|
||||
var find = fsql.Select<ts_iupstr>().Where(a => a.id == item.id).First();
|
||||
Assert.NotNull(find);
|
||||
@ -35,6 +62,83 @@ namespace FreeSql.Tests.KingbaseES
|
||||
public string title { get; set; }
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DateTime_1()
|
||||
{
|
||||
var item1 = new TS_DATETIME01 { CreateTime = DateTime.Now };
|
||||
Assert.Equal(1, g.kingbaseES.Insert(item1).ExecuteAffrows());
|
||||
|
||||
var item2 = g.kingbaseES.Select<TS_DATETIME01>().Where(a => a.Id == item1.Id).First();
|
||||
Assert.NotNull(item2.CreateTime);
|
||||
Assert.True(1 > Math.Abs(item2.CreateTime.Value.Subtract(item1.CreateTime.Value).TotalSeconds));
|
||||
|
||||
item1.CreateTime = DateTime.Now;
|
||||
Assert.Equal(1, g.kingbaseES.Update<TS_DATETIME01>().SetSource(item1).ExecuteAffrows());
|
||||
item2 = g.kingbaseES.Select<TS_DATETIME01>().Where(a => a.Id == item1.Id).First();
|
||||
Assert.NotNull(item2.CreateTime);
|
||||
Assert.True(1 > Math.Abs(item2.CreateTime.Value.Subtract(item1.CreateTime.Value).TotalSeconds));
|
||||
}
|
||||
class TS_DATETIME01
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
[Column(DbType = "timestamp NULL")]
|
||||
public DateTime? CreateTime { get; set; }
|
||||
}
|
||||
[Fact]
|
||||
public void DateTime_2()
|
||||
{
|
||||
var item1 = new TS_DATETIME02 { CreateTime = DateTime.Now };
|
||||
Assert.Equal(1, g.kingbaseES.Insert(item1).ExecuteAffrows());
|
||||
|
||||
var item2 = g.kingbaseES.Select<TS_DATETIME02>().Where(a => a.Id == item1.Id).First();
|
||||
Assert.NotNull(item2.CreateTime);
|
||||
Assert.True(1 > Math.Abs(item2.CreateTime.Value.Subtract(item1.CreateTime.Value).TotalSeconds));
|
||||
|
||||
item1.CreateTime = DateTime.Now;
|
||||
Assert.Equal(1, g.kingbaseES.Update<TS_DATETIME02>().SetSource(item1).ExecuteAffrows());
|
||||
item2 = g.kingbaseES.Select<TS_DATETIME02>().Where(a => a.Id == item1.Id).First();
|
||||
Assert.NotNull(item2.CreateTime);
|
||||
Assert.True(1 > Math.Abs(item2.CreateTime.Value.Subtract(item1.CreateTime.Value).TotalSeconds));
|
||||
}
|
||||
class TS_DATETIME02
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
[Column(DbType = "timestamp NOT NULL")]
|
||||
public DateTime? CreateTime { get; set; }
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Blob()
|
||||
{
|
||||
var str1 = string.Join(",", Enumerable.Range(0, 10000).Select(a => "我是中国人"));
|
||||
var data1 = Encoding.UTF8.GetBytes(str1);
|
||||
|
||||
var item1 = new TS_BLB01 { Data = data1 };
|
||||
Assert.Equal(1, g.kingbaseES.Insert(item1).ExecuteAffrows());
|
||||
|
||||
var item2 = g.kingbaseES.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.Equal(1, g.kingbaseES.Insert<TS_BLB01>().NoneParameter().AppendData(item1).ExecuteAffrows());
|
||||
|
||||
item2 = g.kingbaseES.Select<TS_BLB01>().Where(a => a.Id == item1.Id).First();
|
||||
Assert.Equal(item1.Data.Length, item2.Data.Length);
|
||||
|
||||
str2 = Encoding.UTF8.GetString(item2.Data);
|
||||
Assert.Equal(str1, str2);
|
||||
}
|
||||
class TS_BLB01
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
[MaxLength(-1)]
|
||||
public byte[] Data { get; set; }
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void StringLength()
|
||||
{
|
||||
@ -52,106 +156,57 @@ namespace FreeSql.Tests.KingbaseES
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void 数字表_字段()
|
||||
public void 中文表_字段()
|
||||
{
|
||||
var sql = g.kingbaseES.CodeFirst.GetComparisonDDLStatements<测试数字表>();
|
||||
g.kingbaseES.CodeFirst.SyncStructure<测试数字表>();
|
||||
var sql = g.kingbaseES.CodeFirst.GetComparisonDDLStatements<测试中文表>();
|
||||
g.kingbaseES.CodeFirst.SyncStructure<测试中文表>();
|
||||
|
||||
var item = new 测试数字表
|
||||
var item = new 测试中文表
|
||||
{
|
||||
标题 = "测试标题",
|
||||
创建时间 = DateTime.Now
|
||||
标题 = "测试标题",
|
||||
创建时间 = DateTime.Now
|
||||
};
|
||||
Assert.Equal(1, g.kingbaseES.Insert<测试数字表>().AppendData(item).ExecuteAffrows());
|
||||
Assert.NotEqual(Guid.Empty, item.编号);
|
||||
var item2 = g.kingbaseES.Select<测试数字表>().Where(a => a.编号 == item.编号).First();
|
||||
Assert.Equal(1, g.kingbaseES.Insert<测试中文表>().AppendData(item).ExecuteAffrows());
|
||||
Assert.NotEqual(Guid.Empty, item.编号);
|
||||
var item2 = g.kingbaseES.Select<测试中文表>().Where(a => a.编号 == item.编号).First();
|
||||
Assert.NotNull(item2);
|
||||
Assert.Equal(item.编号, item2.编号);
|
||||
Assert.Equal(item.标题, item2.标题);
|
||||
Assert.Equal(item.编号, item2.编号);
|
||||
Assert.Equal(item.标题, item2.标题);
|
||||
|
||||
item.标题 = "测试标题更新";
|
||||
Assert.Equal(1, g.kingbaseES.Update<测试数字表>().SetSource(item).ExecuteAffrows());
|
||||
item2 = g.kingbaseES.Select<测试数字表>().Where(a => a.编号 == item.编号).First();
|
||||
item.标题 = "测试标题更新";
|
||||
Assert.Equal(1, g.kingbaseES.Update<测试中文表>().SetSource(item).ExecuteAffrows());
|
||||
item2 = g.kingbaseES.Select<测试中文表>().Where(a => a.编号 == item.编号).First();
|
||||
Assert.NotNull(item2);
|
||||
Assert.Equal(item.编号, item2.编号);
|
||||
Assert.Equal(item.标题, item2.标题);
|
||||
Assert.Equal(item.编号, item2.编号);
|
||||
Assert.Equal(item.标题, item2.标题);
|
||||
|
||||
item.标题 = "测试标题更新_repo";
|
||||
var repo = g.kingbaseES.GetRepository<测试数字表>();
|
||||
item.标题 = "测试标题更新_repo";
|
||||
var repo = g.kingbaseES.GetRepository<测试中文表>();
|
||||
Assert.Equal(1, repo.Update(item));
|
||||
item2 = g.kingbaseES.Select<测试数字表>().Where(a => a.编号 == item.编号).First();
|
||||
item2 = g.kingbaseES.Select<测试中文表>().Where(a => a.编号 == item.编号).First();
|
||||
Assert.NotNull(item2);
|
||||
Assert.Equal(item.编号, item2.编号);
|
||||
Assert.Equal(item.标题, item2.标题);
|
||||
Assert.Equal(item.编号, item2.编号);
|
||||
Assert.Equal(item.标题, item2.标题);
|
||||
|
||||
item.标题 = "测试标题更新_repo22";
|
||||
item.标题 = "测试标题更新_repo22";
|
||||
Assert.Equal(1, repo.Update(item));
|
||||
item2 = g.kingbaseES.Select<测试数字表>().Where(a => a.编号 == item.编号).First();
|
||||
item2 = g.kingbaseES.Select<测试中文表>().Where(a => a.编号 == item.编号).First();
|
||||
Assert.NotNull(item2);
|
||||
Assert.Equal(item.编号, item2.编号);
|
||||
Assert.Equal(item.标题, item2.标题);
|
||||
Assert.Equal(item.编号, item2.编号);
|
||||
Assert.Equal(item.标题, item2.标题);
|
||||
}
|
||||
[Table(Name = "123测试数字表")]
|
||||
class 测试数字表
|
||||
{
|
||||
[Column(IsPrimary = true, Name = "123编号")]
|
||||
public Guid 编号 { get; set; }
|
||||
|
||||
[Column(Name = "123标题")]
|
||||
public string 标题 { get; set; }
|
||||
|
||||
[Column(Name = "123创建时间")]
|
||||
public DateTime 创建时间 { get; set; }
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void 中文表_字段()
|
||||
{
|
||||
var sql = g.kingbaseES.CodeFirst.GetComparisonDDLStatements<测试中文表>();
|
||||
g.kingbaseES.CodeFirst.SyncStructure<测试中文表>();
|
||||
|
||||
var item = new 测试中文表
|
||||
{
|
||||
标题 = "测试标题",
|
||||
创建时间 = DateTime.Now
|
||||
};
|
||||
Assert.Equal(1, g.kingbaseES.Insert<测试中文表>().AppendData(item).ExecuteAffrows());
|
||||
Assert.NotEqual(Guid.Empty, item.编号);
|
||||
var item2 = g.kingbaseES.Select<测试中文表>().Where(a => a.编号 == item.编号).First();
|
||||
Assert.NotNull(item2);
|
||||
Assert.Equal(item.编号, item2.编号);
|
||||
Assert.Equal(item.标题, item2.标题);
|
||||
|
||||
item.标题 = "测试标题更新";
|
||||
Assert.Equal(1, g.kingbaseES.Update<测试中文表>().SetSource(item).ExecuteAffrows());
|
||||
item2 = g.kingbaseES.Select<测试中文表>().Where(a => a.编号 == item.编号).First();
|
||||
Assert.NotNull(item2);
|
||||
Assert.Equal(item.编号, item2.编号);
|
||||
Assert.Equal(item.标题, item2.标题);
|
||||
|
||||
item.标题 = "测试标题更新_repo";
|
||||
var repo = g.kingbaseES.GetRepository<测试中文表>();
|
||||
Assert.Equal(1, repo.Update(item));
|
||||
item2 = g.kingbaseES.Select<测试中文表>().Where(a => a.编号 == item.编号).First();
|
||||
Assert.NotNull(item2);
|
||||
Assert.Equal(item.编号, item2.编号);
|
||||
Assert.Equal(item.标题, item2.标题);
|
||||
|
||||
item.标题 = "测试标题更新_repo22";
|
||||
Assert.Equal(1, repo.Update(item));
|
||||
item2 = g.kingbaseES.Select<测试中文表>().Where(a => a.编号 == item.编号).First();
|
||||
Assert.NotNull(item2);
|
||||
Assert.Equal(item.编号, item2.编号);
|
||||
Assert.Equal(item.标题, item2.标题);
|
||||
}
|
||||
class 测试中文表
|
||||
class 测试中文表
|
||||
{
|
||||
[Column(IsPrimary = true)]
|
||||
public Guid 编号 { get; set; }
|
||||
public Guid 编号 { get; set; }
|
||||
|
||||
public string 标题 { get; set; }
|
||||
public string 标题 { get; set; }
|
||||
|
||||
public DateTime 创建时间 { get; set; }
|
||||
[Column(ServerTime = DateTimeKind.Local, CanUpdate = false)]
|
||||
public DateTime 创建时间 { get; set; }
|
||||
|
||||
[Column(ServerTime = DateTimeKind.Local)]
|
||||
public DateTime 更新时间 { get; set; }
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@ -164,7 +219,7 @@ namespace FreeSql.Tests.KingbaseES
|
||||
[Table(Name = "AddUniquesInfo", OldName = "AddUniquesInfo2")]
|
||||
[Index("{tablename}_uk_phone", "phone", true)]
|
||||
[Index("{tablename}_uk_group_index", "group,index", true)]
|
||||
[Index("{tablename}_uk_group_index22", "group, index22", true)]
|
||||
[Index("{tablename}_uk_group_index22", "group, index22", false)]
|
||||
class AddUniquesInfo
|
||||
{
|
||||
public Guid id { get; set; }
|
||||
@ -174,26 +229,36 @@ namespace FreeSql.Tests.KingbaseES
|
||||
public int index { get; set; }
|
||||
public string index22 { get; set; }
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AddField()
|
||||
{
|
||||
var sql = g.kingbaseES.CodeFirst.GetComparisonDDLStatements<TopicAddField>();
|
||||
|
||||
Assert.True(string.IsNullOrEmpty(sql)); //测试运行两次后
|
||||
g.kingbaseES.Select<TopicAddField>();
|
||||
var id = g.kingbaseES.Insert<TopicAddField>().AppendData(new TopicAddField { }).ExecuteIdentity();
|
||||
|
||||
//var inserted = g.kingbaseES.Insert<TopicAddField>().AppendData(new TopicAddField { }).ExecuteInserted();
|
||||
}
|
||||
|
||||
[Table(Name = "TopicAddField", OldName = "xxxtb.TopicAddField")]
|
||||
[Table(Name = "ccc2.TopicAddField", OldName = "ccc.TopicAddField")]
|
||||
public class TopicAddField
|
||||
{
|
||||
[Column(IsIdentity = true)]
|
||||
public int Id { get; set; }
|
||||
|
||||
public string name { get; set; }
|
||||
public string name { get; set; } = "xxx";
|
||||
|
||||
public int clicks { get; set; } = 10;
|
||||
//public int name { get; set; } = 3000;
|
||||
|
||||
//[Column(DbType = "varchar(200) not null", OldName = "title")]
|
||||
//public string title222 { get; set; } = "333";
|
||||
|
||||
[Column(DbType = "varchar(200) not null")]
|
||||
public string title222333 { get; set; } = "xxx";
|
||||
|
||||
//[Column(DbType = "varchar(100) not null", OldName = "title122333aaa")]
|
||||
//public string titleaaa { get; set; } = "fsdf";
|
||||
|
||||
[Column(DbType = "varchar2(200) not null", OldName = "title")]
|
||||
public string title2 { get; set; } = "10";
|
||||
|
||||
[Column(IsIgnore = true)]
|
||||
public DateTime ct { get; set; } = DateTime.Now;
|
||||
@ -202,9 +267,9 @@ namespace FreeSql.Tests.KingbaseES
|
||||
[Fact]
|
||||
public void GetComparisonDDLStatements()
|
||||
{
|
||||
|
||||
var sql = g.kingbaseES.CodeFirst.GetComparisonDDLStatements<TableAllType>();
|
||||
Assert.True(string.IsNullOrEmpty(sql)); //测试运行两次后
|
||||
//sql = g.kingbaseES.CodeFirst.GetComparisonDDLStatements<Tb_alltype>();
|
||||
g.kingbaseES.Select<TableAllType>();
|
||||
}
|
||||
|
||||
IInsert<TableAllType> insert => g.kingbaseES.Insert<TableAllType>();
|
||||
@ -213,6 +278,9 @@ namespace FreeSql.Tests.KingbaseES
|
||||
[Fact]
|
||||
public void CurdAllField()
|
||||
{
|
||||
var sql1 = select.Where(a => a.testFieldIntArray.Contains(1)).ToSql();
|
||||
var sql2 = select.Where(a => a.testFieldIntArray.Contains(1)).ToSql();
|
||||
|
||||
var item = new TableAllType { };
|
||||
item.Id = (int)insert.AppendData(item).ExecuteIdentity();
|
||||
|
||||
@ -220,83 +288,157 @@ namespace FreeSql.Tests.KingbaseES
|
||||
|
||||
var item2 = new TableAllType
|
||||
{
|
||||
Bool = true,
|
||||
BoolNullable = true,
|
||||
Byte = 255,
|
||||
ByteNullable = 127,
|
||||
Bytes = Encoding.UTF8.GetBytes("我是中国人"),
|
||||
DateTime = DateTime.Now,
|
||||
DateTimeNullable = DateTime.Now.AddHours(-1),
|
||||
Decimal = 99.99M,
|
||||
DecimalNullable = 99.98M,
|
||||
Double = 999.99,
|
||||
DoubleNullable = 999.98,
|
||||
Enum1 = TableAllTypeEnumType1.e5,
|
||||
Enum1Nullable = TableAllTypeEnumType1.e3,
|
||||
Enum2 = TableAllTypeEnumType2.f2,
|
||||
Enum2Nullable = TableAllTypeEnumType2.f3,
|
||||
Float = 19.99F,
|
||||
FloatNullable = 19.98F,
|
||||
Guid = Guid.NewGuid(),
|
||||
GuidNullable = Guid.NewGuid(),
|
||||
Int = int.MaxValue,
|
||||
IntNullable = int.MinValue,
|
||||
SByte = 100,
|
||||
SByteNullable = 99,
|
||||
Short = short.MaxValue,
|
||||
ShortNullable = short.MinValue,
|
||||
String = "我是中国人string'\\?!@#$%^&*()_+{}}{~?><<>",
|
||||
Char = 'X',
|
||||
TimeSpan = TimeSpan.FromSeconds(999),
|
||||
TimeSpanNullable = TimeSpan.FromSeconds(60),
|
||||
UInt = uint.MaxValue,
|
||||
UIntNullable = uint.MinValue,
|
||||
ULong = ulong.MaxValue,
|
||||
ULongNullable = ulong.MinValue,
|
||||
UShort = ushort.MaxValue,
|
||||
UShortNullable = ushort.MinValue,
|
||||
testFieldBitArray = new BitArray(Encoding.UTF8.GetBytes("我是")),
|
||||
testFieldBitArrayArray = new[] { new BitArray(Encoding.UTF8.GetBytes("中国")), new BitArray(Encoding.UTF8.GetBytes("公民")) },
|
||||
testFieldBool = true,
|
||||
testFieldBoolArray = new[] { true, true, false, false },
|
||||
testFieldBoolArrayNullable = new bool?[] { true, true, null, false, false },
|
||||
testFieldBoolNullable = true,
|
||||
testFieldByte = byte.MaxValue,
|
||||
testFieldByteArray = new byte[] { 0, 1, 2, 3, 4, 5, 6 },
|
||||
testFieldByteArrayNullable = new byte?[] { 0, 1, 2, 3, null, 4, 5, 6 },
|
||||
testFieldByteNullable = byte.MinValue,
|
||||
testFieldBytes = Encoding.UTF8.GetBytes("我是中国人"),
|
||||
testFieldBytesArray = new[] { Encoding.UTF8.GetBytes("我是中国人"), Encoding.UTF8.GetBytes("我是中国人") },
|
||||
testFieldCidr = (IPAddress.Parse("10.0.0.0"), 8),
|
||||
testFieldCidrArray = new[] { (IPAddress.Parse("10.0.0.0"), 8), (IPAddress.Parse("192.168.0.0"), 16) },
|
||||
testFieldCidrArrayNullable = new (IPAddress, int)?[] { (IPAddress.Parse("10.0.0.0"), 8), null, (IPAddress.Parse("192.168.0.0"), 16) },
|
||||
testFieldCidrNullable = (IPAddress.Parse("192.168.0.0"), 16),
|
||||
testFieldDateTime = DateTime.Now,
|
||||
testFieldDateTimeArray = new[] { DateTime.Now, DateTime.Now.AddHours(2) },
|
||||
testFieldDateTimeArrayNullable = new DateTime?[] { DateTime.Now, null, DateTime.Now.AddHours(2) },
|
||||
testFieldDateTimeNullable = DateTime.Now.AddDays(-1),
|
||||
testFieldDecimal = 999.99M,
|
||||
testFieldDecimalArray = new[] { 999.91M, 999.92M, 999.93M },
|
||||
testFieldDecimalArrayNullable = new decimal?[] { 998.11M, 998.12M, 998.13M },
|
||||
testFieldDecimalNullable = 111.11M,
|
||||
testFieldDouble = 888.88,
|
||||
testFieldDoubleArray = new[] { 888.81, 888.82, 888.83 },
|
||||
testFieldDoubleArrayNullable = new double?[] { 888.11, 888.12, null, 888.13 },
|
||||
testFieldDoubleNullable = 222.22,
|
||||
testFieldEnum1 = TableAllTypeEnumType1.e3,
|
||||
testFieldEnum1Array = new[] { TableAllTypeEnumType1.e5, TableAllTypeEnumType1.e2, TableAllTypeEnumType1.e1 },
|
||||
testFieldEnum1ArrayNullable = new TableAllTypeEnumType1?[] { TableAllTypeEnumType1.e5, TableAllTypeEnumType1.e2, null, TableAllTypeEnumType1.e1 },
|
||||
testFieldEnum1Nullable = TableAllTypeEnumType1.e2,
|
||||
testFieldEnum2 = TableAllTypeEnumType2.f2,
|
||||
testFieldEnum2Array = new[] { TableAllTypeEnumType2.f3, TableAllTypeEnumType2.f1 },
|
||||
testFieldEnum2ArrayNullable = new TableAllTypeEnumType2?[] { TableAllTypeEnumType2.f3, null, TableAllTypeEnumType2.f1 },
|
||||
testFieldEnum2Nullable = TableAllTypeEnumType2.f3,
|
||||
testFieldFloat = 777.77F,
|
||||
testFieldFloatArray = new[] { 777.71F, 777.72F, 777.73F },
|
||||
testFieldFloatArrayNullable = new float?[] { 777.71F, 777.72F, null, 777.73F },
|
||||
testFieldFloatNullable = 333.33F,
|
||||
testFieldGuid = Guid.NewGuid(),
|
||||
testFieldGuidArray = new[] { Guid.NewGuid(), Guid.NewGuid() },
|
||||
testFieldGuidArrayNullable = new Guid?[] { Guid.NewGuid(), null, Guid.NewGuid() },
|
||||
testFieldGuidNullable = Guid.NewGuid(),
|
||||
//testFieldHStore = new Dictionary<string, string> { { "111", "value111" }, { "222", "value222" }, { "333", "value333" } },
|
||||
//testFieldHStoreArray = new[] { new Dictionary<string, string> { { "111", "value111" }, { "222", "value222" }, { "333", "value333" } }, new Dictionary<string, string> { { "444", "value444" }, { "555", "value555" }, { "666", "value666" } } },
|
||||
testFieldInet = IPAddress.Parse("192.168.1.1"),
|
||||
testFieldInetArray = new[] { IPAddress.Parse("192.168.1.1"), IPAddress.Parse("192.168.1.2"), IPAddress.Parse("192.168.1.3") },
|
||||
testFieldInt = int.MaxValue,
|
||||
testFieldInt4range = new KdbndpRange<int>(10, 20),
|
||||
testFieldInt4rangeArray = new[] { new KdbndpRange<int>(10, 20), new KdbndpRange<int>(50, 100), new KdbndpRange<int>(200, 300) },
|
||||
testFieldInt4rangeArrayNullable = new KdbndpRange<int>?[] { new KdbndpRange<int>(10, 20), new KdbndpRange<int>(50, 100), null, new KdbndpRange<int>(200, 300) },
|
||||
testFieldInt4rangeNullable = new KdbndpRange<int>(100, 200),
|
||||
testFieldInt8range = new KdbndpRange<long>(100, 200),
|
||||
testFieldInt8rangeArray = new[] { new KdbndpRange<long>(100, 200), new KdbndpRange<long>(500, 1000), new KdbndpRange<long>(2000, 3000) },
|
||||
testFieldInt8rangeArrayNullable = new KdbndpRange<long>?[] { new KdbndpRange<long>(100, 200), new KdbndpRange<long>(500, 1000), null, new KdbndpRange<long>(2000, 3000) },
|
||||
testFieldInt8rangeNullable = new KdbndpRange<long>(1000, 2000),
|
||||
testFieldIntArray = new[] { 1, 2, 3, 4, 5 },
|
||||
testFieldIntArrayNullable = new int?[] { 1, 2, 3, null, 4, 5 },
|
||||
testFieldIntNullable = int.MinValue,
|
||||
testFieldJArray = JArray.Parse("[1,2,3,4,5]"),
|
||||
testFieldJArrayArray = new[] { JArray.Parse("[1,2,3,4,5]"), JArray.Parse("[10,20,30,40,50]") },
|
||||
testFieldJObject = JObject.Parse("{ \"a\":1, \"b\":2, \"c\":3 }"),
|
||||
testFieldJObjectArray = new[] { JObject.Parse("{ \"a\":1, \"b\":2, \"c\":3 }"), JObject.Parse("{ \"a\":10, \"b\":20, \"c\":30 }") },
|
||||
testFieldJToken = JToken.Parse("{ \"a\":1, \"b\":2, \"c\":3, \"d\":[1,2,3,4,5] }"),
|
||||
testFieldJTokenArray = new[] { JToken.Parse("{ \"a\":1, \"b\":2, \"c\":3, \"d\":[1,2,3,4,5] }"), JToken.Parse("{ \"a\":10, \"b\":20, \"c\":30, \"d\":[10,20,30,40,50] }") },
|
||||
testFieldLong = long.MaxValue,
|
||||
testFieldLongArray = new long[] { 10, 20, 30, 40, 50 },
|
||||
testFieldMacaddr = PhysicalAddress.Parse("A1-A2-CD-DD-FF-02"),
|
||||
testFieldMacaddrArray = new[] { PhysicalAddress.Parse("A1-A2-CD-DD-FF-02"), PhysicalAddress.Parse("A2-22-22-22-22-02") },
|
||||
testFieldKdbndpBox = new KdbndpBox(10, 100, 100, 10),
|
||||
testFieldKdbndpBoxArray = new[] { new KdbndpBox(10, 100, 100, 10), new KdbndpBox(200, 2000, 2000, 200) },
|
||||
testFieldKdbndpBoxArrayNullable = new KdbndpBox?[] { new KdbndpBox(10, 100, 100, 10), null, new KdbndpBox(200, 2000, 2000, 200) },
|
||||
testFieldKdbndpBoxNullable = new KdbndpBox(200, 2000, 2000, 200),
|
||||
testFieldKdbndpCircle = new KdbndpCircle(50, 50, 100),
|
||||
testFieldKdbndpCircleArray = new[] { new KdbndpCircle(50, 50, 100), new KdbndpCircle(80, 80, 100) },
|
||||
testFieldKdbndpCircleArrayNullable = new KdbndpCircle?[] { new KdbndpCircle(50, 50, 100), null, new KdbndpCircle(80, 80, 100) },
|
||||
testFieldKdbndpCircleNullable = new KdbndpCircle(80, 80, 100),
|
||||
testFieldKdbndpLine = new KdbndpLine(30, 30, 30),
|
||||
testFieldKdbndpLineArray = new[] { new KdbndpLine(30, 30, 30), new KdbndpLine(35, 35, 35) },
|
||||
testFieldKdbndpLineArrayNullable = new KdbndpLine?[] { new KdbndpLine(30, 30, 30), null, new KdbndpLine(35, 35, 35) },
|
||||
testFieldKdbndpLineNullable = new KdbndpLine(60, 60, 60),
|
||||
testFieldKdbndpLSeg = new KdbndpLSeg(80, 10, 800, 20),
|
||||
testFieldKdbndpLSegArray = new[] { new KdbndpLSeg(80, 10, 800, 20), new KdbndpLSeg(180, 20, 260, 50) },
|
||||
testFieldKdbndpLSegArrayNullable = new KdbndpLSeg?[] { new KdbndpLSeg(80, 10, 800, 20), null, new KdbndpLSeg(180, 20, 260, 50) },
|
||||
testFieldKdbndpLSegNullable = new KdbndpLSeg(180, 20, 260, 50),
|
||||
testFieldKdbndpPath = new KdbndpPath(new KdbndpPoint(10, 10), new KdbndpPoint(15, 10), new KdbndpPoint(17, 10), new KdbndpPoint(19, 10)),
|
||||
testFieldKdbndpPathArray = new[] { new KdbndpPath(new KdbndpPoint(10, 10), new KdbndpPoint(15, 10), new KdbndpPoint(17, 10), new KdbndpPoint(19, 10)), new KdbndpPath(new KdbndpPoint(210, 10), new KdbndpPoint(215, 10), new KdbndpPoint(217, 10), new KdbndpPoint(219, 10)) },
|
||||
testFieldKdbndpPathArrayNullable = new KdbndpPath?[] { new KdbndpPath(new KdbndpPoint(10, 10), new KdbndpPoint(15, 10), new KdbndpPoint(17, 10), new KdbndpPoint(19, 10)), null, new KdbndpPath(new KdbndpPoint(210, 10), new KdbndpPoint(215, 10), new KdbndpPoint(217, 10), new KdbndpPoint(219, 10)) },
|
||||
testFieldKdbndpPathNullable = new KdbndpPath(new KdbndpPoint(210, 10), new KdbndpPoint(215, 10), new KdbndpPoint(217, 10), new KdbndpPoint(219, 10)),
|
||||
testFieldKdbndpPoint = new KdbndpPoint(666, 666),
|
||||
testFieldKdbndpPointArray = new[] { new KdbndpPoint(666, 666), new KdbndpPoint(888, 888) },
|
||||
testFieldKdbndpPointArrayNullable = new KdbndpPoint?[] { new KdbndpPoint(666, 666), null, new KdbndpPoint(888, 888) },
|
||||
testFieldKdbndpPointNullable = new KdbndpPoint(888, 888),
|
||||
testFieldKdbndpPolygon = new KdbndpPolygon(new KdbndpPoint(36, 30), new KdbndpPoint(36, 50), new KdbndpPoint(38, 80), new KdbndpPoint(36, 30)),
|
||||
testFieldKdbndpPolygonArray = new[] { new KdbndpPolygon(new KdbndpPoint(36, 30), new KdbndpPoint(36, 50), new KdbndpPoint(38, 80), new KdbndpPoint(36, 30)), new KdbndpPolygon(new KdbndpPoint(136, 130), new KdbndpPoint(136, 150), new KdbndpPoint(138, 180), new KdbndpPoint(136, 130)) },
|
||||
testFieldKdbndpPolygonArrayNullable = new KdbndpPolygon?[] { new KdbndpPolygon(new KdbndpPoint(36, 30), new KdbndpPoint(36, 50), new KdbndpPoint(38, 80), new KdbndpPoint(36, 30)), null, new KdbndpPolygon(new KdbndpPoint(136, 130), new KdbndpPoint(136, 150), new KdbndpPoint(138, 180), new KdbndpPoint(136, 130)) },
|
||||
testFieldKdbndpPolygonNullable = new KdbndpPolygon(new KdbndpPoint(136, 130), new KdbndpPoint(136, 150), new KdbndpPoint(138, 180), new KdbndpPoint(136, 130)),
|
||||
testFieldNumrange = new KdbndpRange<decimal>(888.88M, 999.99M),
|
||||
testFieldNumrangeArray = new[] { new KdbndpRange<decimal>(888.88M, 999.99M), new KdbndpRange<decimal>(18888.88M, 19998.99M) },
|
||||
testFieldNumrangeArrayNullable = new KdbndpRange<decimal>?[] { new KdbndpRange<decimal>(888.88M, 999.99M), null, new KdbndpRange<decimal>(18888.88M, 19998.99M) },
|
||||
testFieldNumrangeNullable = new KdbndpRange<decimal>(18888.88M, 19998.99M),
|
||||
|
||||
testFieldSByte = sbyte.MaxValue,
|
||||
testFieldSByteArray = new sbyte[] { 1, 2, 3, 4, 5 },
|
||||
testFieldSByteArrayNullable = new sbyte?[] { 1, 2, 3, null, 4, 5 },
|
||||
testFieldSByteNullable = sbyte.MinValue,
|
||||
testFieldShort = short.MaxValue,
|
||||
testFieldShortArray = new short[] { 1, 2, 3, 4, 5 },
|
||||
testFieldShortArrayNullable = new short?[] { 1, 2, 3, null, 4, 5 },
|
||||
testFieldShortNullable = short.MinValue,
|
||||
testFieldString = "我是中国人string'\\?!@#$%^&*()_+{}}{~?><<>",
|
||||
testFieldChar = 'X',
|
||||
testFieldStringArray = new[] { "我是中国人String1", "我是中国人String2", null, "我是中国人String3" },
|
||||
testFieldTimeSpan = TimeSpan.FromDays(1),
|
||||
testFieldTimeSpanArray = new[] { TimeSpan.FromDays(1), TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(60) },
|
||||
testFieldTimeSpanArrayNullable = new TimeSpan?[] { TimeSpan.FromDays(1), TimeSpan.FromSeconds(10), null, TimeSpan.FromSeconds(60) },
|
||||
testFieldTimeSpanNullable = TimeSpan.FromSeconds(90),
|
||||
testFieldTsrange = new KdbndpRange<DateTime>(DateTime.Now, DateTime.Now.AddMonths(1)),
|
||||
testFieldTsrangeArray = new[] { new KdbndpRange<DateTime>(DateTime.Now, DateTime.Now.AddMonths(1)), new KdbndpRange<DateTime>(DateTime.Now, DateTime.Now.AddMonths(2)) },
|
||||
testFieldTsrangeArrayNullable = new KdbndpRange<DateTime>?[] { new KdbndpRange<DateTime>(DateTime.Now, DateTime.Now.AddMonths(1)), null, new KdbndpRange<DateTime>(DateTime.Now, DateTime.Now.AddMonths(2)) },
|
||||
testFieldTsrangeNullable = new KdbndpRange<DateTime>(DateTime.Now, DateTime.Now.AddMonths(2)),
|
||||
testFieldUInt = uint.MaxValue,
|
||||
testFieldUIntArray = new uint[] { 1, 2, 3, 4, 5 },
|
||||
testFieldUIntArrayNullable = new uint?[] { 1, 2, 3, null, 4, 5 },
|
||||
testFieldUIntNullable = uint.MinValue,
|
||||
testFieldULong = ulong.MaxValue,
|
||||
testFieldULongArray = new ulong[] { 10, 20, 30, 40, 50 },
|
||||
testFieldULongArrayNullable = new ulong?[] { 10, 20, 30, null, 40, 50 },
|
||||
testFieldULongNullable = ulong.MinValue,
|
||||
testFieldUShort = ushort.MaxValue,
|
||||
testFieldUShortArray = new ushort[] { 11, 12, 13, 14, 15 },
|
||||
testFieldUShortArrayNullable = new ushort?[] { 11, 12, 13, null, 14, 15 },
|
||||
testFieldUShortNullable = ushort.MinValue,
|
||||
testFielLongArrayNullable = new long?[] { 500, 600, 700, null, 999, 1000 },
|
||||
testFielLongNullable = long.MinValue
|
||||
};
|
||||
|
||||
var sqlPar = insert.AppendData(item2).ToSql();
|
||||
var sqlText = insert.AppendData(item2).NoneParameter().ToSql();
|
||||
var item3NP = insert.AppendData(item2).NoneParameter().ExecuteIdentity();
|
||||
var item3NP = insert.AppendData(item2).NoneParameter().ExecuteInserted();
|
||||
|
||||
item2.Id = (int)insert.AppendData(item2).ExecuteIdentity();
|
||||
var newitem21 = select.Where(a => a.Id == item2.Id).First(a => new
|
||||
{
|
||||
a.Id,
|
||||
a.id2,
|
||||
a.SByte,
|
||||
a.Short,
|
||||
a.Int,
|
||||
a.Long,
|
||||
a.Byte,
|
||||
a.UShort,
|
||||
a.UInt,
|
||||
a.ULong,
|
||||
a.Double,
|
||||
a.Float,
|
||||
a.Decimal,
|
||||
a.TimeSpan,
|
||||
a.DateTimeOffSet,
|
||||
a.Bytes,
|
||||
a.String,
|
||||
a.Char,
|
||||
a.Guid
|
||||
});
|
||||
var newitem22 = select.Where(a => a.Id == item2.Id).First(a => new
|
||||
{
|
||||
a.Id, a.id2, a.SByte, a.Short, a.Int, a.Long, a.Byte, a.UShort, a.UInt, a.ULong, a.Double, a.Float, a.Decimal, a.TimeSpan, a.DateTime, a.DateTimeOffSet, a.Bytes, a.String, a.Char, a.Guid
|
||||
});
|
||||
var item3 = insert.AppendData(item2).ExecuteInserted().First();
|
||||
var newitem2 = select.Where(a => a.Id == item3.Id && object.Equals(a.testFieldJToken["a"], "1")).ToOne();
|
||||
Assert.Equal(item2.testFieldString, newitem2.testFieldString);
|
||||
Assert.Equal(item2.testFieldChar, newitem2.testFieldChar);
|
||||
|
||||
var newitem2 = select.Where(a => a.Id == item2.Id).ToOne();
|
||||
Assert.Equal(item2.String, newitem2.String);
|
||||
Assert.Equal(item2.Char, newitem2.Char);
|
||||
|
||||
item2.Id = (int)insert.NoneParameter().AppendData(item2).ExecuteIdentity();
|
||||
newitem2 = select.Where(a => a.Id == item2.Id).ToOne();
|
||||
Assert.Equal(item2.String, newitem2.String);
|
||||
Assert.Equal(item2.Char, newitem2.Char);
|
||||
item3 = insert.NoneParameter().AppendData(item2).ExecuteInserted().First();
|
||||
newitem2 = select.Where(a => a.Id == item3.Id && object.Equals(a.testFieldJToken["a"], "1")).ToOne();
|
||||
Assert.Equal(item2.testFieldString, newitem2.testFieldString);
|
||||
Assert.Equal(item2.testFieldChar, newitem2.testFieldChar);
|
||||
|
||||
var items = select.ToList();
|
||||
var itemstb = select.ToDataTable();
|
||||
@ -308,49 +450,155 @@ namespace FreeSql.Tests.KingbaseES
|
||||
[Column(IsIdentity = true, IsPrimary = true)]
|
||||
public int Id { get; set; }
|
||||
|
||||
public string id2 { get; set; } = "id2=10";
|
||||
public bool testFieldBool { get; set; }
|
||||
public sbyte testFieldSByte { get; set; }
|
||||
public short testFieldShort { get; set; }
|
||||
public int testFieldInt { get; set; }
|
||||
public long testFieldLong { get; set; }
|
||||
public byte testFieldByte { get; set; }
|
||||
public ushort testFieldUShort { get; set; }
|
||||
public uint testFieldUInt { get; set; }
|
||||
public ulong testFieldULong { get; set; }
|
||||
public double testFieldDouble { get; set; }
|
||||
public float testFieldFloat { get; set; }
|
||||
public decimal testFieldDecimal { get; set; }
|
||||
public TimeSpan testFieldTimeSpan { get; set; }
|
||||
|
||||
public bool Bool { get; set; }
|
||||
public sbyte SByte { get; set; }
|
||||
public short Short { get; set; }
|
||||
public int Int { get; set; }
|
||||
public long Long { get; set; }
|
||||
public byte Byte { get; set; }
|
||||
public ushort UShort { get; set; }
|
||||
public uint UInt { get; set; }
|
||||
public ulong ULong { get; set; }
|
||||
public double Double { get; set; }
|
||||
public float Float { get; set; }
|
||||
public decimal Decimal { get; set; }
|
||||
public TimeSpan TimeSpan { get; set; }
|
||||
public DateTime DateTime { get; set; }
|
||||
public DateTime DateTimeOffSet { get; set; }
|
||||
public byte[] Bytes { get; set; }
|
||||
public string String { get; set; }
|
||||
public char Char { get; set; }
|
||||
public Guid Guid { get; set; }
|
||||
[Column(ServerTime = DateTimeKind.Local)]
|
||||
public DateTime testFieldDateTime { get; set; }
|
||||
|
||||
public bool? BoolNullable { get; set; }
|
||||
public sbyte? SByteNullable { get; set; }
|
||||
public short? ShortNullable { get; set; }
|
||||
public int? IntNullable { get; set; }
|
||||
public byte[] testFieldBytes { get; set; }
|
||||
public string testFieldString { get; set; }
|
||||
public char testFieldChar { get; set; }
|
||||
public Guid testFieldGuid { get; set; }
|
||||
public KdbndpPoint testFieldKdbndpPoint { get; set; }
|
||||
public KdbndpLine testFieldKdbndpLine { get; set; }
|
||||
public KdbndpLSeg testFieldKdbndpLSeg { get; set; }
|
||||
public KdbndpBox testFieldKdbndpBox { get; set; }
|
||||
public KdbndpPath testFieldKdbndpPath { get; set; }
|
||||
public KdbndpPolygon testFieldKdbndpPolygon { get; set; }
|
||||
public KdbndpCircle testFieldKdbndpCircle { get; set; }
|
||||
public (IPAddress Address, int Subnet) testFieldCidr { get; set; }
|
||||
public KdbndpRange<int> testFieldInt4range { get; set; }
|
||||
public KdbndpRange<long> testFieldInt8range { get; set; }
|
||||
public KdbndpRange<decimal> testFieldNumrange { get; set; }
|
||||
public KdbndpRange<DateTime> testFieldTsrange { get; set; }
|
||||
|
||||
public bool? testFieldBoolNullable { get; set; }
|
||||
public sbyte? testFieldSByteNullable { get; set; }
|
||||
public short? testFieldShortNullable { get; set; }
|
||||
public int? testFieldIntNullable { get; set; }
|
||||
public long? testFielLongNullable { get; set; }
|
||||
public byte? ByteNullable { get; set; }
|
||||
public ushort? UShortNullable { get; set; }
|
||||
public uint? UIntNullable { get; set; }
|
||||
public ulong? ULongNullable { get; set; }
|
||||
public double? DoubleNullable { get; set; }
|
||||
public float? FloatNullable { get; set; }
|
||||
public decimal? DecimalNullable { get; set; }
|
||||
public TimeSpan? TimeSpanNullable { get; set; }
|
||||
public DateTime? DateTimeNullable { get; set; }
|
||||
public DateTime? DateTimeOffSetNullable { get; set; }
|
||||
public Guid? GuidNullable { get; set; }
|
||||
public byte? testFieldByteNullable { get; set; }
|
||||
public ushort? testFieldUShortNullable { get; set; }
|
||||
public uint? testFieldUIntNullable { get; set; }
|
||||
public ulong? testFieldULongNullable { get; set; }
|
||||
public double? testFieldDoubleNullable { get; set; }
|
||||
public float? testFieldFloatNullable { get; set; }
|
||||
public decimal? testFieldDecimalNullable { get; set; }
|
||||
public TimeSpan? testFieldTimeSpanNullable { get; set; }
|
||||
|
||||
public TableAllTypeEnumType1 Enum1 { get; set; }
|
||||
public TableAllTypeEnumType1? Enum1Nullable { get; set; }
|
||||
public TableAllTypeEnumType2 Enum2 { get; set; }
|
||||
public TableAllTypeEnumType2? Enum2Nullable { get; set; }
|
||||
[Column(ServerTime = DateTimeKind.Local)]
|
||||
public DateTime? testFieldDateTimeNullable { get; set; }
|
||||
|
||||
public Guid? testFieldGuidNullable { get; set; }
|
||||
public KdbndpPoint? testFieldKdbndpPointNullable { get; set; }
|
||||
public KdbndpLine? testFieldKdbndpLineNullable { get; set; }
|
||||
public KdbndpLSeg? testFieldKdbndpLSegNullable { get; set; }
|
||||
public KdbndpBox? testFieldKdbndpBoxNullable { get; set; }
|
||||
public KdbndpPath? testFieldKdbndpPathNullable { get; set; }
|
||||
public KdbndpPolygon? testFieldKdbndpPolygonNullable { get; set; }
|
||||
public KdbndpCircle? testFieldKdbndpCircleNullable { get; set; }
|
||||
public (IPAddress Address, int Subnet)? testFieldCidrNullable { get; set; }
|
||||
public KdbndpRange<int>? testFieldInt4rangeNullable { get; set; }
|
||||
public KdbndpRange<long>? testFieldInt8rangeNullable { get; set; }
|
||||
public KdbndpRange<decimal>? testFieldNumrangeNullable { get; set; }
|
||||
public KdbndpRange<DateTime>? testFieldTsrangeNullable { get; set; }
|
||||
|
||||
public BitArray testFieldBitArray { get; set; }
|
||||
public IPAddress testFieldInet { get; set; }
|
||||
public PhysicalAddress testFieldMacaddr { get; set; }
|
||||
public JToken testFieldJToken { get; set; }
|
||||
public JObject testFieldJObject { get; set; }
|
||||
public JArray testFieldJArray { get; set; }
|
||||
//public Dictionary<string, string> testFieldHStore { get; set; }
|
||||
|
||||
public TableAllTypeEnumType1 testFieldEnum1 { get; set; }
|
||||
public TableAllTypeEnumType1? testFieldEnum1Nullable { get; set; }
|
||||
public TableAllTypeEnumType2 testFieldEnum2 { get; set; }
|
||||
public TableAllTypeEnumType2? testFieldEnum2Nullable { get; set; }
|
||||
|
||||
/* array */
|
||||
public bool[] testFieldBoolArray { get; set; }
|
||||
public sbyte[] testFieldSByteArray { get; set; }
|
||||
public short[] testFieldShortArray { get; set; }
|
||||
public int[] testFieldIntArray { get; set; }
|
||||
public long[] testFieldLongArray { get; set; }
|
||||
public byte[] testFieldByteArray { get; set; }
|
||||
public ushort[] testFieldUShortArray { get; set; }
|
||||
public uint[] testFieldUIntArray { get; set; }
|
||||
public ulong[] testFieldULongArray { get; set; }
|
||||
public double[] testFieldDoubleArray { get; set; }
|
||||
public float[] testFieldFloatArray { get; set; }
|
||||
public decimal[] testFieldDecimalArray { get; set; }
|
||||
public TimeSpan[] testFieldTimeSpanArray { get; set; }
|
||||
public DateTime[] testFieldDateTimeArray { get; set; }
|
||||
public byte[][] testFieldBytesArray { get; set; }
|
||||
public string[] testFieldStringArray { get; set; }
|
||||
public Guid[] testFieldGuidArray { get; set; }
|
||||
public KdbndpPoint[] testFieldKdbndpPointArray { get; set; }
|
||||
public KdbndpLine[] testFieldKdbndpLineArray { get; set; }
|
||||
public KdbndpLSeg[] testFieldKdbndpLSegArray { get; set; }
|
||||
public KdbndpBox[] testFieldKdbndpBoxArray { get; set; }
|
||||
public KdbndpPath[] testFieldKdbndpPathArray { get; set; }
|
||||
public KdbndpPolygon[] testFieldKdbndpPolygonArray { get; set; }
|
||||
public KdbndpCircle[] testFieldKdbndpCircleArray { get; set; }
|
||||
public (IPAddress Address, int Subnet)[] testFieldCidrArray { get; set; }
|
||||
public KdbndpRange<int>[] testFieldInt4rangeArray { get; set; }
|
||||
public KdbndpRange<long>[] testFieldInt8rangeArray { get; set; }
|
||||
public KdbndpRange<decimal>[] testFieldNumrangeArray { get; set; }
|
||||
public KdbndpRange<DateTime>[] testFieldTsrangeArray { get; set; }
|
||||
|
||||
public bool?[] testFieldBoolArrayNullable { get; set; }
|
||||
public sbyte?[] testFieldSByteArrayNullable { get; set; }
|
||||
public short?[] testFieldShortArrayNullable { get; set; }
|
||||
public int?[] testFieldIntArrayNullable { get; set; }
|
||||
public long?[] testFielLongArrayNullable { get; set; }
|
||||
public byte?[] testFieldByteArrayNullable { get; set; }
|
||||
public ushort?[] testFieldUShortArrayNullable { get; set; }
|
||||
public uint?[] testFieldUIntArrayNullable { get; set; }
|
||||
public ulong?[] testFieldULongArrayNullable { get; set; }
|
||||
public double?[] testFieldDoubleArrayNullable { get; set; }
|
||||
public float?[] testFieldFloatArrayNullable { get; set; }
|
||||
public decimal?[] testFieldDecimalArrayNullable { get; set; }
|
||||
public TimeSpan?[] testFieldTimeSpanArrayNullable { get; set; }
|
||||
public DateTime?[] testFieldDateTimeArrayNullable { get; set; }
|
||||
public Guid?[] testFieldGuidArrayNullable { get; set; }
|
||||
public KdbndpPoint?[] testFieldKdbndpPointArrayNullable { get; set; }
|
||||
public KdbndpLine?[] testFieldKdbndpLineArrayNullable { get; set; }
|
||||
public KdbndpLSeg?[] testFieldKdbndpLSegArrayNullable { get; set; }
|
||||
public KdbndpBox?[] testFieldKdbndpBoxArrayNullable { get; set; }
|
||||
public KdbndpPath?[] testFieldKdbndpPathArrayNullable { get; set; }
|
||||
public KdbndpPolygon?[] testFieldKdbndpPolygonArrayNullable { get; set; }
|
||||
public KdbndpCircle?[] testFieldKdbndpCircleArrayNullable { get; set; }
|
||||
public (IPAddress Address, int Subnet)?[] testFieldCidrArrayNullable { get; set; }
|
||||
public KdbndpRange<int>?[] testFieldInt4rangeArrayNullable { get; set; }
|
||||
public KdbndpRange<long>?[] testFieldInt8rangeArrayNullable { get; set; }
|
||||
public KdbndpRange<decimal>?[] testFieldNumrangeArrayNullable { get; set; }
|
||||
public KdbndpRange<DateTime>?[] testFieldTsrangeArrayNullable { get; set; }
|
||||
|
||||
public BitArray[] testFieldBitArrayArray { get; set; }
|
||||
public IPAddress[] testFieldInetArray { get; set; }
|
||||
public PhysicalAddress[] testFieldMacaddrArray { get; set; }
|
||||
public JToken[] testFieldJTokenArray { get; set; }
|
||||
public JObject[] testFieldJObjectArray { get; set; }
|
||||
public JArray[] testFieldJArrayArray { get; set; }
|
||||
//public Dictionary<string, string>[] testFieldHStoreArray { get; set; }
|
||||
|
||||
public TableAllTypeEnumType1[] testFieldEnum1Array { get; set; }
|
||||
public TableAllTypeEnumType1?[] testFieldEnum1ArrayNullable { get; set; }
|
||||
public TableAllTypeEnumType2[] testFieldEnum2Array { get; set; }
|
||||
public TableAllTypeEnumType2?[] testFieldEnum2ArrayNullable { get; set; }
|
||||
}
|
||||
|
||||
public enum TableAllTypeEnumType1 { e1, e2, e3, e5 }
|
||||
|
@ -158,7 +158,7 @@ public class g
|
||||
public static IFreeSql shentong => shentongLazy.Value;
|
||||
|
||||
static Lazy<IFreeSql> kingbaseESLazy = new Lazy<IFreeSql>(() => new FreeSql.FreeSqlBuilder()
|
||||
.UseConnectionString(FreeSql.DataType.KingbaseES, "Server=121.36.59.173;Port=54321;UID=system;PWD=abc.123;database=test;max pool size=4")
|
||||
.UseConnectionString(FreeSql.DataType.KingbaseES, "Server=123.57.239.39;Port=54322;UID=system;PWD=123456;database=test;max pool size=4")
|
||||
//.UseConnectionFactory(FreeSql.DataType.KingbaseES, () => new Kdbndp.KdbndpConnection("Server=127.0.0.1;Port=54321;UID=USER2;PWD=123456789;database=TDB2"))
|
||||
.UseAutoSyncStructure(true)
|
||||
.UseLazyLoading(true)
|
||||
|
1432
FreeSql/FreeSql.xml
1432
FreeSql/FreeSql.xml
File diff suppressed because it is too large
Load Diff
@ -84,14 +84,9 @@ namespace FreeSql.Custom.PostgreSQL
|
||||
var sb = new StringBuilder();
|
||||
var seqcols = new List<NativeTuple<ColumnInfo, string[], bool>>(); //序列
|
||||
|
||||
var isPg95 = true;
|
||||
var isPg96 = true;
|
||||
var isPg10 = (_orm.DbFirst as CustomPostgreSQLDbFirst).IsPg10;
|
||||
using (var conn = _orm.Ado.MasterPool.Get(TimeSpan.FromSeconds(5)))
|
||||
{
|
||||
isPg95 = CustomPostgreSQLDbFirst.ParsePgVersion(conn.Value.ServerVersion, 9, 5).Item1;
|
||||
isPg96 = CustomPostgreSQLDbFirst.ParsePgVersion(conn.Value.ServerVersion, 9, 6).Item1;
|
||||
}
|
||||
var isPg95 = (_orm.DbFirst as CustomPostgreSQLDbFirst).IsPg95;
|
||||
var isPg96 = (_orm.DbFirst as CustomPostgreSQLDbFirst).IsPg96;
|
||||
|
||||
foreach (var obj in objects)
|
||||
{
|
||||
|
@ -23,6 +23,8 @@ namespace FreeSql.Custom.PostgreSQL
|
||||
}
|
||||
|
||||
public bool IsPg10 => ServerVersion >= 10;
|
||||
public bool IsPg95 { get; private set; }
|
||||
public bool IsPg96 { get; private set; }
|
||||
public int ServerVersion
|
||||
{
|
||||
get
|
||||
@ -33,6 +35,8 @@ namespace FreeSql.Custom.PostgreSQL
|
||||
try
|
||||
{
|
||||
_ServerVersionValue = ParsePgVersion(conn.Value.ServerVersion, 10, 0).Item2;
|
||||
IsPg95 = ParsePgVersion(conn.Value.ServerVersion, 9, 5).Item1;
|
||||
IsPg96 = ParsePgVersion(conn.Value.ServerVersion, 9, 6).Item1;
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
@ -247,8 +247,9 @@ t.typname,
|
||||
case when a.atttypmod > 0 and a.atttypmod < 32767 then a.atttypmod - 4 else a.attlen end len,
|
||||
case when t.typelem > 0 and t.typinput::varchar = 'ARRAY_IN' then t2.typname else t.typname end,
|
||||
case when a.attnotnull then '0' else '1' end as is_nullable,
|
||||
--e.adsrc,
|
||||
(select {pg_}get_expr(adbin, adrelid) from {pg_}attrdef where adrelid = e.adrelid limit 1) is_identity,
|
||||
--e.adsrc as is_identity, pg12以下
|
||||
--case when a.attidentity = 'd' the(select {pg_}get_expr(adbin, adrelid) from {pg_}attrdef where adrelid = e.adrelid limit 1) is_identity, pg10以下
|
||||
case when a.attidentity = 'd' then '1' else '0' end is_identity,
|
||||
a.attndims,
|
||||
d.description as comment
|
||||
from {pg_}class c
|
||||
@ -284,7 +285,8 @@ where ns.nspname = {{0}} and c.relname = {{1}}", tboldname ?? tbname);
|
||||
sqlType = string.Concat(sqlType),
|
||||
max_length = long.Parse(string.Concat(a[2])),
|
||||
is_nullable = string.Concat(a[4]) == "1",
|
||||
is_identity = string.Concat(a[5]).StartsWith(@"NEXTVAL('") && (string.Concat(a[5]).EndsWith(@"'::REGCLASS)") || string.Concat(a[5]).EndsWith(@"')")),
|
||||
is_identity = string.Concat(a[5]) == "1", //pg10+
|
||||
//is_identity = string.Concat(a[5]).StartsWith(@"NEXTVAL('") && (string.Concat(a[5]).EndsWith(@"'::REGCLASS)") || string.Concat(a[5]).EndsWith(@"')")),
|
||||
attndims,
|
||||
comment = string.Concat(a[7])
|
||||
};
|
||||
|
@ -355,7 +355,8 @@ case when a.atttypmod > 0 and a.atttypmod < 32767 then a.atttypmod - 4 else a.at
|
||||
case when t.typelem = 0 then t.typname else t2.typname end,
|
||||
case when a.attnotnull then 0 else 1 end as is_nullable,
|
||||
--e.adsrc as is_identity, pg12以下
|
||||
(select {pg_}get_expr(adbin, adrelid) from {pg_}attrdef where adrelid = e.adrelid and adnum = e.adnum limit 1) is_identity,
|
||||
--(select {pg_}get_expr(adbin, adrelid) from {pg_}attrdef where adrelid = e.adrelid and adnum = e.adnum limit 1) is_identity, pg10以下
|
||||
case when a.attidentity = 'd' then '1' else '0' end is_identity,
|
||||
d.description as comment,
|
||||
a.attndims,
|
||||
case when t.typelem = 0 then t.typtype else t2.typtype end,
|
||||
@ -381,7 +382,8 @@ where {loc8.ToString().Replace("a.table_name", "ns.nspname || '.' || c.relname")
|
||||
var max_length = int.Parse(string.Concat(row[3]));
|
||||
var sqlType = string.Concat(row[4]);
|
||||
var is_nullable = string.Concat(row[5]) == "1";
|
||||
var is_identity = string.Concat(row[6]).StartsWith(@"NEXTVAL('") && (string.Concat(row[6]).EndsWith(@"'::REGCLASS)") || string.Concat(row[6]).EndsWith(@"')"));
|
||||
var is_identity = string.Concat(row[6]) == "1"; //pg10+
|
||||
//var is_identity = string.Concat(row[6]).StartsWith(@"NEXTVAL('") && (string.Concat(row[6]).EndsWith(@"'::REGCLASS)") || string.Concat(row[6]).EndsWith(@"')"));
|
||||
var comment = string.Concat(row[7]);
|
||||
var defaultValue = string.Concat(row[6]);
|
||||
int attndims = int.Parse(string.Concat(row[8]));
|
||||
@ -635,5 +637,24 @@ where a.typtype = 'e' and ns.nspname in (SELECT schema_name FROM information_sch
|
||||
}
|
||||
return ret.Select(a => new DbEnumInfo { Name = a.Key, Labels = a.Value }).ToList();
|
||||
}
|
||||
|
||||
public static NativeTuple<bool, int, int> ParsePgVersion(string versionString, int v1, int v2)
|
||||
{
|
||||
int[] version = new int[] { 0, 0 };
|
||||
var vmatch = Regex.Match(versionString, @"(\d+)\.(\d+)");
|
||||
if (vmatch.Success)
|
||||
{
|
||||
version[0] = int.Parse(vmatch.Groups[1].Value);
|
||||
version[1] = int.Parse(vmatch.Groups[2].Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
vmatch = Regex.Match(versionString, @"(\d+)");
|
||||
version[0] = int.Parse(vmatch.Groups[1].Value);
|
||||
}
|
||||
if (version[0] > v1) return NativeTuple.Create(true, version[0], version[1]);
|
||||
if (version[0] == v1 && version[1] >= v2) return NativeTuple.Create(true, version[0], version[1]);
|
||||
return NativeTuple.Create(false, version[0], version[1]);
|
||||
}
|
||||
}
|
||||
}
|
@ -85,14 +85,9 @@ namespace FreeSql.Odbc.PostgreSQL
|
||||
var sb = new StringBuilder();
|
||||
var seqcols = new List<NativeTuple<ColumnInfo, string[], bool>>(); //序列
|
||||
|
||||
var isPg95 = true;
|
||||
var isPg96 = true;
|
||||
var isPg10 = (_orm.DbFirst as OdbcPostgreSQLDbFirst).IsPg10;
|
||||
using (var conn = _orm.Ado.MasterPool.Get(TimeSpan.FromSeconds(5)))
|
||||
{
|
||||
isPg95 = OdbcPostgreSQLDbFirst.ParsePgVersion(conn.Value.ServerVersion, 9, 5).Item1;
|
||||
isPg96 = OdbcPostgreSQLDbFirst.ParsePgVersion(conn.Value.ServerVersion, 9, 6).Item1;
|
||||
}
|
||||
var isPg95 = (_orm.DbFirst as OdbcPostgreSQLDbFirst).IsPg95;
|
||||
var isPg96 = (_orm.DbFirst as OdbcPostgreSQLDbFirst).IsPg96;
|
||||
|
||||
foreach (var obj in objects)
|
||||
{
|
||||
|
@ -23,7 +23,10 @@ namespace FreeSql.Odbc.PostgreSQL
|
||||
_commonExpression = commonExpression;
|
||||
}
|
||||
|
||||
|
||||
public bool IsPg10 => ServerVersion >= 10;
|
||||
public bool IsPg95 { get; private set; }
|
||||
public bool IsPg96 { get; private set; }
|
||||
public int ServerVersion
|
||||
{
|
||||
get
|
||||
@ -34,6 +37,8 @@ namespace FreeSql.Odbc.PostgreSQL
|
||||
try
|
||||
{
|
||||
_ServerVersionValue = ParsePgVersion(conn.Value.ServerVersion, 10, 0).Item2;
|
||||
IsPg95 = ParsePgVersion(conn.Value.ServerVersion, 9, 5).Item1;
|
||||
IsPg96 = ParsePgVersion(conn.Value.ServerVersion, 9, 6).Item1;
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
@ -140,14 +140,9 @@ namespace FreeSql.PostgreSQL
|
||||
var sb = new StringBuilder();
|
||||
var seqcols = new List<NativeTuple<ColumnInfo, string[], bool>>(); //序列
|
||||
|
||||
var isPg95 = true;
|
||||
var isPg96 = true;
|
||||
var isPg10 = (_orm.DbFirst as PostgreSQLDbFirst).IsPg10;
|
||||
using (var conn = _orm.Ado.MasterPool.Get(TimeSpan.FromSeconds(5)))
|
||||
{
|
||||
isPg95 = PostgreSQLDbFirst.ParsePgVersion(conn.Value.ServerVersion, 9, 5).Item1;
|
||||
isPg96 = PostgreSQLDbFirst.ParsePgVersion(conn.Value.ServerVersion, 9, 6).Item1;
|
||||
}
|
||||
var isPg95 = (_orm.DbFirst as PostgreSQLDbFirst).IsPg95;
|
||||
var isPg96 = (_orm.DbFirst as PostgreSQLDbFirst).IsPg96;
|
||||
|
||||
foreach (var obj in objects)
|
||||
{
|
||||
|
@ -29,6 +29,8 @@ namespace FreeSql.PostgreSQL
|
||||
}
|
||||
|
||||
public bool IsPg10 => ServerVersion >= 10;
|
||||
public bool IsPg95 { get; private set; }
|
||||
public bool IsPg96 { get; private set; }
|
||||
public int ServerVersion
|
||||
{
|
||||
get
|
||||
@ -39,6 +41,8 @@ namespace FreeSql.PostgreSQL
|
||||
try
|
||||
{
|
||||
_ServerVersionValue = ParsePgVersion(conn.Value.ServerVersion, 10, 0).Item2;
|
||||
IsPg95 = ParsePgVersion(conn.Value.ServerVersion, 9, 5).Item1;
|
||||
IsPg96 = ParsePgVersion(conn.Value.ServerVersion, 9, 6).Item1;
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user