From 9a6a440d063fde5584782b081f3ad7b254e1cb3a Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Wed, 31 May 2023 17:18:02 +0800 Subject: [PATCH] Update HG --- .../DbMaintenance/PostgreSQLDbMaintenance.cs | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/Src/Asp.NetCore2/SqlSugar.HG/HG/DbMaintenance/PostgreSQLDbMaintenance.cs b/Src/Asp.NetCore2/SqlSugar.HG/HG/DbMaintenance/PostgreSQLDbMaintenance.cs index 26c5eeced..bf869236d 100644 --- a/Src/Asp.NetCore2/SqlSugar.HG/HG/DbMaintenance/PostgreSQLDbMaintenance.cs +++ b/Src/Asp.NetCore2/SqlSugar.HG/HG/DbMaintenance/PostgreSQLDbMaintenance.cs @@ -62,7 +62,7 @@ namespace SqlSugar.HG pg_namespace n on n.oid = c.relnamespace and nspname='" + schema + @"' inner join pg_tables z on z.tablename=c.relname - where relkind in('p', 'r') and relname not like 'pg_%' and relname not like 'sql_%' and schemaname='" + schema + "' order by relname"; + where relkind in('p', 'r') and relname not like 'hg_%' and relname not like 'sql_%' and schemaname='" + schema + "' order by relname"; } } protected override string GetViewInfoListSql @@ -317,19 +317,21 @@ namespace SqlSugar.HG FileHelper.CreateDirectory(databaseDirectory); } } - var oldDatabaseName = this.Context.Ado.Connection.Database; - var connection = this.Context.CurrentConnectionConfig.ConnectionString; - connection = connection.Replace(oldDatabaseName, "postgres"); - var newDb = new SqlSugarClient(new ConnectionConfig() + // var oldDatabaseName = this.Context.Ado.Connection.Database; + //var connection = this.Context.CurrentConnectionConfig.ConnectionString; + //connection = connection.Replace(oldDatabaseName, ""); + if (this.Context.Ado.IsValidConnection()) { - DbType = this.Context.CurrentConnectionConfig.DbType, - IsAutoCloseConnection = true, - ConnectionString = connection - }); + return true; + } + var newDb = this.Context.CopyNew(); + newDb.Ado.Connection.ChangeDatabase("highgo"); + newDb.Open(); if (!GetDataBaseList(newDb).Any(it => it.Equals(databaseName, StringComparison.CurrentCultureIgnoreCase))) { newDb.Ado.ExecuteCommand(string.Format(CreateDataBaseSql, this.SqlBuilder.SqlTranslationLeft+databaseName+this.SqlBuilder.SqlTranslationRight, databaseDirectory)); } + newDb.Close(); return true; } public override bool AddRemark(EntityInfo entity)