Skip to content

Commit e1839bd

Browse files
committed
fixes
1 parent 824f8da commit e1839bd

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

KustoSchemaTools/Changes/FollowerPermissionChange.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,19 @@ private string BuildCommand(List<AADObject> principals, string? leaderName)
3232
.Select(a => "\"" + a.Id + "\""
3333
);
3434

35+
var hasPrincipals = ids.Any();
36+
3537
// Kusto control commands expect the literal keyword 'none' when no principals
3638
// are supplied. Wrapping none in parentheses makes it a principal named "none"
3739
// and the command is rejected, so only use parentheses for non-empty sets.
38-
var idsFragment = ids.Any() ? $"({string.Join(",", ids)})" : "none";
40+
var idsFragment = hasPrincipals ? $"({string.Join(",", ids)})" : "none";
3941

40-
// Leader name is optional; when provided we append it the same way the
41-
// portal does (e.g. '.add follower database DB viewers (...) "leader"').
42-
var leaderSuffix = string.IsNullOrWhiteSpace(leaderName) ? string.Empty : $" '{leaderName}'";
42+
// Leader name is only relevant when principals are supplied; Kusto rejects
43+
// bare leader suffixes following 'none', and they add noise to diffs. Emit
44+
// the leader only when we have principals to set.
45+
var leaderSuffix = hasPrincipals && !string.IsNullOrWhiteSpace(leaderName)
46+
? $" '{leaderName}'"
47+
: string.Empty;
4348

4449
return $".set follower database {Db.BracketIfIdentifier()} {Entity.ToLower()} {idsFragment}{leaderSuffix}";
4550
}

0 commit comments

Comments
 (0)