Skip to content

Commit 2d17dcd

Browse files
committed
DeleteDateHint: rename certain fields + no boxing on checking flags
1 parent 67b30e6 commit 2d17dcd

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

Orm/Xtensive.Orm/Modelling/Comparison/Hints/DeleteDataHint.cs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ internal enum DeleteDataHintInfo : byte
2323
None = 0,
2424
PostCopy = 1,
2525
TableMovement = 2,
26-
All = PostCopy | TableMovement
2726
}
2827

2928
private readonly DeleteDataHintInfo info = DeleteDataHintInfo.None;
@@ -34,12 +33,21 @@ internal enum DeleteDataHintInfo : byte
3433
/// these records are still necessary during upgrade to be copied, but must be removed on its
3534
/// completion.
3635
/// </summary>
37-
public bool PostCopy => info.HasFlag(DeleteDataHintInfo.PostCopy);
36+
[Obsolete("Use IsPostCopyCleanup instead")]
37+
public bool PostCopy => IsPostCopyCleanup;
38+
39+
/// <summary>
40+
/// Gets a value indicating whether deletion must be performed after completion of copy data hint processing.
41+
/// Normally this flag is used to remove records related to types moved to other hierarchies -
42+
/// these records are still necessary during upgrade to be copied, but must be removed on its
43+
/// completion.
44+
/// </summary>
45+
public bool IsPostCopyCleanup => (info & DeleteDataHintInfo.PostCopy) > 0;
3846

3947
/// <summary>
4048
/// Gets a value indicating whether cause of data deletion is due to table have changed its owner type.
4149
/// </summary>
42-
public bool DueToTableOwnerChange => info.HasFlag(DeleteDataHintInfo.TableMovement);
50+
public bool IsOwnerChangeCleanup => (info & DeleteDataHintInfo.TableMovement) > 0;
4351

4452
/// <summary>
4553
/// Gets a value indication whether deletion is unsafe. Deletion is considered insafe
@@ -67,8 +75,8 @@ public override string ToString()
6775
(Identities.Count > 0)
6876
? "where (" + string.Join(" and ", Identities.Select(pair => pair.ToString()).ToArray()) + ")"
6977
: string.Empty,
70-
PostCopy ? " (after data copying)" : string.Empty,
71-
DueToTableOwnerChange ? " (due to table changed owner type)" : string.Empty);
78+
IsPostCopyCleanup ? " (after data copying)" : string.Empty,
79+
IsOwnerChangeCleanup ? " (due to table changed owner type)" : string.Empty);
7280
}
7381

7482
// Constructors
@@ -86,7 +94,7 @@ public DeleteDataHint(string sourceTablePath, IList<IdentityPair> identities)
8694
/// </summary>
8795
/// <param name="sourceTablePath">Source table path.</param>
8896
/// <param name="identities">Identities for data operation.</param>
89-
/// <param name="postCopy"><see cref="PostCopy"/> property value.</param>
97+
/// <param name="postCopy"><see cref="IsPostCopyCleanup"/> property value.</param>
9098
public DeleteDataHint(string sourceTablePath, IList<IdentityPair> identities, bool postCopy)
9199
: base(sourceTablePath, identities)
92100
{
@@ -100,7 +108,7 @@ public DeleteDataHint(string sourceTablePath, IList<IdentityPair> identities, b
100108
/// </summary>
101109
/// <param name="sourceTablePath">Source table path.</param>
102110
/// <param name="identities">Identities for data operation.</param>
103-
/// <param name="postCopy"><see cref="PostCopy"/> property value.</param>
111+
/// <param name="postCopy"><see cref="IsPostCopyCleanup"/> property value.</param>
104112
/// <param name="dueToOnwerChange"><see langword="true"/> if reason of deletion is the table <paramref name="sourceTablePath"/>
105113
/// has changed assigned type.</param>
106114
public DeleteDataHint(string sourceTablePath, IList<IdentityPair> identities, bool postCopy, bool dueToOnwerChange)

Orm/Xtensive.Orm/Modelling/Comparison/Upgrader.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ protected virtual void ProcessMovement(NodeDifference difference)
294294
.ForEach(hint => AddAction(UpgradeActionType.Regular,
295295
new DataAction {DataHint = hint}));
296296
Hints.GetHints<DeleteDataHint>(difference.Source)
297-
.Where(hint => !hint.PostCopy)
297+
.Where(hint => !hint.IsPostCopyCleanup)
298298
.Where(hint => sc.Compare(hint.SourceTablePath, difference.Source.Path) == 0)
299299
.ForEach(hint => AddAction(UpgradeActionType.Regular,
300300
new DataAction {DataHint = hint}));
@@ -337,7 +337,7 @@ protected virtual void ProcessMovement(NodeDifference difference)
337337
case UpgradeStage.PostCopyData:
338338
if (difference.IsDataChanged) {
339339
Hints.GetHints<DeleteDataHint>(difference.Source)
340-
.Where(hint => hint.PostCopy)
340+
.Where(hint => hint.IsPostCopyCleanup)
341341
.Where(hint => sc.Compare(hint.SourceTablePath, difference.Source.Path) == 0)
342342
.ForEach(hint => AddAction(UpgradeActionType.Regular,
343343
new DataAction {DataHint = hint}));
@@ -782,7 +782,7 @@ private void UpdateHints()
782782

783783
// Process DeleteDataHints
784784
foreach (var deleteDataHint in originalHints.OfType<DeleteDataHint>()) {
785-
if (!deleteDataHint.PostCopy) {
785+
if (!deleteDataHint.IsPostCopyCleanup) {
786786
continue; // It's not necessary to copy this hint
787787
}
788788

Orm/Xtensive.Orm/Orm/Upgrade/Internals/SqlActionTranslator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,7 @@ select action
734734
var deleteActions = (
735735
from action in clearDataActions
736736
let deleteDataHint = action.DataHint as DeleteDataHint
737-
where deleteDataHint!=null && deleteDataHint.PostCopy==postCopy
737+
where deleteDataHint!=null && deleteDataHint.IsPostCopyCleanup==postCopy
738738
select action
739739
).ToList();
740740

0 commit comments

Comments
 (0)