Optimize pgsql IsAnyTable

This commit is contained in:
sunkaixuan 2025-04-03 18:25:32 +08:00
parent 8e182e1236
commit b4d44ce7b5

View File

@ -250,6 +250,24 @@ namespace SqlSugar
#endregion
#region Methods
public override bool IsAnyTable(string tableName, bool isCache = true)
{
if (isCache == false)
{
var sql = @"select 1 from pg_class c
inner join
pg_namespace n on n.oid = c.relnamespace and nspname='"+GetSchema()+@"'
inner join
pg_tables z on z.tablename=c.relname and Lower(z.tablename)='" + tableName.ToLower()+@"'
where relkind in('p', 'r') and relname not like 'pg\_%' and relname not like 'sql\_%' and schemaname='public' order by relname";
var isAny=this.Context.Ado.GetDataTable(sql).Rows.Count>0;
return isAny;
}
else
{
return base.IsAnyTable(tableName, isCache);
}
}
public override List<string> GetDbTypes()
{
var result = this.Context.Ado.SqlQuery<string>(@"SELECT DISTINCT data_type