Skip to content

feat(sqlserver): partition maintenance and DDL helpers - #13

Merged
vistart merged 4 commits into
release/v1.0.0.dev3from
feature/partition-maintenance
Nov 9, 2026
Merged

vistart merged 4 commits into
release/v1.0.0.dev3from
feature/partition-maintenance

Conversation

@vistart

@vistart vistart commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Description

Adds SQL Server partition DDL and backend-level maintenance on the core partition plan/report contract.

SQL Server does not use PARTITION BY or PARTITION OF: a partitioned table is a partition function, a partition scheme and a table built ON <scheme>(<column>).

  • Adds DDL expressions for CREATE PARTITION FUNCTION, CREATE PARTITION SCHEME, SPLIT RANGE, MERGE RANGE, NEXT USED, SWITCH PARTITION, and dropping the function or scheme.
  • SQLServerPartitionPlan describes the function, boundaries, direction and optional scheme without embedding a table name or retention rule.
  • SQLServerPartitionMaintenance and AsyncSQLServerPartitionMaintenance expose ensure, list, validate, retention_boundaries, drop_or_merge and drop_before.
  • ensure creates missing functions and schemes and splits only boundaries the server does not already hold, emitting NEXT USED before each split; a direction or data-type mismatch raises instead of silently repairing.
  • list reports functions, schemes, tables and per-partition ranges; validate only reports issues.
  • drop_before computes boundaries at or before the caller's cutoff and merges them; there is no generic ADD/DROP PARTITION, and there is no subpartitioning at any version.
  • Updates the README known-limitations section and adds syntax-matrix, unit and live tests.

No tracking issue.

Type of change

  • feat: A new feature
  • docs: Documentation only changes (if related to the new feature)
  • test: Adding missing tests or correcting existing tests (for the new feature)
  • perf: A code change that improves performance (if part of the feature)
  • chore: Changes to the build process or auxiliary tools and libraries suchs as documentation generation (if related to the new feature)
  • ci: Changes to our CI configuration files and scripts (if related to the new feature)
  • build: Changes that affect the build system or external dependencies (if related to the new feature)
  • revert: Reverts a previous commit

Breaking Change

  • Yes, for end-users (backward-incompatible API changes)
  • Yes, for backend developers (internal architectural changes that may affect custom implementations)
  • No breaking changes

(If Yes, please describe the impact and migration path below):

N/A

Impact on End-Users:

No backward-incompatible changes are expected for typical end-user applications.

Impact on Backend Developers (Custom Implementations):

No backward-incompatible changes are expected for backend developers using custom implementations.

Applicable rhosocial-activerecord Version Range:

rhosocial-activerecord>=1.0.0.dev30,<2.0.0

Related Repositories/Packages

  • Core: consumes the partition plan/report contract from core PR #130 (feature/partition-maintenance); this backend's test.yml installs core from that branch until PR #130 merges.
  • No testsuite change is required; the existing suite is installed from release/v1.0.0.dev17.

Testing

  • I have added new tests to cover my changes.
  • I have updated existing tests to reflect my changes.
  • All existing tests pass.
  • This change has been tested on [specify backend/DB versions].

Test Plan:

Local full-suite execution was skipped per the merge workflow; the repository CI matrix will run:

pytest tests/rhosocial/activerecord_sqlserver_test/feature/backend/test_sqlserver_partition.py
pytest tests/rhosocial/activerecord_sqlserver_test/feature/backend/sqlserver/test_partition_syntax_matrix.py
pytest tests/rhosocial/activerecord_sqlserver_test/feature/backend/test_sqlserver_partition_live.py
pytest tests/rhosocial/activerecord_sqlserver_test/feature/backend/test_sqlserver_partition_maintenance.py

CI covers SQL Server 2017/2019/2022/2025 across Python 3.9–3.14.

Checklist

  • My code follows the project's code style guidelines in .claude/code_style.md.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation (Docstrings, README.md, etc.).
  • My changes generate no new warnings.
  • I have added a Changelog fragment as described in .claude/version_control.md (changelog.d/<issue_number>.<type>.md).
  • I have verified that my changes do not introduce SQL injection vulnerabilities.
  • I have checked for potential performance regressions.

Additional Notes

The README conflict from the rebase was resolved by keeping the partition-maintenance capability description and removing the obsolete metadata-only limitation text. The changelog fragment is intentionally added after CI passes.

@vistart vistart added the enhancement New feature or request label Nov 9, 2026
@vistart vistart self-assigned this Nov 9, 2026
@sonarqubecloud

sonarqubecloud Bot commented Nov 9, 2026

Copy link
Copy Markdown

@codecov

codecov Bot commented Nov 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.27352% with 226 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.67%. Comparing base (9c9a249) to head (cd93ccb).

Files with missing lines Patch % Lines
...rd/backend/impl/sqlserver/partition/maintenance.py 70.31% 103 Missing and 57 partials ⚠️
...ord/backend/impl/sqlserver/expression/partition.py 82.31% 18 Missing and 8 partials ⚠️
...iverecord/backend/impl/sqlserver/partition/plan.py 67.94% 17 Missing and 8 partials ⚠️
...erecord/backend/impl/sqlserver/partition/report.py 82.35% 3 Missing and 6 partials ⚠️
...cord/backend/impl/sqlserver/protocols/partition.py 53.84% 6 Missing ⚠️
Additional details and impacted files
@@                   Coverage Diff                   @@
##           release/v1.0.0.dev3      #13      +/-   ##
=======================================================
- Coverage                79.02%   78.67%   -0.36%     
=======================================================
  Files                      144      148       +4     
  Lines                     8893     9805     +912     
  Branches                  1364     1535     +171     
=======================================================
+ Hits                      7028     7714     +686     
- Misses                    1383     1530     +147     
- Partials                   482      561      +79     
Flag Coverage Δ
python-3.14 78.67% <75.27%> (-0.36%) ⬇️
sqlserver-2025 78.67% <75.27%> (-0.36%) ⬇️
unittests 78.67% <75.27%> (-0.36%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@vistart
vistart merged commit 70aa6ab into release/v1.0.0.dev3 Nov 9, 2026
11 of 13 checks passed
@vistart
vistart deleted the feature/partition-maintenance branch November 9, 2026 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant