Skip to content

feat(backend): add PostgreSQL DDL coverage-completion expressions and CREATE UNLOGGED TABLE - #53

Merged
vistart merged 5 commits into
release/v1.0.0.dev16from
feature/postgres-ddl-coverage-completion
Aug 8, 2026
Merged

vistart merged 5 commits into
release/v1.0.0.dev16from
feature/postgres-ddl-coverage-completion

Conversation

@vistart

@vistart vistart commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

Description

Closes the PostgreSQL SQL-command coverage gaps documented in the 2026-08-07 coverage-gap analysis plan
(.claude/plan/2026-08-07/postgres-coverage-gap-analysis.md). Adds expression/mixin/protocol triads so the
remaining PostgreSQL DDL objects and ALTER TABLE subclauses can be driven through the Expression-Dialect
pipeline, each version-gated (PG 9.6–19 baseline) and exposed via @runtime_checkable protocols:

  • ALTER TABLE RLS configuration: ENABLE/DISABLE [ALWAYS] ROW LEVEL SECURITY and FORCE/NO FORCE RLS
    (PostgresAlterTableRlsExpression, PostgresForceRlsExpression; PG 9.5+)
  • ALTER TABLE SET LOGGED/UNLOGGED (9.6+) and SET ACCESS METHOD (15+)
  • CLUSTER table [ USING index ] [ VERBOSE ] (9.6+)
  • CREATE/ALTER/DROP DOMAIN (9.6+, ALTER supports SET DEFAULT / RENAME TO)
  • CREATE/DROP COLLATION objects (9.6+)
  • CREATE/DROP FOREIGN TABLE (9.6+)
  • CREATE/DROP FUNCTION and CREATE/DROP AGGREGATE (9.6+)
  • CREATE/DROP PUBLICATION / CREATE/DROP SUBSCRIPTION (10+)
  • ALTER COLUMN SET DATA TYPE ... USING (expr) conversion on the existing core AlterColumn action
    (opt-in via dialect_options={"using": ...}; rejected on non-type operations)
  • CREATE UNLOGGED TABLE via dialect_options={"unlogged_table": True} (PG 9.5+), with TEMPORARY
    taking precedence

All are PostgreSQL vendor extensions implemented only in the postgres backend package; the core
rhosocial-activerecord library is untouched.

Type of change

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

Breaking Change

  • Yes
  • No

Applicable rhosocial-activerecord Version Range: >=1.0.0,<2.0.0

Related Repositories/Packages

None — core rhosocial-activerecord is not modified. This PR is the postgres counterpart to the single-branch
plan; sibling coverage-completion work already landed in python-activerecord (SQLite) and
python-activerecord-mysql.

Testing

  • I have added new tests to cover my changes. (pure-SQL unit tests, no DB)
  • I have updated existing tests.
  • All existing tests pass.
  • This change has been tested on [specific backend/DB versions]. (CI matrix covers PG 9–19; benchmarks on 18)

Test Plan:

  • Unit/protocol tests: test_ddl_expressions.py, test_ddl_protocols.py, test_policy.py,
    test_alter_table_if_exists.py
  • Includes a plain §6.3 version-baseline sweep at PG 9.6/10/11/14/15/17/19
  • CI: full matrix PG 9 / 10 / 11 / 12 / 13 / 14 / 15 / 16 / 17 / 18 / 19 (beta) — all green

Checklist

  • My code follows the project's code style guidelines.
  • 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).
  • My changes generate no new warnings (ruff clean).
  • I have added a [Changelog fragment] (changelog.d/53.added.md).
  • I have verified that my changes do not introduce SQL injection vulnerabilities (all user input
    routed through identifier quoting / parameter placeholders).
  • I have checked for potential performance regressions (no loops over rows; pure formatting).

Additional Notes

Commit history since release/v1.0.0.dev16:

  • 16a6bc5 feat(backend): add coverage-gap DDL expressions for PostgreSQL
  • 8ccd35e docs(backend): add JSONExpression type hints to enhanced JSONB mixin and protocol
  • 147efd3 feat(backend): complete DDL coverage gaps RENAME and CREATE UNLOGGED TABLE

CI run (workflow_dispatch, head 147efd3): all 12 matrix jobs succeeded.

vistart added 3 commits August 8, 2026 10:39
Add expression/mixin/protocol triads covering the remaining PostgreSQL DDL
coverage gaps, each version-gated and exposed through a @runtime_checkable
Protocol:

- RLS table configuration (ENABLE/DISABLE/ALWAYS/FORCE) — PG 9.5+
- ALTER TABLE SET LOGGED/UNLOGGED (9.6+) and SET ACCESS METHOD (15+)
- CLUSTER (index re-cluster) — 9.6+
- CREATE/ALTER/DROP DOMAIN (9.6+; ALTER supports SET DEFAULT/RENAME NOT NULL)
- CREATE/DROP COLLATION objects (9.6+)
- CREATE/DROP FOREIGN TABLE (9.6+)
- CREATE/DROP FUNCTION and CREATE/DROP AGGREGATE (9.6+)
- CREATE/DROP PUBLICATION / SUBSCRIPTION (10+)

PostgresAlterColumnModifierMixin.format_alter_column_action now renders the
ALTER COLUMN ... SET DATA TYPE ... USING (expr) conversion (opt-in via
dialect_options['using']), raising ValueError when used on non-type ops.

PostgreSQL extensions only — core rhosocial-activerecord untouched. Adds
pure-SQL unit tests (no DB) for capability switches, protocol conformance,
and SQL generation. Closes the plan at .claude/plan/2026-08-07
postgres-coverage-gap-analysis.md.
…TABLE

Plan 4.6/4.7 closure:
- CREATE UNLOGGED TABLE via dialect_options={'unlogged_table': True} on
  CreateTableExpression, version-gated at 9.5+, rendering through
  PostgresTableMixin.format_create_table_statement; TEMPORARY wins over
  UNLOGGED. Exposes supports_unlogged_table on PostgresTableSupport.
- RENAME COLUMN / RENAME TABLE verified through core actions and covered
  by tests (already supported by core DDL; no new mixin needed).

Tests:
- Extend test_alter_table_if_exists.py with ALTER COLUMN SET DATA TYPE
  [USING] and RENAME subclause coverage plus CREATE UNLOGGED TABLE.
- Add plan §6.3 version-baseline sweep at PG 9.6/10/11/14/15/17/19 with
  UnsupportedFeatureError gates.
@vistart vistart added the feature label Aug 8, 2026
@vistart vistart self-assigned this Aug 8, 2026
@codecov

codecov Bot commented Aug 8, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.24273% with 93 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.68%. Comparing base (226867d) to head (0b81bde).

Files with missing lines Patch % Lines
...backend/impl/postgres/protocols/ddl/publication.py 52.94% 7 Missing and 1 partial ⚠️
...ord/backend/impl/postgres/protocols/ddl/routine.py 52.94% 7 Missing and 1 partial ⚠️
.../backend/impl/postgres/protocols/ddl/rls_config.py 53.33% 6 Missing and 1 partial ⚠️
...cord/backend/impl/postgres/protocols/ddl/domain.py 53.84% 5 Missing and 1 partial ⚠️
...activerecord/backend/impl/postgres/mixins/table.py 73.68% 4 Missing and 1 partial ⚠️
...d/backend/impl/postgres/protocols/ddl/collation.py 54.54% 4 Missing and 1 partial ⚠️
...ckend/impl/postgres/protocols/ddl/foreign_table.py 54.54% 4 Missing and 1 partial ⚠️
...kend/impl/postgres/protocols/ddl/table_settings.py 54.54% 4 Missing and 1 partial ⚠️
...ord/backend/impl/postgres/protocols/ddl/cluster.py 55.55% 3 Missing and 1 partial ⚠️
...erecord/backend/impl/postgres/mixins/ddl/domain.py 93.87% 1 Missing and 2 partials ⚠️
... and 18 more
Additional details and impacted files
@@                   Coverage Diff                    @@
##           release/v1.0.0.dev16      #53      +/-   ##
========================================================
+ Coverage                 73.58%   74.68%   +1.09%     
========================================================
  Files                       281      305      +24     
  Lines                     11590    12377     +787     
  Branches                   1879     2001     +122     
========================================================
+ Hits                       8529     9244     +715     
- Misses                     2456     2500      +44     
- Partials                    605      633      +28     
Flag Coverage Δ
postgres-18 74.68% <88.24%> (+1.09%) ⬆️
python-3.14 74.68% <88.24%> (+1.09%) ⬆️
unittests 74.68% <88.24%> (+1.09%) ⬆️

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 added 2 commits August 8, 2026 13:21
…de paths

Static-check pass over source and tests touched by the DDL coverage work:
- src: drop unused imports (types, ddl/__init__, named_expressions/partition),
  fix E501 in examples, restore noqa where intentional
- tests: remove unused imports, add E402 noqa to late imports, drop unused
  backend binding var

No behavioral change.; src and changed tests pass ruff.
@sonarqubecloud

sonarqubecloud Bot commented Aug 8, 2026

Copy link
Copy Markdown

@vistart
vistart merged commit acf620e into release/v1.0.0.dev16 Aug 8, 2026
17 checks passed
@vistart vistart mentioned this pull request Aug 15, 2026
8 of 12 tasks
vistart added a commit that referenced this pull request Aug 15, 2026
… CREATE UNLOGGED TABLE (#53)

* feat(backend): add coverage-gap DDL expressions for PostgreSQL

Add expression/mixin/protocol triads covering the remaining PostgreSQL DDL
coverage gaps, each version-gated and exposed through a @runtime_checkable
Protocol:

- RLS table configuration (ENABLE/DISABLE/ALWAYS/FORCE) — PG 9.5+
- ALTER TABLE SET LOGGED/UNLOGGED (9.6+) and SET ACCESS METHOD (15+)
- CLUSTER (index re-cluster) — 9.6+
- CREATE/ALTER/DROP DOMAIN (9.6+; ALTER supports SET DEFAULT/RENAME NOT NULL)
- CREATE/DROP COLLATION objects (9.6+)
- CREATE/DROP FOREIGN TABLE (9.6+)
- CREATE/DROP FUNCTION and CREATE/DROP AGGREGATE (9.6+)
- CREATE/DROP PUBLICATION / SUBSCRIPTION (10+)

PostgresAlterColumnModifierMixin.format_alter_column_action now renders the
ALTER COLUMN ... SET DATA TYPE ... USING (expr) conversion (opt-in via
dialect_options['using']), raising ValueError when used on non-type ops.

PostgreSQL extensions only — core rhosocial-activerecord untouched. Adds
pure-SQL unit tests (no DB) for capability switches, protocol conformance,
and SQL generation. Closes the plan at .claude/plan/2026-08-07
postgres-coverage-gap-analysis.md.

* docs(backend): add JSONExpression type hints to enhanced JSONB mixin and protocol

* feat(backend): complete DDL coverage gaps RENAME and CREATE UNLOGGED TABLE

Plan 4.6/4.7 closure:
- CREATE UNLOGGED TABLE via dialect_options={'unlogged_table': True} on
  CreateTableExpression, version-gated at 9.5+, rendering through
  PostgresTableMixin.format_create_table_statement; TEMPORARY wins over
  UNLOGGED. Exposes supports_unlogged_table on PostgresTableSupport.
- RENAME COLUMN / RENAME TABLE verified through core actions and covered
  by tests (already supported by core DDL; no new mixin needed).

Tests:
- Extend test_alter_table_if_exists.py with ALTER COLUMN SET DATA TYPE
  [USING] and RENAME subclause coverage plus CREATE UNLOGGED TABLE.
- Add plan §6.3 version-baseline sweep at PG 9.6/10/11/14/15/17/19 with
  UnsupportedFeatureError gates.

* test(backend): split DDL expression tests and close DDL mixin coverage gaps

* chore(backend): clean up unused imports and long-line style in DDL code paths

Static-check pass over source and tests touched by the DDL coverage work:
- src: drop unused imports (types, ddl/__init__, named_expressions/partition),
  fix E501 in examples, restore noqa where intentional
- tests: remove unused imports, add E402 noqa to late imports, drop unused
  backend binding var

No behavioral change.; src and changed tests pass ruff.
@vistart
vistart deleted the feature/postgres-ddl-coverage-completion branch October 1, 2026 03:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant