mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-22 10:42:52 +08:00
修改ClickHouse数据类型错误
This commit is contained in:
parent
d085acc4e9
commit
c22d8d74d2
@ -11,13 +11,31 @@ namespace FreeSql.Tests.MySql
|
|||||||
|
|
||||||
class TestAuditValue
|
class TestAuditValue
|
||||||
{
|
{
|
||||||
public Guid id { get; set; }
|
[FreeSql.DataAnnotations.Column(IsPrimary = true)]
|
||||||
|
public long Id { get; set; }
|
||||||
[Now]
|
[Now]
|
||||||
public DateTime createtime { get; set; }
|
public DateTime CreateTime { get; set; }
|
||||||
|
|
||||||
|
[FreeSql.DataAnnotations.Column(IsNullable = true )]
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
[FreeSql.DataAnnotations.Column(IsNullable = false)]
|
||||||
|
public int Age { get; set; }
|
||||||
|
|
||||||
|
public bool State { get; set; }
|
||||||
|
|
||||||
|
[FreeSql.DataAnnotations.Column(IsNullable = true)]
|
||||||
|
public bool Enable { get; set; }
|
||||||
|
|
||||||
|
public DateTime? UpdateTime { get; set; }
|
||||||
|
|
||||||
|
public int? Points { get; set; }
|
||||||
}
|
}
|
||||||
[FreeSql.DataAnnotations.Table(Name = "ClickHouseTest")]
|
[FreeSql.DataAnnotations.Table(Name = "ClickHouseTest")]
|
||||||
public class TestClickHouse
|
public class TestClickHouse
|
||||||
{
|
{
|
||||||
|
[FreeSql.DataAnnotations.Column(IsPrimary = true)]
|
||||||
|
[Now]
|
||||||
public long Id { get; set; }
|
public long Id { get; set; }
|
||||||
|
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
@ -27,21 +45,29 @@ namespace FreeSql.Tests.MySql
|
|||||||
[Fact]
|
[Fact]
|
||||||
public void AuditValue()
|
public void AuditValue()
|
||||||
{
|
{
|
||||||
var date = DateTime.Now.Date;
|
var id = BitConverter.ToInt64(Guid.NewGuid().ToByteArray(), 0);
|
||||||
var item = new TestAuditValue();
|
var item = new TestClickHouse();
|
||||||
|
item.Id = id;
|
||||||
|
item.Name = "李四";
|
||||||
EventHandler<Aop.AuditValueEventArgs> audit = (s, e) =>
|
EventHandler<Aop.AuditValueEventArgs> audit = (s, e) =>
|
||||||
{
|
{
|
||||||
if (e.Property.GetCustomAttribute<NowAttribute>(false) != null)
|
if (e.Property.GetCustomAttribute<NowAttribute>(false) != null)
|
||||||
e.Value = DateTime.Now.Date;
|
e.Value = BitConverter.ToInt64(Guid.NewGuid().ToByteArray(), 0);
|
||||||
};
|
};
|
||||||
g.mysql.Aop.AuditValue += audit;
|
g.clickHouse.Aop.AuditValue += audit;
|
||||||
|
|
||||||
g.mysql.Insert(item).ExecuteAffrows();
|
g.clickHouse.Insert(item).ExecuteAffrows();
|
||||||
|
|
||||||
g.mysql.Aop.AuditValue -= audit;
|
g.clickHouse.Aop.AuditValue -= audit;
|
||||||
|
|
||||||
Assert.Equal(item.createtime, date);
|
Assert.Equal(item.Id, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void CreateTalbe()
|
||||||
|
{
|
||||||
|
g.clickHouse.CodeFirst.SyncStructure<TestAuditValue>();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@ -61,6 +87,7 @@ namespace FreeSql.Tests.MySql
|
|||||||
var items = fsql.Select<TestClickHouse>().Where(o=>o.Id>900).OrderByDescending(o=>o.Id).ToList();
|
var items = fsql.Select<TestClickHouse>().Where(o=>o.Id>900).OrderByDescending(o=>o.Id).ToList();
|
||||||
Assert.Equal(100, items.Count);
|
Assert.Equal(100, items.Count);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void TestPage()
|
public void TestPage()
|
||||||
{
|
{
|
||||||
@ -72,6 +99,7 @@ namespace FreeSql.Tests.MySql
|
|||||||
.Count(out var count).ToList();
|
.Count(out var count).ToList();
|
||||||
Assert.Equal(100, list.Count);
|
Assert.Equal(100, list.Count);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void TestDelete()
|
public void TestDelete()
|
||||||
{
|
{
|
||||||
@ -81,6 +109,7 @@ namespace FreeSql.Tests.MySql
|
|||||||
var count2 = fsql.Select<TestClickHouse>().Count();
|
var count2 = fsql.Select<TestClickHouse>().Count();
|
||||||
Assert.NotEqual(count1, count2);
|
Assert.NotEqual(count1, count2);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void TestUpdate()
|
public void TestUpdate()
|
||||||
{
|
{
|
||||||
@ -91,5 +120,71 @@ namespace FreeSql.Tests.MySql
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void TestRepositorySelect()
|
||||||
|
{
|
||||||
|
var fsql = g.clickHouse;
|
||||||
|
var list=fsql.GetRepository<TestClickHouse>().Where(o => o.Id > 900)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void TestRepositoryInsert()
|
||||||
|
{
|
||||||
|
var fsql = g.clickHouse;
|
||||||
|
long id = BitConverter.ToInt64(Guid.NewGuid().ToByteArray(),0);
|
||||||
|
var list=fsql.GetRepository<TestClickHouse>().Insert(new TestClickHouse { Id= id, Name="张三"});
|
||||||
|
var data=fsql.GetRepository<TestClickHouse,long>().Get(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void TestDateTime()
|
||||||
|
{
|
||||||
|
var fsql = g.clickHouse;
|
||||||
|
long id = BitConverter.ToInt64(Guid.NewGuid().ToByteArray(), 0);
|
||||||
|
DateTime createTime=DateTime.Now;
|
||||||
|
fsql.Insert(new TestAuditValue {
|
||||||
|
Id = id, CreateTime = createTime, Age =18,Name="张三"
|
||||||
|
}).ExecuteAffrows();
|
||||||
|
|
||||||
|
var date1 = fsql.GetRepository<TestAuditValue>().Where(o => o.CreateTime == createTime)
|
||||||
|
.ToList();
|
||||||
|
var date2 = fsql.GetRepository<TestAuditValue>().Where(o => o.CreateTime.Date == createTime.Date)
|
||||||
|
.ToList();
|
||||||
|
var date3 = fsql.GetRepository<TestAuditValue>().Where(o => o.CreateTime.Year == createTime.Year)
|
||||||
|
.ToList();
|
||||||
|
var date4 = fsql.GetRepository<TestAuditValue>().Where(o => o.CreateTime.Month == createTime.Month)
|
||||||
|
.ToList();
|
||||||
|
var date5 = fsql.GetRepository<TestAuditValue>().Where(o => o.CreateTime.Second == createTime.Second)
|
||||||
|
.ToList();
|
||||||
|
var date6 = fsql.GetRepository<TestAuditValue>().Where(o => o.CreateTime.Millisecond == createTime.Millisecond)
|
||||||
|
.ToList();
|
||||||
|
var date7 = fsql.GetRepository<TestAuditValue>().Where(o => o.CreateTime.AddSeconds(10) < createTime)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void TestRepositoryUpdateTime()
|
||||||
|
{
|
||||||
|
//暂时无法修改
|
||||||
|
var fsql = g.clickHouse;
|
||||||
|
var repository=fsql.GetRepository<TestAuditValue>();
|
||||||
|
var list = repository.Select.ToList();
|
||||||
|
list.ForEach(o=>o.UpdateTime = DateTime.Now);
|
||||||
|
repository.Update(list);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void TestUpdateTime()
|
||||||
|
{
|
||||||
|
var fsql = g.clickHouse;
|
||||||
|
var state=fsql.GetRepository<TestAuditValue>().UpdateDiy.Set(o=>o.UpdateTime,DateTime.Now).Where(o=>1==1).ExecuteAffrows();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ public class g
|
|||||||
//.UseAutoSyncStructure(true)
|
//.UseAutoSyncStructure(true)
|
||||||
//.UseGenerateCommandParameterWithLambda(true)
|
//.UseGenerateCommandParameterWithLambda(true)
|
||||||
.UseMonitorCommand(
|
.UseMonitorCommand(
|
||||||
cmd => Trace.WriteLine("\r\n线程" + Thread.CurrentThread.ManagedThreadId + ": " + cmd.CommandText) //监听SQL命令对象,在执行前
|
cmd => Debug.WriteLine("\r\n线程" + Thread.CurrentThread.ManagedThreadId + ": " + cmd.CommandText) //监听SQL命令对象,在执行前
|
||||||
//, (cmd, traceLog) => Console.WriteLine(traceLog)
|
//, (cmd, traceLog) => Console.WriteLine(traceLog)
|
||||||
)
|
)
|
||||||
.UseLazyLoading(true)
|
.UseLazyLoading(true)
|
||||||
|
@ -118,7 +118,7 @@ namespace FreeSql.Internal
|
|||||||
var leftBt = colattr.DbType.IndexOf('(');
|
var leftBt = colattr.DbType.IndexOf('(');
|
||||||
colattr.DbType = colattr.DbType.Substring(0, leftBt).ToUpper() + colattr.DbType.Substring(leftBt);
|
colattr.DbType = colattr.DbType.Substring(0, leftBt).ToUpper() + colattr.DbType.Substring(leftBt);
|
||||||
}
|
}
|
||||||
else
|
else if(common._orm.Ado.DataType != DataType.ClickHouse)
|
||||||
colattr.DbType = colattr.DbType.ToUpper();
|
colattr.DbType = colattr.DbType.ToUpper();
|
||||||
|
|
||||||
if (colattrIsNull == false && colattrIsNullable == true) colattr.DbType = colattr.DbType.Replace("NOT NULL", "");
|
if (colattrIsNull == false && colattrIsNullable == true) colattr.DbType = colattr.DbType.Replace("NOT NULL", "");
|
||||||
@ -129,12 +129,13 @@ namespace FreeSql.Internal
|
|||||||
if (common.CodeFirst.IsSyncStructureToLower) colattr.Name = colattr.Name.ToLower();
|
if (common.CodeFirst.IsSyncStructureToLower) colattr.Name = colattr.Name.ToLower();
|
||||||
if (common.CodeFirst.IsSyncStructureToUpper) colattr.Name = colattr.Name.ToUpper();
|
if (common.CodeFirst.IsSyncStructureToUpper) colattr.Name = colattr.Name.ToUpper();
|
||||||
|
|
||||||
if ((colattr.IsNullable != true || colattr.IsIdentity == true || colattr.IsPrimary == true) && colattr.DbType.Contains("NOT NULL") == false)
|
if ((colattr.IsNullable != true || colattr.IsIdentity == true || colattr.IsPrimary == true) && colattr.DbType.Contains("NOT NULL") == false && common._orm.Ado.DataType != DataType.ClickHouse)
|
||||||
{
|
{
|
||||||
colattr.IsNullable = false;
|
colattr.IsNullable = false;
|
||||||
colattr.DbType = Regex.Replace(colattr.DbType, @"\bNULL\b", "").Trim() + " NOT NULL";
|
colattr.DbType = Regex.Replace(colattr.DbType, @"\bNULL\b", "").Trim() + " NOT NULL";
|
||||||
}
|
}
|
||||||
if (colattr.IsNullable == true && colattr.DbType.Contains("NOT NULL")) colattr.DbType = colattr.DbType.Replace("NOT NULL", "");
|
if (colattr.IsNullable == true && colattr.DbType.Contains("NOT NULL")) colattr.DbType = colattr.DbType.Replace("NOT NULL", "");
|
||||||
|
else if (colattr.IsNullable == true && !colattr.DbType.Contains("Nullable") && common._orm.Ado.DataType == DataType.ClickHouse)colattr.DbType = $"Nullable({colattr.DbType})" ;
|
||||||
colattr.DbType = Regex.Replace(colattr.DbType, @"\([^\)]+\)", m =>
|
colattr.DbType = Regex.Replace(colattr.DbType, @"\([^\)]+\)", m =>
|
||||||
{
|
{
|
||||||
var tmpLt = Regex.Replace(m.Groups[0].Value, @"\s", "");
|
var tmpLt = Regex.Replace(m.Groups[0].Value, @"\s", "");
|
||||||
|
@ -14,7 +14,7 @@ namespace FreeSql.ClickHouse
|
|||||||
{
|
{
|
||||||
|
|
||||||
public ClickHouseAdo() : base(DataType.ClickHouse, null, null) { }
|
public ClickHouseAdo() : base(DataType.ClickHouse, null, null) { }
|
||||||
public ClickHouseAdo(CommonUtils util, string masterConnectionString, string[] slaveConnectionStrings, Func<DbConnection> connectionFactory) : base(DataType.MySql, masterConnectionString, slaveConnectionStrings)
|
public ClickHouseAdo(CommonUtils util, string masterConnectionString, string[] slaveConnectionStrings, Func<DbConnection> connectionFactory) : base(DataType.ClickHouse, masterConnectionString, slaveConnectionStrings)
|
||||||
{
|
{
|
||||||
base._util = util;
|
base._util = util;
|
||||||
if (connectionFactory != null)
|
if (connectionFactory != null)
|
||||||
@ -50,7 +50,7 @@ namespace FreeSql.ClickHouse
|
|||||||
else if (decimal.TryParse(string.Concat(param), out var trydec))
|
else if (decimal.TryParse(string.Concat(param), out var trydec))
|
||||||
return param;
|
return param;
|
||||||
else if (param is DateTime || param is DateTime?)
|
else if (param is DateTime || param is DateTime?)
|
||||||
return string.Concat("'", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss.fff"), "'");
|
return string.Concat("'", ((DateTime)param).ToString("yyyy-MM-dd HH:mm:ss"), "'");
|
||||||
else if (param is TimeSpan || param is TimeSpan?)
|
else if (param is TimeSpan || param is TimeSpan?)
|
||||||
return ((TimeSpan)param).Ticks / 10;
|
return ((TimeSpan)param).Ticks / 10;
|
||||||
else if (param is byte[])
|
else if (param is byte[])
|
||||||
|
@ -84,17 +84,17 @@ namespace FreeSql.ClickHouse
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string.Compare(tbname[0], database, true) != 0 && LocalExecuteScalar(database, _commonUtils.FormatSql(" select 1 from information_schema.schemata where schema_name={0}", tbname[0])) == null) //创建数据库
|
if (string.Compare(tbname[0], database, true) != 0 && LocalExecuteScalar(database, _commonUtils.FormatSql(" select 1 from system.databases d where name={0}", tbname[0])) == null) //创建数据库
|
||||||
sb.Append($"CREATE DATABASE IF NOT EXISTS ").Append(_commonUtils.QuoteSqlName(tbname[0])).Append(" default charset utf8 COLLATE utf8_general_ci;\r\n");
|
sb.Append($"CREATE DATABASE IF NOT EXISTS ").Append(_commonUtils.QuoteSqlName(tbname[0])).Append(" ENGINE=Ordinary;\r\n");
|
||||||
|
|
||||||
var sbalter = new StringBuilder();
|
var sbalter = new StringBuilder();
|
||||||
var istmpatler = false; //创建临时表,导入数据,删除旧表,修改
|
var istmpatler = false; //创建临时表,导入数据,删除旧表,修改
|
||||||
if (LocalExecuteScalar(tbname[0], _commonUtils.FormatSql(" SELECT 1 FROM information_schema.TABLES WHERE table_schema={0} and table_name={1}", tbname)) == null)
|
if (LocalExecuteScalar(tbname[0], _commonUtils.FormatSql(" SELECT 1 FROM system.tables t WHERE database ={0} and name ={1}", tbname)) == null)
|
||||||
{ //表不存在
|
{ //表不存在
|
||||||
if (tboldname != null)
|
if (tboldname != null)
|
||||||
{
|
{
|
||||||
if (string.Compare(tboldname[0], tbname[0], true) != 0 && LocalExecuteScalar(database, _commonUtils.FormatSql(" select 1 from information_schema.schemata where schema_name={0}", tboldname[0])) == null ||
|
if (string.Compare(tboldname[0], tbname[0], true) != 0 && LocalExecuteScalar(database, _commonUtils.FormatSql(" select 1 from system.databases where name={0}", tboldname[0])) == null ||
|
||||||
LocalExecuteScalar(tboldname[0], _commonUtils.FormatSql(" SELECT 1 FROM information_schema.TABLES WHERE table_schema={0} and table_name={1}", tboldname)) == null)
|
LocalExecuteScalar(tboldname[0], _commonUtils.FormatSql(" SELECT 1 FROM system.tables WHERE database={0} and name={1}", tboldname)) == null)
|
||||||
//数据库或表不存在
|
//数据库或表不存在
|
||||||
tboldname = null;
|
tboldname = null;
|
||||||
}
|
}
|
||||||
@ -105,36 +105,43 @@ namespace FreeSql.ClickHouse
|
|||||||
sb.Append("CREATE TABLE IF NOT EXISTS ").Append(createTableName).Append(" ( ");
|
sb.Append("CREATE TABLE IF NOT EXISTS ").Append(createTableName).Append(" ( ");
|
||||||
foreach (var tbcol in tb.ColumnsByPosition)
|
foreach (var tbcol in tb.ColumnsByPosition)
|
||||||
{
|
{
|
||||||
|
tbcol.Attribute.DbType = tbcol.Attribute.DbType.Replace(" NOT NULL", "");
|
||||||
sb.Append(" \r\n ").Append(_commonUtils.QuoteSqlName(tbcol.Attribute.Name)).Append(" ").Append(tbcol.Attribute.DbType);
|
sb.Append(" \r\n ").Append(_commonUtils.QuoteSqlName(tbcol.Attribute.Name)).Append(" ").Append(tbcol.Attribute.DbType);
|
||||||
if (tbcol.Attribute.IsIdentity == true && tbcol.Attribute.DbType.IndexOf("AUTO_INCREMENT", StringComparison.CurrentCultureIgnoreCase) == -1) sb.Append(" AUTO_INCREMENT");
|
|
||||||
if (string.IsNullOrEmpty(tbcol.Comment) == false) sb.Append(" COMMENT ").Append(_commonUtils.FormatSql("{0}", tbcol.Comment));
|
if (string.IsNullOrEmpty(tbcol.Comment) == false) sb.Append(" COMMENT ").Append(_commonUtils.FormatSql("{0}", tbcol.Comment));
|
||||||
sb.Append(",");
|
sb.Append(",");
|
||||||
}
|
}
|
||||||
if (tb.Primarys.Any())
|
|
||||||
{
|
|
||||||
sb.Append(" \r\n PRIMARY KEY (");
|
|
||||||
foreach (var tbcol in tb.Primarys) sb.Append(_commonUtils.QuoteSqlName(tbcol.Attribute.Name)).Append(", ");
|
|
||||||
sb.Remove(sb.Length - 2, 2).Append("),");
|
|
||||||
}
|
|
||||||
//创建表的索引,感谢 @mafeng8,这样写可以支持自增不是主键的情况
|
|
||||||
foreach (var uk in tb.Indexes)
|
foreach (var uk in tb.Indexes)
|
||||||
{
|
{
|
||||||
sb.Append(" \r\n ");
|
sb.Append(" \r\n ");
|
||||||
if (uk.IsUnique) sb.Append("UNIQUE ");
|
|
||||||
sb.Append("INDEX ").Append(_commonUtils.QuoteSqlName(ReplaceIndexName(uk.Name, tbname[1]))).Append("(");
|
sb.Append("INDEX ").Append(_commonUtils.QuoteSqlName(ReplaceIndexName(uk.Name, tbname[1]))).Append("(");
|
||||||
foreach (var tbcol in uk.Columns)
|
foreach (var tbcol in uk.Columns)
|
||||||
{
|
{
|
||||||
sb.Append(_commonUtils.QuoteSqlName(tbcol.Column.Attribute.Name));
|
sb.Append(_commonUtils.QuoteSqlName(tbcol.Column.Attribute.Name));
|
||||||
if (tbcol.IsDesc) sb.Append(" DESC");
|
sb.Append("TYPE set(8192) GRANULARITY 5, ");
|
||||||
sb.Append(", ");
|
|
||||||
}
|
}
|
||||||
sb.Remove(sb.Length - 2, 2).Append("),");
|
sb.Remove(sb.Length - 2, 2).Append("),");
|
||||||
}
|
}
|
||||||
sb.Remove(sb.Length - 1, 1);
|
sb.Remove(sb.Length - 1, 1);
|
||||||
sb.Append("\r\n) Engine=InnoDB");
|
sb.Append("\r\n) ");
|
||||||
if (string.IsNullOrEmpty(tb.Comment) == false)
|
sb.Append("\r\nENGINE = MergeTree()");
|
||||||
sb.Append(" Comment=").Append(_commonUtils.FormatSql("{0}", tb.Comment));
|
|
||||||
sb.Append(";\r\n");
|
if (tb.Primarys.Any())
|
||||||
|
{
|
||||||
|
sb.Append(" \r\nORDER BY ( ");
|
||||||
|
var ls = new StringBuilder();
|
||||||
|
foreach (var tbcol in tb.Primarys) ls.Append(_commonUtils.QuoteSqlName(tbcol.Attribute.Name)).Append(", ");
|
||||||
|
sb.Append(ls);
|
||||||
|
sb.Remove(sb.Length - 2, 2);
|
||||||
|
sb.Append(" )");
|
||||||
|
sb.Append(" \r\nPRIMARY KEY ");
|
||||||
|
sb.Append(ls);
|
||||||
|
sb.Remove(sb.Length - 2, 2).Append(",");
|
||||||
|
}
|
||||||
|
sb.Remove(sb.Length - 1, 1);
|
||||||
|
//if (string.IsNullOrEmpty(tb.Comment) == false)
|
||||||
|
// sb.Append(" Comment=").Append(_commonUtils.FormatSql("{0}", tb.Comment));
|
||||||
|
sb.Append(" SETTINGS index_granularity = 8192;\r\n");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//如果新表,旧表在一个数据库下,直接修改表名
|
//如果新表,旧表在一个数据库下,直接修改表名
|
||||||
@ -152,122 +159,57 @@ namespace FreeSql.ClickHouse
|
|||||||
//对比字段,只可以修改类型、增加字段、有限的修改字段名;保证安全不删除字段
|
//对比字段,只可以修改类型、增加字段、有限的修改字段名;保证安全不删除字段
|
||||||
var sql = _commonUtils.FormatSql(@"
|
var sql = _commonUtils.FormatSql(@"
|
||||||
select
|
select
|
||||||
a.column_name,
|
a.name,
|
||||||
a.column_type,
|
a.type,
|
||||||
case when a.is_nullable = 'YES' then 1 else 0 end 'is_nullable',
|
if(ilike(a.`type`, 'Nullable(%S%)'),'is_nullable','0'),
|
||||||
case when locate('auto_increment', a.extra) > 0 then 1 else 0 end 'is_identity',
|
a.comment as comment,
|
||||||
a.column_comment 'comment'
|
a.is_in_partition_key,
|
||||||
from information_schema.columns a
|
a.is_in_sorting_key,
|
||||||
where a.table_schema in ({0}) and a.table_name in ({1})", tboldname ?? tbname);
|
a.is_in_primary_key,
|
||||||
|
a.is_in_sampling_key
|
||||||
|
from system.columns a
|
||||||
|
where a.database in ({0}) and a.table in ({1})", tboldname ?? tbname);
|
||||||
var ds = _orm.Ado.ExecuteArray(CommandType.Text, sql);
|
var ds = _orm.Ado.ExecuteArray(CommandType.Text, sql);
|
||||||
var tbstruct = ds.ToDictionary(a => string.Concat(a[0]), a =>
|
var tbstruct = ds.ToDictionary(a => string.Concat(a[0]), a =>
|
||||||
{
|
{
|
||||||
var a1 = string.Concat(a[1]);
|
|
||||||
if (a1 == "datetime") a1 = string.Concat(a1, "(0)");
|
|
||||||
return new
|
return new
|
||||||
{
|
{
|
||||||
column = string.Concat(a[0]),
|
column = string.Concat(a[0]),
|
||||||
sqlType = a1,
|
sqlType = (string)a[1],
|
||||||
is_nullable = string.Concat(a[2]) == "1",
|
is_nullable = string.Concat(a[2]) == "1",
|
||||||
is_identity = string.Concat(a[3]) == "1",
|
is_identity = false,
|
||||||
is_unsigned = string.Concat(a[1]).EndsWith(" unsigned"),
|
comment = string.Concat(a[3]),
|
||||||
comment = string.Concat(a[4])
|
is_primary= string.Concat(a[6]) == "1",
|
||||||
};
|
};
|
||||||
}, StringComparer.CurrentCultureIgnoreCase);
|
}, StringComparer.CurrentCultureIgnoreCase);
|
||||||
|
|
||||||
if (istmpatler == false)
|
if (istmpatler == false)
|
||||||
{
|
{
|
||||||
var existsPrimary = LocalExecuteScalar(tbname[0], _commonUtils.FormatSql(" select 1 from information_schema.key_column_usage where table_schema={0} and table_name={1} and constraint_name = 'PRIMARY' limit 1", tbname));
|
var existsPrimary = tbstruct.Any(o => o.Value.is_primary);
|
||||||
foreach (var tbcol in tb.ColumnsByPosition)
|
foreach (var tbcol in tb.ColumnsByPosition)
|
||||||
{
|
{
|
||||||
if (tbstruct.TryGetValue(tbcol.Attribute.Name, out var tbstructcol) ||
|
if (tbstruct.TryGetValue(tbcol.Attribute.Name, out var tbstructcol) ||
|
||||||
string.IsNullOrEmpty(tbcol.Attribute.OldName) == false && tbstruct.TryGetValue(tbcol.Attribute.OldName, out tbstructcol))
|
string.IsNullOrEmpty(tbcol.Attribute.OldName) == false && tbstruct.TryGetValue(tbcol.Attribute.OldName, out tbstructcol))
|
||||||
{
|
{
|
||||||
var isCommentChanged = tbstructcol.comment != (tbcol.Comment ?? "");
|
var isCommentChanged = tbstructcol.comment != (tbcol.Comment ?? "");
|
||||||
var isDbTypeChanged = tbcol.Attribute.DbType.StartsWith(tbstructcol.sqlType, StringComparison.CurrentCultureIgnoreCase) == false;
|
if (tbcol.Attribute.DbType.StartsWith(tbstructcol.sqlType, StringComparison.CurrentCultureIgnoreCase) == false ||
|
||||||
if (tbstructcol.sqlType == "datetime(0)" && Regex.IsMatch(tbcol.Attribute.DbType, @"datetime\s*\(", RegexOptions.IgnoreCase) == false)
|
tbcol.Attribute.IsNullable != tbstructcol.is_nullable || isCommentChanged)
|
||||||
isDbTypeChanged = tbcol.Attribute.DbType.StartsWith("datetime", StringComparison.CurrentCultureIgnoreCase) == false;
|
sbalter.Append("ALTER TABLE ").Append(_commonUtils.QuoteSqlName($"{tbname[0]}.{tbname[1]}")).Append(" MODIFY COLUMN ").Append(_commonUtils.QuoteSqlName(tbstructcol.column)).Append(tbcol.Attribute.IsNullable ? $"Nullable({tbcol.Attribute.DbType.Split(' ').First()})":tbcol.Attribute.DbType.Split(' ').First()).Append(";\r\n");
|
||||||
else if (tbstructcol.sqlType.StartsWith("datetime", StringComparison.CurrentCultureIgnoreCase)) isDbTypeChanged = tbcol.Attribute.DbType.StartsWith("datetime", StringComparison.CurrentCultureIgnoreCase) == false ||
|
if(isCommentChanged) sbalter.Append("ALTER TABLE ").Append(_commonUtils.QuoteSqlName($"{tbname[0]}.{tbname[1]}")).Append(" COMMENT COLUMN ").Append(_commonUtils.QuoteSqlName(tbstructcol.column)).Append(_commonUtils.FormatSql("{0}", tbcol.Comment ?? "")).Append(";\r\n");
|
||||||
(int.TryParse(Regex.Match(tbcol.Attribute.DbType, @"datetime\s*\((\d*)", RegexOptions.IgnoreCase).Groups[1].Value, out var trydtrd) ? trydtrd : 3) !=
|
|
||||||
(int.TryParse(Regex.Match(tbstructcol.sqlType, @"datetime\s*\((\d*)", RegexOptions.IgnoreCase).Groups[1].Value, out var trydtrd2) ? trydtrd2 : 3);
|
|
||||||
else if (tbstructcol.sqlType.StartsWith("int", StringComparison.CurrentCultureIgnoreCase)) isDbTypeChanged = tbcol.Attribute.DbType.StartsWith("int", StringComparison.CurrentCultureIgnoreCase) == false;
|
|
||||||
else if (tbstructcol.sqlType.StartsWith("tinyint", StringComparison.CurrentCultureIgnoreCase)) isDbTypeChanged = tbcol.Attribute.DbType.StartsWith("tinyint", StringComparison.CurrentCultureIgnoreCase) == false;
|
|
||||||
else if (tbstructcol.sqlType.StartsWith("smallint", StringComparison.CurrentCultureIgnoreCase)) isDbTypeChanged = tbcol.Attribute.DbType.StartsWith("smallint", StringComparison.CurrentCultureIgnoreCase) == false;
|
|
||||||
else if (tbstructcol.sqlType.StartsWith("bigint", StringComparison.CurrentCultureIgnoreCase)) isDbTypeChanged = tbcol.Attribute.DbType.StartsWith("bigint", StringComparison.CurrentCultureIgnoreCase) == false;
|
|
||||||
|
|
||||||
if ((tbcol.Attribute.DbType.IndexOf(" unsigned", StringComparison.CurrentCultureIgnoreCase) != -1) != tbstructcol.is_unsigned ||
|
|
||||||
isDbTypeChanged ||
|
|
||||||
tbcol.Attribute.IsNullable != tbstructcol.is_nullable ||
|
|
||||||
tbcol.Attribute.IsIdentity != tbstructcol.is_identity ||
|
|
||||||
isCommentChanged)
|
|
||||||
{
|
|
||||||
if (tbcol.Attribute.IsNullable != tbstructcol.is_nullable && tbcol.Attribute.IsNullable == false && tbcol.DbDefaultValue != "NULL" && tbcol.Attribute.IsIdentity == false)
|
|
||||||
sbalter.Append("UPDATE ").Append(_commonUtils.QuoteSqlName(tbname[0], tbname[1])).Append(" SET ").Append(_commonUtils.QuoteSqlName(tbstructcol.column)).Append(" = ").Append(tbcol.DbDefaultValue).Append(" WHERE ").Append(_commonUtils.QuoteSqlName(tbstructcol.column)).Append(" IS NULL;\r\n");
|
|
||||||
sbalter.Append("ALTER TABLE ").Append(_commonUtils.QuoteSqlName(tbname[0], tbname[1])).Append(" MODIFY ").Append(_commonUtils.QuoteSqlName(tbstructcol.column)).Append(" ").Append(tbcol.Attribute.DbType);
|
|
||||||
if (string.IsNullOrEmpty(tbcol.Comment) == false) sbalter.Append(" COMMENT ").Append(_commonUtils.FormatSql("{0}", tbcol.Comment ?? ""));
|
|
||||||
if (tbcol.Attribute.IsIdentity == true && tbcol.Attribute.DbType.IndexOf("AUTO_INCREMENT", StringComparison.CurrentCultureIgnoreCase) == -1) sbalter.Append(" AUTO_INCREMENT");
|
|
||||||
if (tbcol.Attribute.IsIdentity == true) sbalter.Append(existsPrimary == null ? "" : ", DROP PRIMARY KEY").Append(", ADD PRIMARY KEY(").Append(_commonUtils.QuoteSqlName(tbcol.Attribute.Name)).Append(")");
|
|
||||||
sbalter.Append(";\r\n");
|
|
||||||
}
|
|
||||||
if (string.Compare(tbstructcol.column, tbcol.Attribute.OldName, true) == 0)
|
if (string.Compare(tbstructcol.column, tbcol.Attribute.OldName, true) == 0)
|
||||||
{
|
sbalter.Append("ALTER TABLE ").Append(_commonUtils.QuoteSqlName($"{tbname[0]}.{tbname[1]}")).Append(" COLUMN ").Append(_commonUtils.QuoteSqlName(tbstructcol.column)).Append(" TO ").Append(_commonUtils.QuoteSqlName(tbcol.Attribute.Name)).Append(";\r\n");
|
||||||
//修改列名
|
|
||||||
sbalter.Append("ALTER TABLE ").Append(_commonUtils.QuoteSqlName(tbname[0], tbname[1])).Append(" CHANGE COLUMN ").Append(_commonUtils.QuoteSqlName(tbstructcol.column)).Append(" ").Append(_commonUtils.QuoteSqlName(tbcol.Attribute.Name)).Append(" ").Append(tbcol.Attribute.DbType);
|
|
||||||
if (string.IsNullOrEmpty(tbcol.Comment) == false) sbalter.Append(" COMMENT ").Append(_commonUtils.FormatSql("{0}", tbcol.Comment ?? ""));
|
|
||||||
if (tbcol.Attribute.IsIdentity == true && tbcol.Attribute.DbType.IndexOf("AUTO_INCREMENT", StringComparison.CurrentCultureIgnoreCase) == -1) sbalter.Append(" AUTO_INCREMENT");
|
|
||||||
if (tbcol.Attribute.IsIdentity == true) sbalter.Append(existsPrimary == null ? "" : ", DROP PRIMARY KEY").Append(", ADD PRIMARY KEY(").Append(_commonUtils.QuoteSqlName(tbcol.Attribute.Name)).Append(")");
|
|
||||||
sbalter.Append(";\r\n");
|
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//添加列
|
//添加列
|
||||||
sbalter.Append("ALTER TABLE ").Append(_commonUtils.QuoteSqlName(tbname[0], tbname[1])).Append(" ADD ").Append(_commonUtils.QuoteSqlName(tbcol.Attribute.Name)).Append(" ").Append(tbcol.Attribute.DbType);
|
sbalter.Append("ALTER TABLE ").Append(_commonUtils.QuoteSqlName(tbname[0], tbname[1])).Append(" ADD ").Append(_commonUtils.QuoteSqlName(tbcol.Attribute.Name)).Append(" ").Append(tbcol.Attribute.DbType);
|
||||||
if (tbcol.Attribute.IsNullable == false && tbcol.DbDefaultValue != "NULL" && tbcol.Attribute.IsIdentity == false) sbalter.Append(" DEFAULT ").Append(tbcol.DbDefaultValue);
|
if (tbcol.Attribute.IsNullable == false && tbcol.DbDefaultValue != "NULL" && tbcol.Attribute.IsIdentity == false) sbalter.Append(" DEFAULT ").Append(tbcol.DbDefaultValue);
|
||||||
if (string.IsNullOrEmpty(tbcol.Comment) == false) sbalter.Append(" COMMENT ").Append(_commonUtils.FormatSql("{0}", tbcol.Comment ?? ""));
|
if (string.IsNullOrEmpty(tbcol.Comment) == false) sbalter.Append(" COMMENT ").Append(_commonUtils.FormatSql("{0}", tbcol.Comment ?? ""));
|
||||||
if (tbcol.Attribute.IsIdentity == true && tbcol.Attribute.DbType.IndexOf("AUTO_INCREMENT", StringComparison.CurrentCultureIgnoreCase) == -1) sbalter.Append(" AUTO_INCREMENT");
|
|
||||||
if (tbcol.Attribute.IsIdentity == true) sbalter.Append(existsPrimary == null ? "" : ", DROP PRIMARY KEY").Append(", ADD PRIMARY KEY(").Append(_commonUtils.QuoteSqlName(tbcol.Attribute.Name)).Append(")");
|
|
||||||
sbalter.Append(";\r\n");
|
sbalter.Append(";\r\n");
|
||||||
}
|
}
|
||||||
var dsuksql = _commonUtils.FormatSql(@"
|
|
||||||
select
|
|
||||||
a.column_name,
|
|
||||||
a.index_name 'index_id',
|
|
||||||
0 'IsDesc',
|
|
||||||
case when a.non_unique = 0 then 1 else 0 end 'IsUnique'
|
|
||||||
from information_schema.statistics a
|
|
||||||
where a.table_schema IN ({0}) and a.table_name IN ({1}) and a.index_name <> 'PRIMARY'", tboldname ?? tbname);
|
|
||||||
var dsuk = _orm.Ado.ExecuteArray(CommandType.Text, dsuksql).Select(a => new[] { string.Concat(a[0]), string.Concat(a[1]), string.Concat(a[2]), string.Concat(a[3]) });
|
|
||||||
foreach (var uk in tb.Indexes)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(uk.Name) || uk.Columns.Any() == false) continue;
|
|
||||||
var ukname = ReplaceIndexName(uk.Name, tbname[1]);
|
|
||||||
var dsukfind1 = dsuk.Where(a => string.Compare(a[1], ukname, true) == 0).ToArray();
|
|
||||||
if (dsukfind1.Any() == false || dsukfind1.Length != uk.Columns.Length || dsukfind1.Where(a => (a[3] == "1") == uk.IsUnique && uk.Columns.Where(b => string.Compare(b.Column.Attribute.Name, a[0], true) == 0 && (a[2] == "1") == b.IsDesc).Any()).Count() != uk.Columns.Length)
|
|
||||||
{
|
|
||||||
if (dsukfind1.Any()) sbalter.Append("DROP INDEX ").Append(_commonUtils.QuoteSqlName(ukname)).Append(" ON ").Append(_commonUtils.QuoteSqlName(tbname[0], tbname[1])).Append(";\r\n");
|
|
||||||
sbalter.Append("CREATE ");
|
|
||||||
if (uk.IsUnique) sbalter.Append("UNIQUE ");
|
|
||||||
sbalter.Append("INDEX ").Append(_commonUtils.QuoteSqlName(ukname)).Append(" ON ").Append(_commonUtils.QuoteSqlName(tbname[0], tbname[1])).Append("(");
|
|
||||||
foreach (var tbcol in uk.Columns)
|
|
||||||
{
|
|
||||||
sbalter.Append(_commonUtils.QuoteSqlName(tbcol.Column.Attribute.Name));
|
|
||||||
if (tbcol.IsDesc) sbalter.Append(" DESC");
|
|
||||||
sbalter.Append(", ");
|
|
||||||
}
|
|
||||||
sbalter.Remove(sbalter.Length - 2, 2).Append(");\r\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (istmpatler == false)
|
|
||||||
{
|
|
||||||
var dbcomment = string.Concat(_orm.Ado.ExecuteScalar(CommandType.Text, _commonUtils.FormatSql(@" select table_comment from information_schema.tables where table_schema = {0} and table_name = {1}", tbname[0], tbname[1])));
|
|
||||||
if (dbcomment != (tb.Comment ?? ""))
|
|
||||||
sb.Append("ALTER TABLE ").Append(_commonUtils.QuoteSqlName(tbname[0], tbname[1])).Append(" COMMENT ").Append(" ").Append(_commonUtils.FormatSql("{0}", tb.Comment ?? "")).Append(";\r\n");
|
|
||||||
|
|
||||||
sb.Append(sbalter);
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//创建临时表,数据导进临时表,然后删除原表,将临时表改名为原表名
|
//创建临时表,数据导进临时表,然后删除原表,将临时表改名为原表名
|
||||||
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]);
|
||||||
var tmptablename = _commonUtils.QuoteSqlName(tbname[0], $"FreeSqlTmp_{tbname[1]}");
|
var tmptablename = _commonUtils.QuoteSqlName(tbname[0], $"FreeSqlTmp_{tbname[1]}");
|
||||||
@ -275,27 +217,45 @@ where a.table_schema IN ({0}) and a.table_name IN ({1}) and a.index_name <> 'PRI
|
|||||||
sb.Append("CREATE TABLE IF NOT EXISTS ").Append(tmptablename).Append(" ( ");
|
sb.Append("CREATE TABLE IF NOT EXISTS ").Append(tmptablename).Append(" ( ");
|
||||||
foreach (var tbcol in tb.ColumnsByPosition)
|
foreach (var tbcol in tb.ColumnsByPosition)
|
||||||
{
|
{
|
||||||
|
tbcol.Attribute.DbType = tbcol.Attribute.DbType.Replace(" NOT NULL", "");
|
||||||
sb.Append(" \r\n ").Append(_commonUtils.QuoteSqlName(tbcol.Attribute.Name)).Append(" ").Append(tbcol.Attribute.DbType);
|
sb.Append(" \r\n ").Append(_commonUtils.QuoteSqlName(tbcol.Attribute.Name)).Append(" ").Append(tbcol.Attribute.DbType);
|
||||||
if (tbcol.Attribute.IsIdentity == true && tbcol.Attribute.DbType.IndexOf("AUTO_INCREMENT", StringComparison.CurrentCultureIgnoreCase) == -1) sb.Append(" AUTO_INCREMENT");
|
|
||||||
if (string.IsNullOrEmpty(tbcol.Comment) == false) sb.Append(" COMMENT ").Append(_commonUtils.FormatSql("{0}", tbcol.Comment));
|
if (string.IsNullOrEmpty(tbcol.Comment) == false) sb.Append(" COMMENT ").Append(_commonUtils.FormatSql("{0}", tbcol.Comment));
|
||||||
sb.Append(",");
|
sb.Append(",");
|
||||||
}
|
}
|
||||||
if (tb.Primarys.Any())
|
|
||||||
|
foreach (var uk in tb.Indexes)
|
||||||
{
|
{
|
||||||
sb.Append(" \r\n PRIMARY KEY (");
|
sb.Append(" \r\n ");
|
||||||
foreach (var tbcol in tb.Primarys) sb.Append(_commonUtils.QuoteSqlName(tbcol.Attribute.Name)).Append(", ");
|
sb.Append("INDEX ").Append(_commonUtils.QuoteSqlName(ReplaceIndexName(uk.Name, tbname[1]))).Append("(");
|
||||||
|
foreach (var tbcol in uk.Columns)
|
||||||
|
{
|
||||||
|
sb.Append(_commonUtils.QuoteSqlName(tbcol.Column.Attribute.Name));
|
||||||
|
sb.Append("TYPE set(8192) GRANULARITY 5, ");
|
||||||
|
}
|
||||||
sb.Remove(sb.Length - 2, 2).Append("),");
|
sb.Remove(sb.Length - 2, 2).Append("),");
|
||||||
}
|
}
|
||||||
sb.Remove(sb.Length - 1, 1);
|
sb.Remove(sb.Length - 1, 1);
|
||||||
sb.Append("\r\n) Engine=InnoDB");
|
sb.Append("\r\n) ");
|
||||||
if (string.IsNullOrEmpty(tb.Comment) == false)
|
sb.Append("\r\nENGINE = MergeTree()");
|
||||||
sb.Append(" Comment=").Append(_commonUtils.FormatSql("{0}", tb.Comment));
|
|
||||||
sb.Append(";\r\n");
|
|
||||||
|
|
||||||
sb.Append("INSERT INTO ").Append(tmptablename).Append(" (");
|
if (tb.Primarys.Any())
|
||||||
foreach (var tbcol in tb.ColumnsByPosition)
|
{
|
||||||
sb.Append(_commonUtils.QuoteSqlName(tbcol.Attribute.Name)).Append(", ");
|
sb.Append(" \r\nORDER BY ( ");
|
||||||
sb.Remove(sb.Length - 2, 2).Append(")\r\nSELECT ");
|
var ls = new StringBuilder();
|
||||||
|
foreach (var tbcol in tb.Primarys) ls.Append(_commonUtils.QuoteSqlName(tbcol.Attribute.Name)).Append(", ");
|
||||||
|
sb.Append(ls);
|
||||||
|
sb.Remove(sb.Length - 2, 2);
|
||||||
|
sb.Append(" )");
|
||||||
|
sb.Append(" \r\nPRIMARY KEY ");
|
||||||
|
sb.Append(ls);
|
||||||
|
sb.Remove(sb.Length - 2, 2).Append(",");
|
||||||
|
}
|
||||||
|
sb.Remove(sb.Length - 1, 1);
|
||||||
|
//if (string.IsNullOrEmpty(tb.Comment) == false)
|
||||||
|
// sb.Append(" Comment=").Append(_commonUtils.FormatSql("{0}", tb.Comment));
|
||||||
|
sb.Append(" SETTINGS index_granularity = 8192;\r\n");
|
||||||
|
|
||||||
|
sb.Append("INSERT INTO ").Append(tmptablename).Append(" SELECT ");
|
||||||
foreach (var tbcol in tb.ColumnsByPosition)
|
foreach (var tbcol in tb.ColumnsByPosition)
|
||||||
{
|
{
|
||||||
var insertvalue = "NULL";
|
var insertvalue = "NULL";
|
||||||
@ -311,27 +271,13 @@ where a.table_schema IN ({0}) and a.table_name IN ({1}) and a.index_name <> 'PRI
|
|||||||
insertvalue = $"ifnull({insertvalue},{tbcol.DbDefaultValue})";
|
insertvalue = $"ifnull({insertvalue},{tbcol.DbDefaultValue})";
|
||||||
}
|
}
|
||||||
else if (tbcol.Attribute.IsNullable == false)
|
else if (tbcol.Attribute.IsNullable == false)
|
||||||
if (tbcol.DbDefaultValue != "NULL" && tbcol.Attribute.IsIdentity == false)
|
if (tbcol.DbDefaultValue != "NULL")
|
||||||
insertvalue = tbcol.DbDefaultValue;
|
insertvalue = tbcol.DbDefaultValue;
|
||||||
sb.Append(insertvalue).Append(", ");
|
sb.Append(insertvalue).Append(", ");
|
||||||
}
|
}
|
||||||
sb.Remove(sb.Length - 2, 2).Append(" FROM ").Append(tablename).Append(";\r\n");
|
sb.Remove(sb.Length - 2, 2).Append(" FROM ").Append(tablename).Append(";\r\n");
|
||||||
sb.Append("DROP TABLE ").Append(tablename).Append(";\r\n");
|
sb.Append("DROP TABLE ").Append(tablename).Append(";\r\n");
|
||||||
sb.Append("ALTER TABLE ").Append(tmptablename).Append(" RENAME TO ").Append(_commonUtils.QuoteSqlName(tbname[0], tbname[1])).Append(";\r\n");
|
sb.Append("RENAME TABLE ").Append(tmptablename).Append(" TO ").Append(_commonUtils.QuoteSqlName(tbname[0], tbname[1])).Append(";\r\n");
|
||||||
//创建表的索引
|
|
||||||
foreach (var uk in tb.Indexes)
|
|
||||||
{
|
|
||||||
sb.Append("CREATE ");
|
|
||||||
if (uk.IsUnique) sb.Append("UNIQUE ");
|
|
||||||
sb.Append("INDEX ").Append(_commonUtils.QuoteSqlName(ReplaceIndexName(uk.Name, tbname[1]))).Append(" ON ").Append(tablename).Append("(");
|
|
||||||
foreach (var tbcol in uk.Columns)
|
|
||||||
{
|
|
||||||
sb.Append(_commonUtils.QuoteSqlName(tbcol.Column.Attribute.Name));
|
|
||||||
if (tbcol.IsDesc) sb.Append(" DESC");
|
|
||||||
sb.Append(", ");
|
|
||||||
}
|
|
||||||
sb.Remove(sb.Length - 2, 2).Append(");\r\n");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return sb.Length == 0 ? null : sb.ToString();
|
return sb.Length == 0 ? null : sb.ToString();
|
||||||
}
|
}
|
||||||
@ -367,5 +313,18 @@ where a.table_schema IN ({0}) and a.table_name IN ({1}) and a.index_name <> 'PRI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override int ExecuteDDLStatements(string ddl)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(ddl)) return 0;
|
||||||
|
var scripts = ddl.Split(new string[] { ";\r\n" }, StringSplitOptions.None).Where(a => string.IsNullOrEmpty(a.Trim()) == false).ToArray();
|
||||||
|
|
||||||
|
if (scripts.Any() == false) return 0;
|
||||||
|
|
||||||
|
var affrows = 0;
|
||||||
|
foreach (var script in scripts)
|
||||||
|
affrows += base.ExecuteDDLStatements(script);
|
||||||
|
return affrows;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -26,43 +26,67 @@ namespace FreeSql.ClickHouse
|
|||||||
public int GetDbType(DbColumnInfo column) => (int)GetClickHouseDbType(column);
|
public int GetDbType(DbColumnInfo column) => (int)GetClickHouseDbType(column);
|
||||||
DbType GetClickHouseDbType(DbColumnInfo column)
|
DbType GetClickHouseDbType(DbColumnInfo column)
|
||||||
{
|
{
|
||||||
var is_unsigned = column.DbTypeTextFull.ToLower().EndsWith(" unsigned");
|
if (column.DbTypeText == "Nullable")
|
||||||
|
{
|
||||||
|
column.DbTypeText = column.DbTypeTextFull;
|
||||||
|
//(?<=\()(\S +)(?=\))
|
||||||
|
}
|
||||||
switch (column.DbTypeText.ToLower())
|
switch (column.DbTypeText.ToLower())
|
||||||
{
|
{
|
||||||
case "bit":
|
case "bit":
|
||||||
case "tinyint":
|
case "tinyint":
|
||||||
case "bool":
|
case "bool":
|
||||||
case "sbyte":
|
case "sbyte":
|
||||||
case "Int8": return DbType.SByte;
|
case "int8":
|
||||||
|
case "nullable(int8)": return DbType.SByte;
|
||||||
case "byte":
|
case "byte":
|
||||||
case "UInt8": return DbType.Byte;
|
case "uint8":
|
||||||
|
case "nullable(uint8)": return DbType.Byte;
|
||||||
case "smallint":
|
case "smallint":
|
||||||
case "Int16": return DbType.Int16;
|
case "int16":
|
||||||
case "UInt16": return DbType.UInt16;
|
case "nullable(int16)": return DbType.Int16;
|
||||||
case "Int32":
|
case "uint16":
|
||||||
case "int": return DbType.Int32;
|
case "nullable(uint16)": return DbType.UInt16;
|
||||||
|
case "int32":
|
||||||
|
case "int":
|
||||||
|
case "nullable(int32)": return DbType.Int32;
|
||||||
case "uint":
|
case "uint":
|
||||||
case "UInt32": return DbType.UInt32;
|
case "uint32":
|
||||||
|
case "nullable(uint32)": return DbType.UInt32;
|
||||||
case "bigint":
|
case "bigint":
|
||||||
case "Int64":
|
case "int64":
|
||||||
case "long": return DbType.Int64;
|
case "long":
|
||||||
case "UInt64":
|
case "nullable(int64)": return DbType.Int64;
|
||||||
case "ulong": return DbType.UInt64;
|
case "uint64":
|
||||||
|
case "ulong":
|
||||||
|
case "nullable(uint64)": return DbType.UInt64;
|
||||||
case "real":
|
case "real":
|
||||||
case "Float64":
|
case "Float64":
|
||||||
case "double": return DbType.Double;
|
case "double":
|
||||||
|
case "nullable(float64)": return DbType.Double;
|
||||||
case "Float32":
|
case "Float32":
|
||||||
case "float": return DbType.Single;
|
case "float":
|
||||||
case "date": return DbType.Date;
|
case "nullable(float32)": return DbType.Single;
|
||||||
case "datetime": return DbType.DateTime;
|
case "date":
|
||||||
case "datetime64": return DbType.DateTime;
|
case "nullable(date)": return DbType.Date;
|
||||||
|
case "datetime":
|
||||||
|
case "nullable(datetime)": return DbType.DateTime;
|
||||||
|
case "datetime64":
|
||||||
|
case "nullable(datetime64)": return DbType.DateTime;
|
||||||
case "tinytext":
|
case "tinytext":
|
||||||
case "text":
|
case "text":
|
||||||
case "mediumtext":
|
case "mediumtext":
|
||||||
case "longtext":
|
case "longtext":
|
||||||
case "char":
|
case "char":
|
||||||
|
case "string":
|
||||||
|
case "nullable(string)":
|
||||||
case "varchar": return DbType.String;
|
case "varchar": return DbType.String;
|
||||||
default: return DbType.String;
|
default:
|
||||||
|
{
|
||||||
|
if (column.DbTypeText.ToLower().Contains("datetime"))
|
||||||
|
return DbType.DateTime;
|
||||||
|
return DbType.String;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,7 +201,10 @@ namespace FreeSql.ClickHouse
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
var left = ExpressionLambdaToSql(exp.Expression, tsc);
|
var left = ExpressionLambdaToSql(exp.Expression, tsc);
|
||||||
|
if ((exp.Expression as MemberExpression)?.Expression.NodeType == ExpressionType.Constant)
|
||||||
|
left = $"toDateTime({left})";
|
||||||
|
|
||||||
|
//IsDate(left);
|
||||||
switch (exp.Member.Name)
|
switch (exp.Member.Name)
|
||||||
{
|
{
|
||||||
case "Date": return $"toDate({left})";
|
case "Date": return $"toDate({left})";
|
||||||
@ -219,6 +222,19 @@ namespace FreeSql.ClickHouse
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
public bool IsInt(string _string)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(_string))
|
||||||
|
return false;
|
||||||
|
int i = 0;
|
||||||
|
return int.TryParse(_string, out i);
|
||||||
|
}
|
||||||
|
public bool IsDate(string date)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(date))
|
||||||
|
return true;
|
||||||
|
return DateTime.TryParse(date, out var time);
|
||||||
|
}
|
||||||
public override string ExpressionLambdaToSqlMemberAccessTimeSpan(MemberExpression exp, ExpTSC tsc)
|
public override string ExpressionLambdaToSqlMemberAccessTimeSpan(MemberExpression exp, ExpTSC tsc)
|
||||||
{
|
{
|
||||||
if (exp.Expression == null)
|
if (exp.Expression == null)
|
||||||
|
@ -35,6 +35,10 @@ namespace FreeSql.ClickHouse
|
|||||||
if (col.DbScale != 0) ret.Scale = col.DbScale;
|
if (col.DbScale != 0) ret.Scale = col.DbScale;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (value is bool)
|
||||||
|
{
|
||||||
|
ret.Value = (bool)value ? 1 : 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret.DbType = dbtype;
|
ret.DbType = dbtype;
|
||||||
@ -56,9 +60,10 @@ namespace FreeSql.ClickHouse
|
|||||||
});
|
});
|
||||||
public override string RewriteColumn(ColumnInfo col, string sql)
|
public override string RewriteColumn(ColumnInfo col, string sql)
|
||||||
{
|
{
|
||||||
|
col.Attribute.DbType = col.Attribute.DbType.Replace(" NOT NULL", "");
|
||||||
if (string.IsNullOrWhiteSpace(col?.Attribute.RewriteSql) == false)
|
if (string.IsNullOrWhiteSpace(col?.Attribute.RewriteSql) == false)
|
||||||
return string.Format(col.Attribute.RewriteSql, sql);
|
return string.Format(col.Attribute.RewriteSql, sql);
|
||||||
return string.Format(sql, col.CsType.Name);
|
return string.Format(sql, col.Attribute.DbType);
|
||||||
}
|
}
|
||||||
public override string FormatSql(string sql, params object[] args) => sql?.FormatClickHouse(args);
|
public override string FormatSql(string sql, params object[] args) => sql?.FormatClickHouse(args);
|
||||||
public override string QuoteSqlName(params string[] name)
|
public override string QuoteSqlName(params string[] name)
|
||||||
|
@ -113,98 +113,98 @@ namespace FreeSql.ClickHouse.Curd
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ClickHouseSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
public ClickHouseSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
||||||
public override ISelect<T1, T2> From<T2>(Expression<Func<ISelectFromExpression<T1>, T2, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp); var ret = new MySqlSelect<T1, T2>(_orm, _commonUtils, _commonExpression, null); ClickHouseSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
|
public override ISelect<T1, T2> From<T2>(Expression<Func<ISelectFromExpression<T1>, T2, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp); var ret = new ClickHouseSelect<T1, T2>(_orm, _commonUtils, _commonExpression, null); ClickHouseSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
|
||||||
public override ISelect<T1, T2, T3> From<T2, T3>(Expression<Func<ISelectFromExpression<T1>, T2, T3, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp); var ret = new MySqlSelect<T1, T2, T3>(_orm, _commonUtils, _commonExpression, null); ClickHouseSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
|
public override ISelect<T1, T2, T3> From<T2, T3>(Expression<Func<ISelectFromExpression<T1>, T2, T3, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp); var ret = new ClickHouseSelect<T1, T2, T3>(_orm, _commonUtils, _commonExpression, null); ClickHouseSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
|
||||||
public override ISelect<T1, T2, T3, T4> From<T2, T3, T4>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp); var ret = new MySqlSelect<T1, T2, T3, T4>(_orm, _commonUtils, _commonExpression, null); ClickHouseSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
|
public override ISelect<T1, T2, T3, T4> From<T2, T3, T4>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp); var ret = new ClickHouseSelect<T1, T2, T3, T4>(_orm, _commonUtils, _commonExpression, null); ClickHouseSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
|
||||||
public override ISelect<T1, T2, T3, T4, T5> From<T2, T3, T4, T5>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp); var ret = new MySqlSelect<T1, T2, T3, T4, T5>(_orm, _commonUtils, _commonExpression, null); ClickHouseSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
|
public override ISelect<T1, T2, T3, T4, T5> From<T2, T3, T4, T5>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp); var ret = new ClickHouseSelect<T1, T2, T3, T4, T5>(_orm, _commonUtils, _commonExpression, null); ClickHouseSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
|
||||||
public override ISelect<T1, T2, T3, T4, T5, T6> From<T2, T3, T4, T5, T6>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp); var ret = new MySqlSelect<T1, T2, T3, T4, T5, T6>(_orm, _commonUtils, _commonExpression, null); ClickHouseSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
|
public override ISelect<T1, T2, T3, T4, T5, T6> From<T2, T3, T4, T5, T6>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp); var ret = new ClickHouseSelect<T1, T2, T3, T4, T5, T6>(_orm, _commonUtils, _commonExpression, null); ClickHouseSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
|
||||||
public override ISelect<T1, T2, T3, T4, T5, T6, T7> From<T2, T3, T4, T5, T6, T7>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp); var ret = new MySqlSelect<T1, T2, T3, T4, T5, T6, T7>(_orm, _commonUtils, _commonExpression, null); ClickHouseSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
|
public override ISelect<T1, T2, T3, T4, T5, T6, T7> From<T2, T3, T4, T5, T6, T7>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp); var ret = new ClickHouseSelect<T1, T2, T3, T4, T5, T6, T7>(_orm, _commonUtils, _commonExpression, null); ClickHouseSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
|
||||||
public override ISelect<T1, T2, T3, T4, T5, T6, T7, T8> From<T2, T3, T4, T5, T6, T7, T8>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp); var ret = new MySqlSelect<T1, T2, T3, T4, T5, T6, T7, T8>(_orm, _commonUtils, _commonExpression, null); ClickHouseSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
|
public override ISelect<T1, T2, T3, T4, T5, T6, T7, T8> From<T2, T3, T4, T5, T6, T7, T8>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp); var ret = new ClickHouseSelect<T1, T2, T3, T4, T5, T6, T7, T8>(_orm, _commonUtils, _commonExpression, null); ClickHouseSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
|
||||||
public override ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9> From<T2, T3, T4, T5, T6, T7, T8, T9>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp); var ret = new MySqlSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>(_orm, _commonUtils, _commonExpression, null); ClickHouseSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
|
public override ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9> From<T2, T3, T4, T5, T6, T7, T8, T9>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp); var ret = new ClickHouseSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>(_orm, _commonUtils, _commonExpression, null); ClickHouseSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
|
||||||
public override ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> From<T2, T3, T4, T5, T6, T7, T8, T9, T10>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, T10, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp); var ret = new MySqlSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(_orm, _commonUtils, _commonExpression, null); ClickHouseSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
|
public override ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> From<T2, T3, T4, T5, T6, T7, T8, T9, T10>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, T10, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp); var ret = new ClickHouseSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(_orm, _commonUtils, _commonExpression, null); ClickHouseSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
|
||||||
|
|
||||||
public override ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> From<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp); var ret = new MySqlSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(_orm, _commonUtils, _commonExpression, null); ClickHouseSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
|
public override ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> From<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp); var ret = new ClickHouseSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(_orm, _commonUtils, _commonExpression, null); ClickHouseSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
|
||||||
public override ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> From<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp); var ret = new MySqlSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(_orm, _commonUtils, _commonExpression, null); ClickHouseSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
|
public override ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> From<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp); var ret = new ClickHouseSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(_orm, _commonUtils, _commonExpression, null); ClickHouseSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
|
||||||
public override ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> From<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp); var ret = new MySqlSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>(_orm, _commonUtils, _commonExpression, null); ClickHouseSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
|
public override ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> From<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp); var ret = new ClickHouseSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>(_orm, _commonUtils, _commonExpression, null); ClickHouseSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
|
||||||
public override ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> From<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp); var ret = new MySqlSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>(_orm, _commonUtils, _commonExpression, null); ClickHouseSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
|
public override ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> From<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp); var ret = new ClickHouseSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>(_orm, _commonUtils, _commonExpression, null); ClickHouseSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
|
||||||
public override ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> From<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp); var ret = new MySqlSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>(_orm, _commonUtils, _commonExpression, null); ClickHouseSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
|
public override ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> From<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp); var ret = new ClickHouseSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>(_orm, _commonUtils, _commonExpression, null); ClickHouseSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
|
||||||
public override ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> From<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp); var ret = new MySqlSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>(_orm, _commonUtils, _commonExpression, null); ClickHouseSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
|
public override ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> From<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, ISelectFromExpression<T1>>> exp) { this.InternalFrom(exp); var ret = new ClickHouseSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>(_orm, _commonUtils, _commonExpression, null); ClickHouseSelect<T1>.CopyData(this, ret, exp?.Parameters); return ret; }
|
||||||
public override string ToSql(string field = null) => ToSqlStatic(_commonUtils, _commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule, _tosqlAppendContent, _whereGlobalFilter, _orm);
|
public override string ToSql(string field = null) => ToSqlStatic(_commonUtils, _commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule, _tosqlAppendContent, _whereGlobalFilter, _orm);
|
||||||
}
|
}
|
||||||
class MySqlSelect<T1, T2> : FreeSql.Internal.CommonProvider.Select2Provider<T1, T2> where T2 : class
|
class ClickHouseSelect<T1, T2> : FreeSql.Internal.CommonProvider.Select2Provider<T1, T2> where T2 : class
|
||||||
{
|
{
|
||||||
public MySqlSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
public ClickHouseSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
||||||
public override string ToSql(string field = null) => ClickHouseSelect<T1>.ToSqlStatic(_commonUtils, _commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule, _tosqlAppendContent, _whereGlobalFilter, _orm);
|
public override string ToSql(string field = null) => ClickHouseSelect<T1>.ToSqlStatic(_commonUtils, _commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule, _tosqlAppendContent, _whereGlobalFilter, _orm);
|
||||||
}
|
}
|
||||||
class MySqlSelect<T1, T2, T3> : FreeSql.Internal.CommonProvider.Select3Provider<T1, T2, T3> where T2 : class where T3 : class
|
class ClickHouseSelect<T1, T2, T3> : FreeSql.Internal.CommonProvider.Select3Provider<T1, T2, T3> where T2 : class where T3 : class
|
||||||
{
|
{
|
||||||
public MySqlSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
public ClickHouseSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
||||||
public override string ToSql(string field = null) => ClickHouseSelect<T1>.ToSqlStatic(_commonUtils, _commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule, _tosqlAppendContent, _whereGlobalFilter, _orm);
|
public override string ToSql(string field = null) => ClickHouseSelect<T1>.ToSqlStatic(_commonUtils, _commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule, _tosqlAppendContent, _whereGlobalFilter, _orm);
|
||||||
}
|
}
|
||||||
class MySqlSelect<T1, T2, T3, T4> : FreeSql.Internal.CommonProvider.Select4Provider<T1, T2, T3, T4> where T2 : class where T3 : class where T4 : class
|
class ClickHouseSelect<T1, T2, T3, T4> : FreeSql.Internal.CommonProvider.Select4Provider<T1, T2, T3, T4> where T2 : class where T3 : class where T4 : class
|
||||||
{
|
{
|
||||||
public MySqlSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
public ClickHouseSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
||||||
public override string ToSql(string field = null) => ClickHouseSelect<T1>.ToSqlStatic(_commonUtils, _commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule, _tosqlAppendContent, _whereGlobalFilter, _orm);
|
public override string ToSql(string field = null) => ClickHouseSelect<T1>.ToSqlStatic(_commonUtils, _commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule, _tosqlAppendContent, _whereGlobalFilter, _orm);
|
||||||
}
|
}
|
||||||
class MySqlSelect<T1, T2, T3, T4, T5> : FreeSql.Internal.CommonProvider.Select5Provider<T1, T2, T3, T4, T5> where T2 : class where T3 : class where T4 : class where T5 : class
|
class ClickHouseSelect<T1, T2, T3, T4, T5> : FreeSql.Internal.CommonProvider.Select5Provider<T1, T2, T3, T4, T5> where T2 : class where T3 : class where T4 : class where T5 : class
|
||||||
{
|
{
|
||||||
public MySqlSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
public ClickHouseSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
||||||
public override string ToSql(string field = null) => ClickHouseSelect<T1>.ToSqlStatic(_commonUtils, _commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule, _tosqlAppendContent, _whereGlobalFilter, _orm);
|
public override string ToSql(string field = null) => ClickHouseSelect<T1>.ToSqlStatic(_commonUtils, _commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule, _tosqlAppendContent, _whereGlobalFilter, _orm);
|
||||||
}
|
}
|
||||||
class MySqlSelect<T1, T2, T3, T4, T5, T6> : FreeSql.Internal.CommonProvider.Select6Provider<T1, T2, T3, T4, T5, T6> where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class
|
class ClickHouseSelect<T1, T2, T3, T4, T5, T6> : FreeSql.Internal.CommonProvider.Select6Provider<T1, T2, T3, T4, T5, T6> where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class
|
||||||
{
|
{
|
||||||
public MySqlSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
public ClickHouseSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
||||||
public override string ToSql(string field = null) => ClickHouseSelect<T1>.ToSqlStatic(_commonUtils, _commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule, _tosqlAppendContent, _whereGlobalFilter, _orm);
|
public override string ToSql(string field = null) => ClickHouseSelect<T1>.ToSqlStatic(_commonUtils, _commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule, _tosqlAppendContent, _whereGlobalFilter, _orm);
|
||||||
}
|
}
|
||||||
class MySqlSelect<T1, T2, T3, T4, T5, T6, T7> : FreeSql.Internal.CommonProvider.Select7Provider<T1, T2, T3, T4, T5, T6, T7> where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class
|
class ClickHouseSelect<T1, T2, T3, T4, T5, T6, T7> : FreeSql.Internal.CommonProvider.Select7Provider<T1, T2, T3, T4, T5, T6, T7> where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class
|
||||||
{
|
{
|
||||||
public MySqlSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
public ClickHouseSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
||||||
public override string ToSql(string field = null) => ClickHouseSelect<T1>.ToSqlStatic(_commonUtils, _commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule, _tosqlAppendContent, _whereGlobalFilter, _orm);
|
public override string ToSql(string field = null) => ClickHouseSelect<T1>.ToSqlStatic(_commonUtils, _commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule, _tosqlAppendContent, _whereGlobalFilter, _orm);
|
||||||
}
|
}
|
||||||
class MySqlSelect<T1, T2, T3, T4, T5, T6, T7, T8> : FreeSql.Internal.CommonProvider.Select8Provider<T1, T2, T3, T4, T5, T6, T7, T8> where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class
|
class ClickHouseSelect<T1, T2, T3, T4, T5, T6, T7, T8> : FreeSql.Internal.CommonProvider.Select8Provider<T1, T2, T3, T4, T5, T6, T7, T8> where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class
|
||||||
{
|
{
|
||||||
public MySqlSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
public ClickHouseSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
||||||
public override string ToSql(string field = null) => ClickHouseSelect<T1>.ToSqlStatic(_commonUtils, _commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule, _tosqlAppendContent, _whereGlobalFilter, _orm);
|
public override string ToSql(string field = null) => ClickHouseSelect<T1>.ToSqlStatic(_commonUtils, _commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule, _tosqlAppendContent, _whereGlobalFilter, _orm);
|
||||||
}
|
}
|
||||||
class MySqlSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9> : FreeSql.Internal.CommonProvider.Select9Provider<T1, T2, T3, T4, T5, T6, T7, T8, T9> where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class
|
class ClickHouseSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9> : FreeSql.Internal.CommonProvider.Select9Provider<T1, T2, T3, T4, T5, T6, T7, T8, T9> where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class
|
||||||
{
|
{
|
||||||
public MySqlSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
public ClickHouseSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
||||||
public override string ToSql(string field = null) => ClickHouseSelect<T1>.ToSqlStatic(_commonUtils, _commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule, _tosqlAppendContent, _whereGlobalFilter, _orm);
|
public override string ToSql(string field = null) => ClickHouseSelect<T1>.ToSqlStatic(_commonUtils, _commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule, _tosqlAppendContent, _whereGlobalFilter, _orm);
|
||||||
}
|
}
|
||||||
class MySqlSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> : FreeSql.Internal.CommonProvider.Select10Provider<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class
|
class ClickHouseSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> : FreeSql.Internal.CommonProvider.Select10Provider<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class
|
||||||
{
|
{
|
||||||
public MySqlSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
public ClickHouseSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
||||||
public override string ToSql(string field = null) => ClickHouseSelect<T1>.ToSqlStatic(_commonUtils, _commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule, _tosqlAppendContent, _whereGlobalFilter, _orm);
|
public override string ToSql(string field = null) => ClickHouseSelect<T1>.ToSqlStatic(_commonUtils, _commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule, _tosqlAppendContent, _whereGlobalFilter, _orm);
|
||||||
}
|
}
|
||||||
|
|
||||||
class MySqlSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> : FreeSql.Internal.CommonProvider.Select11Provider<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class where T11 : class
|
class ClickHouseSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> : FreeSql.Internal.CommonProvider.Select11Provider<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class where T11 : class
|
||||||
{
|
{
|
||||||
public MySqlSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
public ClickHouseSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
||||||
public override string ToSql(string field = null) => ClickHouseSelect<T1>.ToSqlStatic(_commonUtils, _commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule, _tosqlAppendContent, _whereGlobalFilter, _orm);
|
public override string ToSql(string field = null) => ClickHouseSelect<T1>.ToSqlStatic(_commonUtils, _commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule, _tosqlAppendContent, _whereGlobalFilter, _orm);
|
||||||
}
|
}
|
||||||
class MySqlSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> : FreeSql.Internal.CommonProvider.Select12Provider<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class where T11 : class where T12 : class
|
class ClickHouseSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> : FreeSql.Internal.CommonProvider.Select12Provider<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class where T11 : class where T12 : class
|
||||||
{
|
{
|
||||||
public MySqlSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
public ClickHouseSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
||||||
public override string ToSql(string field = null) => ClickHouseSelect<T1>.ToSqlStatic(_commonUtils, _commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule, _tosqlAppendContent, _whereGlobalFilter, _orm);
|
public override string ToSql(string field = null) => ClickHouseSelect<T1>.ToSqlStatic(_commonUtils, _commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule, _tosqlAppendContent, _whereGlobalFilter, _orm);
|
||||||
}
|
}
|
||||||
class MySqlSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> : FreeSql.Internal.CommonProvider.Select13Provider<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class where T11 : class where T12 : class where T13 : class
|
class ClickHouseSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> : FreeSql.Internal.CommonProvider.Select13Provider<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class where T11 : class where T12 : class where T13 : class
|
||||||
{
|
{
|
||||||
public MySqlSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
public ClickHouseSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
||||||
public override string ToSql(string field = null) => ClickHouseSelect<T1>.ToSqlStatic(_commonUtils, _commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule, _tosqlAppendContent, _whereGlobalFilter, _orm);
|
public override string ToSql(string field = null) => ClickHouseSelect<T1>.ToSqlStatic(_commonUtils, _commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule, _tosqlAppendContent, _whereGlobalFilter, _orm);
|
||||||
}
|
}
|
||||||
class MySqlSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> : FreeSql.Internal.CommonProvider.Select14Provider<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class where T11 : class where T12 : class where T13 : class where T14 : class
|
class ClickHouseSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> : FreeSql.Internal.CommonProvider.Select14Provider<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class where T11 : class where T12 : class where T13 : class where T14 : class
|
||||||
{
|
{
|
||||||
public MySqlSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
public ClickHouseSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
||||||
public override string ToSql(string field = null) => ClickHouseSelect<T1>.ToSqlStatic(_commonUtils, _commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule, _tosqlAppendContent, _whereGlobalFilter, _orm);
|
public override string ToSql(string field = null) => ClickHouseSelect<T1>.ToSqlStatic(_commonUtils, _commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule, _tosqlAppendContent, _whereGlobalFilter, _orm);
|
||||||
}
|
}
|
||||||
class MySqlSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> : FreeSql.Internal.CommonProvider.Select15Provider<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class where T11 : class where T12 : class where T13 : class where T14 : class where T15 : class
|
class ClickHouseSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> : FreeSql.Internal.CommonProvider.Select15Provider<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class where T11 : class where T12 : class where T13 : class where T14 : class where T15 : class
|
||||||
{
|
{
|
||||||
public MySqlSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
public ClickHouseSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
||||||
public override string ToSql(string field = null) => ClickHouseSelect<T1>.ToSqlStatic(_commonUtils, _commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule, _tosqlAppendContent, _whereGlobalFilter, _orm);
|
public override string ToSql(string field = null) => ClickHouseSelect<T1>.ToSqlStatic(_commonUtils, _commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule, _tosqlAppendContent, _whereGlobalFilter, _orm);
|
||||||
}
|
}
|
||||||
class MySqlSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> : FreeSql.Internal.CommonProvider.Select16Provider<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class where T11 : class where T12 : class where T13 : class where T14 : class where T15 : class where T16 : class
|
class ClickHouseSelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> : FreeSql.Internal.CommonProvider.Select16Provider<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class where T11 : class where T12 : class where T13 : class where T14 : class where T15 : class where T16 : class
|
||||||
{
|
{
|
||||||
public MySqlSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
public ClickHouseSelect(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression, object dywhere) : base(orm, commonUtils, commonExpression, dywhere) { }
|
||||||
public override string ToSql(string field = null) => ClickHouseSelect<T1>.ToSqlStatic(_commonUtils, _commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule, _tosqlAppendContent, _whereGlobalFilter, _orm);
|
public override string ToSql(string field = null) => ClickHouseSelect<T1>.ToSqlStatic(_commonUtils, _commonExpression, _select, _distinct, field ?? this.GetAllFieldExpressionTreeLevel2().Field, _join, _where, _groupby, _having, _orderby, _skip, _limit, _tables, this.GetTableRuleUnions(), _aliasRule, _tosqlAppendContent, _whereGlobalFilter, _orm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ namespace FreeSql.ClickHouse.Curd
|
|||||||
internal Dictionary<string, bool> InternalIgnore => _ignore;
|
internal Dictionary<string, bool> InternalIgnore => _ignore;
|
||||||
public override string ToSql()
|
public override string ToSql()
|
||||||
{
|
{
|
||||||
return base.ToSql().Replace("UPDATE", "ALTER TABLE").Replace("SET", "UPDATE");
|
return base.ToSql()?.Replace("UPDATE", "ALTER TABLE").Replace("SET", "UPDATE");
|
||||||
}
|
}
|
||||||
internal void InternalResetSource(List<T1> source) => _source = source;
|
internal void InternalResetSource(List<T1> source) => _source = source;
|
||||||
internal string InternalWhereCaseSource(string CsName, Func<string, string> thenValue) => WhereCaseSource(CsName, thenValue);
|
internal string InternalWhereCaseSource(string CsName, Func<string, string> thenValue) => WhereCaseSource(CsName, thenValue);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user