mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-06-28 04:35:29 +08:00
Update ClickHouse
This commit is contained in:
parent
d4e22d0fbb
commit
69db2bda2b
@ -16,7 +16,7 @@ namespace OrmTest
|
||||
/// Account have permission to create database
|
||||
/// 用有建库权限的数据库账号
|
||||
/// </summary>
|
||||
public static string ConnectionString = "Database=default;Username=default;Password=;Host=localhost;Port=8123;Compression=False;UseSession=False;Timeout=120;";
|
||||
public static string ConnectionString = "Database=SqlSugarTest2;Username=default;Password=;Host=localhost;Port=8123;Compression=False;UseSession=False;Timeout=120;";
|
||||
/// <summary>
|
||||
/// Account have permission to create database
|
||||
/// 用有建库权限的数据库账号
|
||||
|
@ -67,7 +67,7 @@ namespace OrmTest
|
||||
});
|
||||
|
||||
//If no exist create datebase
|
||||
// db.DbMaintenance.CreateDatabase();
|
||||
db.DbMaintenance.CreateDatabase();
|
||||
|
||||
//Use db query
|
||||
var dt = db.Ado.GetDataTable("SELECT * FROM system.tables");
|
||||
|
@ -19,7 +19,7 @@ namespace OrmTest
|
||||
InitKeyType = InitKeyType.Attribute,
|
||||
IsAutoCloseConnection = true
|
||||
});
|
||||
db.DbMaintenance.CreateDatabase();
|
||||
//db.DbMaintenance.CreateDatabase();
|
||||
db.CodeFirst.InitTables(typeof(CodeFirstTable1));//Create CodeFirstTable1
|
||||
db.Insertable(new CodeFirstTable1() { Name = "a", Text="a" }).ExecuteCommand();
|
||||
var list = db.Queryable<CodeFirstTable1>().ToList();
|
||||
@ -29,10 +29,10 @@ namespace OrmTest
|
||||
|
||||
public class CodeFirstTable1
|
||||
{
|
||||
[SugarColumn(IsIdentity = true, IsPrimaryKey = true)]
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
[SugarColumn(ColumnDataType = "varchar(255)")]//custom
|
||||
[SugarColumn(ColumnDataType = "String")]//custom
|
||||
public string Text { get; set; }
|
||||
[SugarColumn(IsNullable = true)]
|
||||
public DateTime CreateTime { get; set; }
|
||||
|
@ -37,7 +37,7 @@ namespace OrmTest
|
||||
Console.WriteLine(string.Join("," ,list));
|
||||
});
|
||||
|
||||
var list2= db.Utilities.DataTableToList<Order>(db.Ado.GetDataTable("select * from \"order\""));
|
||||
var list2= db.Utilities.DataTableToList<Order>(db.Ado.GetDataTable("select * from \"Order\""));
|
||||
|
||||
//more https://github.com/sunkaixuan/SqlSugar/wiki/f.Utilities
|
||||
Console.WriteLine("#### Utilities End ####");
|
||||
|
@ -33,7 +33,8 @@ namespace SqlSugar.ClickHouse
|
||||
{
|
||||
get
|
||||
{
|
||||
return @"SELECT name FROM system.tables where database not in('INFORMATION_SCHEMA','system','information_schema' )";
|
||||
string schema = GetSchema();
|
||||
return @"SELECT name FROM system.tables where database not in('INFORMATION_SCHEMA','system','information_schema' ) and database='"+GetSchema()+"'";
|
||||
}
|
||||
}
|
||||
protected override string GetViewInfoListSql
|
||||
@ -281,7 +282,7 @@ namespace SqlSugar.ClickHouse
|
||||
}
|
||||
var oldDatabaseName = this.Context.Ado.Connection.Database;
|
||||
var connection = this.Context.CurrentConnectionConfig.ConnectionString;
|
||||
connection = connection.Replace(oldDatabaseName, "postgres");
|
||||
connection = connection.Replace(oldDatabaseName, "system");
|
||||
var newDb = new SqlSugarClient(new ConnectionConfig()
|
||||
{
|
||||
DbType = this.Context.CurrentConnectionConfig.DbType,
|
||||
@ -390,25 +391,7 @@ namespace SqlSugar.ClickHouse
|
||||
#region Helper
|
||||
private string GetSchema()
|
||||
{
|
||||
var schema = "public";
|
||||
if (System.Text.RegularExpressions.Regex.IsMatch(this.Context.CurrentConnectionConfig.ConnectionString.ToLower(), "searchpath="))
|
||||
{
|
||||
var regValue = System.Text.RegularExpressions.Regex.Match(this.Context.CurrentConnectionConfig.ConnectionString.ToLower(), @"searchpath\=(\w+)").Groups[1].Value;
|
||||
if (regValue.HasValue())
|
||||
{
|
||||
schema = regValue;
|
||||
}
|
||||
}
|
||||
else if (System.Text.RegularExpressions.Regex.IsMatch(this.Context.CurrentConnectionConfig.ConnectionString.ToLower(), "search path="))
|
||||
{
|
||||
var regValue = System.Text.RegularExpressions.Regex.Match(this.Context.CurrentConnectionConfig.ConnectionString.ToLower(), @"search path\=(\w+)").Groups[1].Value;
|
||||
if (regValue.HasValue())
|
||||
{
|
||||
schema = regValue;
|
||||
}
|
||||
}
|
||||
|
||||
return schema;
|
||||
return this.Context.Ado.Connection.Database;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
Loading…
Reference in New Issue
Block a user