Skip to content

Commit 9e6cb4d

Browse files
author
Alexey Shalaev
committed
test: a past window the plan names is left to its attach
1 parent 0258c21 commit 9e6cb4d

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

‎pg_partsmith/planner.py‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,10 +281,8 @@ def _report_rows_in_default(self) -> None:
281281
"""
282282
earliest = self.actual.default_earliest
283283
root = self.config.scheme
284-
if earliest is None or not isinstance(root, RangePartitioning):
285-
return
286284
default = next((child for child in self.actual.root.children if child.is_default), None)
287-
if default is None:
285+
if earliest is None or default is None or not isinstance(root, RangePartitioning):
288286
return
289287
boundaries = root.range_boundaries
290288
position = boundaries.decode(str(earliest))

‎tests/unit/test_planner.py‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2561,3 +2561,17 @@ def test__plan_maintenance__default_holding_rows_past_the_cursor__is_left_to_a_l
25612561

25622562
# Assert
25632563
assert plan.findings == ()
2564+
2565+
2566+
def test__plan_maintenance__default_holding_rows_of_a_past_window_this_plan_names__is_left_to_the_attach() -> None:
2567+
# Arrange -- ensure_partitions for June 2025, whose rows sit in DEFAULT
2568+
config = _config(lifecycle=_policy(creation=CreateAhead(count=2)))
2569+
root = _root(_month(2026, 8, oid=1), _month(2026, 9, oid=2), _default())
2570+
context = _context(mode=PlanMode.EXPLICIT, explicit_windows={"created_at": (_window(2025, 6),)})
2571+
2572+
# Act
2573+
plan = _plan(config, root, default_earliest=datetime(2025, 6, 15, tzinfo=UTC), context=context)
2574+
2575+
# Assert
2576+
assert _targets(plan.creates) == [f"{ROOT}__2025_06"]
2577+
assert plan.findings == ()

0 commit comments

Comments
 (0)