Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions KustoSchemaTools/Changes/DatabaseChanges.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ public static List<IChange> GenerateChanges(Database oldState, Database newState
}
}

foreach (var mv in newState.MaterializedViews)
{
if (mv.Value.AllowMaterializedViewsWithoutRowLevelSecurity
&& oldState.MaterializedViews.ContainsKey(mv.Key))
{
oldState.MaterializedViews[mv.Key].AllowMaterializedViewsWithoutRowLevelSecurity = true;
}
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The propagation logic only handles the direct AllowMaterializedViewsWithoutRowLevelSecurity property on MaterializedView, but not the same property in mv.Value.Policies.AllowMaterializedViewsWithoutRowLevelSecurity. Similar to the table propagation logic (lines 53-61), this should also propagate the Policies property to avoid phantom diffs when row-level security is configured. Consider adding:

if (mv.Value.Policies?.AllowMaterializedViewsWithoutRowLevelSecurity == true
    && oldState.MaterializedViews.ContainsKey(mv.Key)
    && oldState.MaterializedViews[mv.Key].Policies != null)
{
    oldState.MaterializedViews[mv.Key].Policies.AllowMaterializedViewsWithoutRowLevelSecurity = true;
}
Suggested change
}
}
if (mv.Value.Policies?.AllowMaterializedViewsWithoutRowLevelSecurity == true
&& oldState.MaterializedViews.ContainsKey(mv.Key)
&& oldState.MaterializedViews[mv.Key].Policies != null)
{
oldState.MaterializedViews[mv.Key].Policies.AllowMaterializedViewsWithoutRowLevelSecurity = true;
}

Copilot uses AI. Check for mistakes.
}

result.AddRange(GenerateScriptCompareChanges(oldState, newState, db => db.Tables, nameof(newState.Tables), log, (oldItem, newItem) => oldItem != null || newItem.Columns?.Any() == true));
var mvChanges = GenerateScriptCompareChanges(oldState, newState, db => db.MaterializedViews, nameof(newState.MaterializedViews), log);
foreach(var mvChange in mvChanges)
Expand Down
11 changes: 10 additions & 1 deletion KustoSchemaTools/Model/MaterializedView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class MaterializedView : IKustoBaseEntity
public string? RowLevelSecurity { get; set; }
public Policy? Policies { get; set; }
public bool Preformatted { get; set; } = false;
public bool AllowMaterializedViewsWithoutRowLevelSecurity { get; set; } = false;
public List<DatabaseScriptContainer> CreateScripts(string name, bool isNew)
{
var asyncSetup = isNew && Backfill == true;
Expand All @@ -36,7 +37,8 @@ public List<DatabaseScriptContainer> CreateScripts(string name, bool isNew)
"RetentionAndCachePolicy",
"RowLevelSecurity",
"Policies",
"Preformatted"
"Preformatted",
"AllowMaterializedViewsWithoutRowLevelSecurity"
]);

if (!asyncSetup)
Expand All @@ -52,6 +54,13 @@ public List<DatabaseScriptContainer> CreateScripts(string name, bool isNew)
.Where(p => !string.IsNullOrWhiteSpace(p.Value?.ToString()))
.Select(p => $"{p.Name}=```{p.Value}```"));

if (AllowMaterializedViewsWithoutRowLevelSecurity && isNew)
{
properties = string.IsNullOrEmpty(properties)
? "allowMaterializedViewsWithoutRowLevelSecurity=true"
: $"{properties}, allowMaterializedViewsWithoutRowLevelSecurity=true";
}
Comment on lines +57 to +62
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new AllowMaterializedViewsWithoutRowLevelSecurity property lacks test coverage. Consider adding tests that verify:

  1. The property is correctly excluded from automatic property reflection (line 41)
  2. The property is correctly added to the script when creating a new materialized view with AllowMaterializedViewsWithoutRowLevelSecurity=true and isNew=true
  3. The property is NOT added when isNew=false (updating an existing materialized view)
  4. The property is correctly appended to existing properties with proper comma separation
  5. The property works correctly when there are no other properties

Similar to the test pattern in YamlDatabaseHandlerTests.cs line 169, you could test the generated scripts from CreateScripts.

Copilot uses AI. Check for mistakes.

if (asyncSetup)
{
scripts.Add(new DatabaseScriptContainer("CreateMaterializedViewAsync", Kind == "table" ? 40 : 41, $".create async ifnotexists materialized-view with ({properties}) {name} on {Kind} {Source} {{ {Query} }}", true));
Expand Down
Loading