Browse Source

Update ClickHouse

SqlSugar5
sunkaixuan 2 years ago
parent
commit
bf853eac7b
  1. 2
      Src/Asp.NetCore2/ClickHouseTest/Demo/Demo0_SqlSugarClient.cs
  2. 2
      Src/Asp.NetCore2/ClickHouseTest/Demo/Demo1_Queryable.cs
  3. 3
      Src/Asp.NetCore2/ClickHouseTest/Models/Custom.cs
  4. 6
      Src/Asp.NetCore2/ClickHouseTest/Models/Order.cs
  5. 6
      Src/Asp.NetCore2/ClickHouseTest/Models/OrderItem.cs
  6. 1
      Src/Asp.NetCore2/SqlSugar.ClickHouseCore/ClickHouse/DbBind/ClickHouseDbBind.cs
  7. 11
      Src/Asp.NetCore2/SqlSugar.ClickHouseCore/ClickHouse/DbMaintenance/ClickHouseDbMaintenance.cs
  8. 4
      Src/Asp.NetCore2/SqlSugar.ClickHouseCore/ClickHouse/SqlBuilder/ClickHouseExpressionContext.cs
  9. 6
      Src/Asp.NetCore2/SqlSugar.ClickHouseCore/Tools/UtilExtensions.cs

2
Src/Asp.NetCore2/ClickHouseTest/Demo/Demo0_SqlSugarClient.cs

@ -107,7 +107,7 @@ namespace OrmTest
var data6 = orderDb.GetPageList(it => it.Name == "xx", p, it => it.Name, OrderByType.Asc);
Console.Write(p.TotalCount);
List<IConditionalModel> conModels = new List<IConditionalModel>();
conModels.Add(new ConditionalModel() { FieldName = "id", ConditionalType = ConditionalType.Equal, FieldValue = "1", FieldValueConvertFunc=it=>Convert.ToInt32(it) });//id=1
conModels.Add(new ConditionalModel() { FieldName = "Id", ConditionalType = ConditionalType.Equal, FieldValue = "1", FieldValueConvertFunc=it=>Convert.ToInt32(it) });//id=1
var data7 = orderDb.GetPageList(conModels, p, it => it.Name, OrderByType.Asc);
orderDb.AsQueryable().Where(x => x.Id == 1).ToList();

2
Src/Asp.NetCore2/ClickHouseTest/Demo/Demo1_Queryable.cs

@ -58,7 +58,7 @@ namespace OrmTest
var json = db.Queryable<Order>().ToJson();
List<int> listInt = db.Queryable<Order>().Select(it => it.Id).ToList();
List<long> listInt = db.Queryable<Order>().Select(it => it.Id).ToList();
var dynamic = db.Queryable<Order>().Select<dynamic>().ToList();

3
Src/Asp.NetCore2/ClickHouseTest/Models/Custom.cs

@ -8,7 +8,8 @@ namespace OrmTest
{
public class Custom
{
public int Id { get; set; }
public long Id { get; set; }
public string Name { get; set; }
}
}

6
Src/Asp.NetCore2/ClickHouseTest/Models/Order.cs

@ -9,15 +9,15 @@ namespace OrmTest
public class Order
{
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public int Id { get; set; }
[SugarColumn(IsPrimaryKey = true)]
public long Id { get; set; }
public string Name { get; set; }
public decimal Price { get; set; }
[SugarColumn(IsNullable = true)]
public DateTime CreateTime { get; set; }
[SugarColumn(IsNullable =true)]
public int CustomId { get; set; }
public long CustomId { get; set; }
[SugarColumn(IsIgnore = true)]
public List<OrderItem> Items { get; set; }
}

6
Src/Asp.NetCore2/ClickHouseTest/Models/OrderItem.cs

@ -8,9 +8,9 @@ namespace OrmTest
[SqlSugar.SugarTable("OrderDetail")]
public class OrderItem
{
[SqlSugar.SugarColumn(IsPrimaryKey =true, IsIdentity =true)]
public int ItemId { get; set; }
public int OrderId { get; set; }
[SqlSugar.SugarColumn(IsPrimaryKey =true)]
public long ItemId { get; set; }
public long OrderId { get; set; }
public decimal? Price { get; set; }
[SqlSugar.SugarColumn(IsNullable = true)]
public DateTime? CreateTime { get; set; }

1
Src/Asp.NetCore2/SqlSugar.ClickHouseCore/ClickHouse/DbBind/ClickHouseDbBind.cs

@ -86,6 +86,7 @@ namespace SqlSugar.ClickHouse
new KeyValuePair<string, CSharpDataType>("Datetime64",CSharpDataType.DateTime),
new KeyValuePair<string, CSharpDataType>("Float64",CSharpDataType.@double),
new KeyValuePair<string, CSharpDataType>("Float32",CSharpDataType.@float),
new KeyValuePair<string, CSharpDataType>("nullable",CSharpDataType.@object),
};
public override List<string> StringThrow
{

11
Src/Asp.NetCore2/SqlSugar.ClickHouseCore/ClickHouse/DbMaintenance/ClickHouseDbMaintenance.cs

@ -60,7 +60,7 @@ namespace SqlSugar.ClickHouse
{
get
{
return "ALTER TABLE {0} ADD PRIMARY KEY({2}) /*{1}*/";
return "";
}
}
protected override string AddColumnToTableSql
@ -220,6 +220,10 @@ namespace SqlSugar.ClickHouse
#endregion
#region Methods
public override bool AddPrimaryKey(string tableName, string columnName)
{
return true;
}
public override bool AddDefaultValue(string tableName, string columnName, string defaultValue)
{
return base.AddDefaultValue(this.SqlBuilder.GetTranslationTableName(tableName), this.SqlBuilder.GetTranslationTableName(columnName), defaultValue);
@ -324,6 +328,7 @@ namespace SqlSugar.ClickHouse
List<string> columnArray = new List<string>();
Check.Exception(columns.IsNullOrEmpty(), "No columns found ");
var pkName = "";
var isLower = ((ClickHouseBuilder)this.SqlBuilder).isAutoToLower;
foreach (var item in columns)
{
string columnName = item.DbColumnName;
@ -339,14 +344,14 @@ namespace SqlSugar.ClickHouse
}
string nullType = item.IsNullable ? this.CreateTableNull : CreateTableNotNull;
string primaryKey = "";
string addItem = string.Format(this.CreateTableColumn, this.SqlBuilder.GetTranslationColumnName(columnName.ToLower()), dataType, dataSize, nullType, primaryKey, "");
string addItem = string.Format(this.CreateTableColumn, this.SqlBuilder.GetTranslationColumnName(columnName.ToLower(isLower)), dataType, dataSize, nullType, primaryKey, "");
columnArray.Add(addItem);
if (pkName.IsNullOrEmpty()&&item.IsPrimarykey)
{
pkName = item.DbColumnName;
}
}
string tableString = string.Format(this.CreateTableSql, this.SqlBuilder.GetTranslationTableName(tableName.ToLower()), string.Join(",\r\n", columnArray));
string tableString = string.Format(this.CreateTableSql, this.SqlBuilder.GetTranslationTableName(tableName.ToLower(isLower)), string.Join(",\r\n", columnArray));
if (pkName.HasValue())
{
pkName = this.SqlBuilder.GetTranslationColumnName(pkName);

4
Src/Asp.NetCore2/SqlSugar.ClickHouseCore/ClickHouse/SqlBuilder/ClickHouseExpressionContext.cs

@ -4,7 +4,7 @@ namespace SqlSugar.ClickHouse
{
public class ClickHouseExpressionContext : ExpressionContext, ILambdaExpressions
{
public SqlSugarProvider Context { get; set; }
public SqlSugarProvider Context { get; set; } = new SqlSugarProvider(new ConnectionConfig() { });
public ClickHouseExpressionContext()
{
base.DbMehtods = new ClickHouseMethod();
@ -31,7 +31,7 @@ namespace SqlSugar.ClickHouse
{
get
{
return base.PgSqlIsAutoToLower;
return false;
}
}
public override string GetTranslationTableName(string entityName, bool isMapping = true)

6
Src/Asp.NetCore2/SqlSugar.ClickHouseCore/Tools/UtilExtensions.cs

@ -11,7 +11,11 @@ namespace SqlSugar.ClickHouse
{
public static string ToLower(this string value, bool isLower)
{
return value.ObjToString().ToLower();
if (isLower)
{
return value.ObjToString().ToLower();
}
return value.ObjToString();
}
public static int ObjToInt(this object thisValue)
{

Loading…
Cancel
Save