mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-20 02:29:39 +08:00
Update pgsql
This commit is contained in:
@@ -19,6 +19,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
string schema = GetSchema();
|
||||||
string sql = @"select cast (pclass.oid as int4) as TableId,cast(ptables.tablename as varchar) as TableName,
|
string sql = @"select cast (pclass.oid as int4) as TableId,cast(ptables.tablename as varchar) as TableName,
|
||||||
pcolumn.column_name as DbColumnName,pcolumn.udt_name as DataType,
|
pcolumn.column_name as DbColumnName,pcolumn.udt_name as DataType,
|
||||||
CASE WHEN pcolumn.numeric_scale >0 THEN pcolumn.numeric_precision ELSE pcolumn.character_maximum_length END as Length,
|
CASE WHEN pcolumn.numeric_scale >0 THEN pcolumn.numeric_precision ELSE pcolumn.character_maximum_length END as Length,
|
||||||
@@ -32,7 +33,7 @@ namespace SqlSugar
|
|||||||
then true else false end as IsIdentity,
|
then true else false end as IsIdentity,
|
||||||
case when pcolumn.is_nullable = 'YES'
|
case when pcolumn.is_nullable = 'YES'
|
||||||
then true else false end as IsNullable
|
then true else false end as IsNullable
|
||||||
from (select * from pg_tables where upper(tablename) = upper('{0}') and schemaname='public') ptables inner join pg_class pclass
|
from (select * from pg_tables where upper(tablename) = upper('{0}') and schemaname='" + schema + @"') ptables inner join pg_class pclass
|
||||||
on ptables.tablename = pclass.relname inner join (SELECT *
|
on ptables.tablename = pclass.relname inner join (SELECT *
|
||||||
FROM information_schema.columns
|
FROM information_schema.columns
|
||||||
) pcolumn on pcolumn.table_name = ptables.tablename
|
) pcolumn on pcolumn.table_name = ptables.tablename
|
||||||
@@ -49,13 +50,17 @@ namespace SqlSugar
|
|||||||
return sql;
|
return sql;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override string GetTableInfoListSql
|
protected override string GetTableInfoListSql
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
var schema = GetSchema();
|
||||||
return @"select cast(relname as varchar) as Name,
|
return @"select cast(relname as varchar) as Name,
|
||||||
cast(obj_description(relfilenode,'pg_class') as varchar) as Description from pg_class c
|
cast(obj_description(relfilenode,'pg_class') as varchar) as Description from pg_class c
|
||||||
where relkind = 'r' and relname not like 'pg_%' and relname not like 'sql_%' order by relname";
|
inner join
|
||||||
|
pg_tables z on z.tablename=c.relname
|
||||||
|
where relkind = 'r' and relname not like 'pg_%' and relname not like 'sql_%' and schemaname='"+ schema + "' order by relname";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected override string GetViewInfoListSql
|
protected override string GetViewInfoListSql
|
||||||
@@ -446,5 +451,31 @@ namespace SqlSugar
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#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;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user