Repository navigation
Commit 58665f3
feat(postgres): add pg_partman partition support (#43)
* feat(postgres): add pg_partman partition support
Add PostgreSQL partition and pg_partman support with dialect,
expression, protocol, mixin, provider, and test updates.
Also apply ruff formatting/lint cleanup across the current change set
and add low-risk backend signature annotations.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(test): align partition tests with public protocol API
Update partition value security tests to exercise the public
format_partition_value expression path instead of the removed
_format_partition_value helper.
Declare supports_table_partitioning in PostgresTableSupport so the
protocol conformance reverse coverage matches PostgresTableMixin.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(postgres): avoid table and partition protocol overlap
Remove supports_table_partitioning from PostgresTableMixin so the
partition capability remains owned by PartitionSupport and
PostgresPartitionMixin. This keeps PostgreSQL protocol interfaces
non-overlapping while preserving dialect support through the partition
mixin.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* refactor(postgres): separate table and partition capabilities
Move PostgreSQL implementations of generic PartitionSupport capability
methods into PostgresPartitionMixin and ensure that mixin takes
precedence over the generic PartitionMixin in the dialect MRO.
Keep PostgresTableMixin focused on table capabilities only, and move
partition feature detection coverage from table tests into DDL protocol
and partition mixin tests. Explicitly include PartitionSupport in the
protocol conformance checks to document the inheritance boundary.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* refactor(postgres): expressionize partition operation helpers
Disable the Python 3.15 experimental workflow job until the beta
toolchain stabilizes.
Move pg_partman part_config cleanup into a dedicated expression and
formatter, then update partition operation tests to use expression
helpers for DDL and pg_partman operations instead of hand-built SQL.
Validation queries remain raw SQL because they inspect PostgreSQL
runtime metadata and routing behavior directly.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* feat(postgres): align partition capability mapping
Add PostgreSQL partition metadata query expression and align generic partition capability methods with PostgreSQL declarative partitioning.
Update provider and tests to use Expression-Dialect generated SQL for partition metadata, truncate, and drop paths.
Also update PR template links to repository-local .claude rule documents.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* test(partition): add production time partition operation scenarios
Add production-style PostgreSQL time partition scenarios covering microsecond boundaries, future partition preparation, continuous partition pruning, index usage, metadata changes, and cold archival via DETACH PARTITION.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(ddl): generate DEFAULT partition clauses correctly
Fix PostgreSQL DEFAULT partition DDL by omitting FOR VALUES for DEFAULT RANGE and LIST partitions.
Also add expression and real backend coverage for DEFAULT partition maintenance and pg_partman configuration maintenance.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* test(query): add eager loading and split sync/async relation with bridge files
- Add 5 eager loading test bridge files (one-to-one import)
- Split test_relations_with.py into sync/async bridge files
- Remove old combined test_relations_with.py bridge
- Remove partition.interfaces dependency from provider registry
- Fix async_blog_fixtures to import AsyncUser from async_models for fixture parity
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* feat(provider): implement setup_profile_fixtures for Postgres sync/async
- Add setup_profile_fixtures() and setup_async_profile_fixtures() to Postgres QueryProvider
- Create profiles.sql schema with FK reference to users table
- Add bridge files for eager_loading_scenarios_sync/async tests
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* refactor(dialect): split mixins into directory-based modules
* fix(ci): remove bridge file referencing non-existent testsuite module
test_eager_loading_scenarios.py imported
rhosocial.activerecord.testsuite.feature.query.test_eager_loading_scenarios
which does not exist in the testsuite's release/v1.0.0.dev15 branch.
This caused ModuleNotFoundError during test collection on all
Python/PostgreSQL versions in CI.
The async and sync variants
(test_eager_loading_scenarios_async.py,
test_eager_loading_scenarios_sync.py) already exist and work correctly.
* fix(test): import Profile from version-specific module, not base models
setup_profile_fixtures() imported Profile from the base models module,
but User is selected from a version-specific module (e.g. models_py312)
via _select_model_class(). The profile relation on the selected User
class resolves to the version-specific Profile class, which had no
backend configured, causing 'No backend configured' errors in all
eager loading tests using with_('profile').
Fix: add Profile to the module-level version-conditional imports
using the same _select_model_class() pattern as User, Order, etc.
* fix(test): allow TEXT[]/INTEGER[] in column definition and fix detach concurrently assertion
- Override format_column_definition in PostgresTableMixin to permit
PostgreSQL array types (e.g. TEXT[], INTEGER[]) that contain brackets
- Fix test_detach_concurrently_pg14 assertion: PR refactoring moved
CONCURRENTLY from adjacent to DETACH to a separate token after the
partition name
* fix(protocol): declare format_column_definition in PostgresTableSupport
The method was added to PostgresTableMixin but not declared in
the matching protocol, causing protocol conformance test failure.
* feat(partition): complete partitioning support with named expressions, attach improvements, and comprehensive docstrings
- Add ATTACH CONCURRENTLY support (PG 14+) to PostgresAttachPartitionExpression
- Add ATTACH DEFAULT partition support via partition_values={'default': True}
- Refactor format_partition_metadata_query to use dynamic schema filtering
- Complete pg_partman create_parent with all 7 optional parameters
- Add named expression functions for partition auto-management (create_next_monthly_partition,
create_range_partition_for_month, create_range_partition_for_quarter,
create_range_partitions_for_interval) via rhosocial-activerecord resolver
- Add english docstrings (Args/Returns/Raises) to all partition classes and methods
- Add tests: ATTACH CONCURRENTLY, ATTACH DEFAULT, multi-column partition keys,
expression boundary values, DETACH FINALIZE, pg_partman optional params,
metadata query schema filtering, concurrent_attach capability
- Verify on real PostgreSQL 18, 14, 11, 10, 9: all 150+ unit + 27 integration tests pass
* chore: add changelog fragment for PR #43
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>1 parent df84e80 commit 58665f3
172 files changed
Lines changed: 8960 additions & 633 deletions
File tree
- .claude
- .github
- PULL_REQUEST_TEMPLATE
- workflows
- changelog.d
- docs/examples
- chapter_02_connection_pool
- chapter_05_worker_isolation
- chapter_08_scenarios/parallel_workers
- chapter_10_fastapi
- chapter_12_named_procedure
- src/rhosocial/activerecord/backend/impl/postgres
- adapters
- backend
- examples/ddl
- expression
- ddl
- mixins
- ddl
- dml
- extensions
- named_expressions
- protocols
- ddl
- extensions
- tests
- providers
- rhosocial/activerecord_postgres_test/feature
- backend
- expression
- introspection
- named_connection
- postgres
- extensions
- transaction
- basic
- connection
- fixtures
- worker
- connection
- events
- mixins
- fixtures
- query
- connection
- schema
- worker
- relation
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | | - | |
| 95 | + | |
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
100 | | - | |
| 100 | + | |
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | | - | |
| 82 | + | |
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
87 | | - | |
| 87 | + | |
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
| 69 | + | |
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
219 | 219 | | |
220 | 220 | | |
221 | 221 | | |
| 222 | + | |
| 223 | + | |
222 | 224 | | |
223 | 225 | | |
224 | 226 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
132 | | - | |
133 | | - | |
134 | | - | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
| |||
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
147 | | - | |
| 147 | + | |
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
134 | | - | |
135 | | - | |
136 | | - | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
137 | 137 | | |
138 | 138 | | |
139 | 139 | | |
| |||
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
149 | | - | |
| 149 | + | |
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
118 | | - | |
| 118 | + | |
119 | 119 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
28 | | - | |
| 27 | + | |
| 28 | + | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
37 | | - | |
| 36 | + | |
| 37 | + | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| |||
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
156 | | - | |
| 156 | + | |
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
| |||
183 | 183 | | |
184 | 184 | | |
185 | 185 | | |
186 | | - | |
| 186 | + | |
187 | 187 | | |
188 | 188 | | |
189 | 189 | | |
| |||
230 | 230 | | |
231 | 231 | | |
232 | 232 | | |
233 | | - | |
| 233 | + | |
234 | 234 | | |
235 | 235 | | |
236 | 236 | | |
| |||
243 | 243 | | |
244 | 244 | | |
245 | 245 | | |
246 | | - | |
| 246 | + | |
247 | 247 | | |
248 | 248 | | |
249 | 249 | | |
| |||
0 commit comments