Skip to content

Commit 8373411

Browse files
committed
- 完善 达梦 DbFirst 支持视图;
1 parent dddfbe5 commit 8373411

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

FreeSql.Tests/FreeSql.Tests/Dameng/DamengDbFirstTest.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ public void GetTableByName()
3333
Assert.Equal(t1.Columns.Count, t2.Columns.Count);
3434
var t3 = fsql.DbFirst.GetTableByName("notexists_tb");
3535
Assert.Null(t3);
36+
37+
var t4 = fsql.DbFirst.GetTableByName("v_2user_v1");
38+
Assert.NotNull(t4);
3639
}
3740

3841
[Fact]

Providers/FreeSql.Provider.Dameng/DamengDbFirst.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,19 @@ public List<DbTableInfo> GetTables(string[] database, string tablename, bool ign
270270
'TABLE'
271271
from all_tables a
272272
left join all_tab_comments b on b.owner = a.owner and b.table_name = a.table_name and b.table_type = 'TABLE'
273-
where {(ignoreCase ? "lower(a.owner)" : "a.owner")} in ({databaseIn}){(tbname == null ? "" : $" and {(ignoreCase ? "lower(a.table_name)" : "a.table_name")}={_commonUtils.FormatSql("{0}", tbname[1])}")}";
273+
where {(ignoreCase ? "lower(a.owner)" : "a.owner")} in ({databaseIn}){(tbname == null ? "" : $" and {(ignoreCase ? "lower(a.table_name)" : "a.table_name")}={_commonUtils.FormatSql("{0}", tbname[1])}")}
274+
275+
UNION ALL
276+
277+
select
278+
a.owner || '.' || a.view_name,
279+
a.owner,
280+
a.view_name,
281+
b.comments,
282+
'VIEW' AS tp
283+
from all_views a
284+
left join all_tab_comments b on b.owner = a.owner and b.table_name = a.view_name and b.table_type = 'VIEW'
285+
where {(ignoreCase ? "lower(a.owner)" : "a.owner")} in ({databaseIn}){(tbname == null ? "" : $" and {(ignoreCase ? "lower(a.view_name)" : "a.view_name")}={_commonUtils.FormatSql("{0}", tbname[1])}")}";
274286
var ds = _orm.Ado.ExecuteArray(CommandType.Text, sql);
275287
if (ds == null) return loc1;
276288

Providers/FreeSql.Provider.Odbc/Dameng/OdbcDamengDbFirst.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,19 @@ public List<DbTableInfo> GetTables(string[] database, string tablename, bool ign
270270
'TABLE'
271271
from all_tables a
272272
left join all_tab_comments b on b.owner = a.owner and b.table_name = a.table_name and b.table_type = 'TABLE'
273-
where {(ignoreCase ? "lower(a.owner)" : "a.owner")} in ({databaseIn}){(tbname == null ? "" : $" and {(ignoreCase ? "lower(a.table_name)" : "a.table_name")}={_commonUtils.FormatSql("{0}", tbname[1])}")}";
273+
where {(ignoreCase ? "lower(a.owner)" : "a.owner")} in ({databaseIn}){(tbname == null ? "" : $" and {(ignoreCase ? "lower(a.table_name)" : "a.table_name")}={_commonUtils.FormatSql("{0}", tbname[1])}")}
274+
275+
UNION ALL
276+
277+
select
278+
a.owner || '.' || a.view_name,
279+
a.owner,
280+
a.view_name,
281+
b.comments,
282+
'VIEW' AS tp
283+
from all_views a
284+
left join all_tab_comments b on b.owner = a.owner and b.table_name = a.view_name and b.table_type = 'VIEW'
285+
where {(ignoreCase ? "lower(a.owner)" : "a.owner")} in ({databaseIn}){(tbname == null ? "" : $" and {(ignoreCase ? "lower(a.view_name)" : "a.view_name")}={_commonUtils.FormatSql("{0}", tbname[1])}")}";
274286
var ds = _orm.Ado.ExecuteArray(CommandType.Text, sql);
275287
if (ds == null) return loc1;
276288

0 commit comments

Comments
 (0)