Skip to content

Commit 325f6c2

Browse files
committed
sys.views / sys.all_views gain has_opaque_metadata and is_dropped_ledger_view.
1 parent bb471ea commit 325f6c2

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

SqlServerSimulator.Tests/SsmsProgrammabilityNodeCatalogTests.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,21 @@ public void DatabaseFiles_ResolvesCrossDatabaseThroughMaster()
176176
AreEqual("master_Log", (string?)sim.ExecuteScalar("select name from master.sys.database_files where file_id = 2"));
177177
}
178178

179+
[TestMethod]
180+
public void Views_ScriptAsColumns_ZeroForOrdinaryView()
181+
{
182+
// SMO's Script View As query reads has_opaque_metadata and
183+
// is_dropped_ledger_view — both nullable bit, 0 for every ordinary
184+
// view (probe-confirmed against SQL Server 2025), on sys.views and
185+
// sys.all_views alike.
186+
var sim = new Simulation();
187+
sim.ExecuteBatches("create view dbo.v as select 1 as c");
188+
AreEqual(0, sim.ExecuteScalar(
189+
"select cast(has_opaque_metadata as int) + cast(is_dropped_ledger_view as int) from sys.views where name = 'v'"));
190+
AreEqual(0, sim.ExecuteScalar(
191+
"select cast(has_opaque_metadata as int) + cast(is_dropped_ledger_view as int) from sys.all_views where name = 'v'"));
192+
}
193+
179194
[TestMethod]
180195
public void ViewsNode_TrimmedSmoQuery_ReturnsCreatedView()
181196
{

SqlServerSimulator/BuiltInResources.Programmable.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,11 @@ void Iso(string name, HeapColumn[] columns, Func<Parser.BatchContext, Database,
134134
new("with_check_option", SqlType.Bit, null, false),
135135
new("is_date_correlation_view", SqlType.Bit, null, false),
136136
new("ledger_view_type", SqlType.TinyInt, null, false),
137+
// has_opaque_metadata / is_dropped_ledger_view: both nullable bit
138+
// on real, 0 for every ordinary view (probe-confirmed against
139+
// SQL Server 2025) — SMO's Script-As view query reads both.
140+
new("has_opaque_metadata", SqlType.Bit, null, true),
141+
new("is_dropped_ledger_view", SqlType.Bit, null, true),
137142
], EnumerateViews);
138143

139144
// sys.all_views shares sys.views' shape and row generator — user-view
@@ -155,6 +160,8 @@ void Iso(string name, HeapColumn[] columns, Func<Parser.BatchContext, Database,
155160
new("with_check_option", SqlType.Bit, null, false),
156161
new("is_date_correlation_view", SqlType.Bit, null, false),
157162
new("ledger_view_type", SqlType.TinyInt, null, false),
163+
new("has_opaque_metadata", SqlType.Bit, null, true),
164+
new("is_dropped_ledger_view", SqlType.Bit, null, true),
158165
], EnumerateViews);
159166

160167
// sys.procedures: per-procedure rows. Shipped column subset matches
@@ -658,6 +665,8 @@ private static IEnumerable<SqlValue[]> EnumerateViews(Parser.BatchContext batch,
658665
SqlValue.FromBoolean(view.WithCheckOption),
659666
falseBit,
660667
ledgerViewTypeNone,
668+
falseBit,
669+
falseBit,
661670
];
662671
}
663672
}

0 commit comments

Comments
 (0)