Skip to content

Release v1.0.0.dev8 - #18

Merged
vistart merged 11 commits into
mainfrom
release/v1.0.0.dev8
Apr 5, 2026
Merged

vistart merged 11 commits into
mainfrom
release/v1.0.0.dev8

Conversation

@vistart

@vistart vistart commented Apr 5, 2026

Copy link
Copy Markdown
Contributor

Release v1.0.0.dev8

Summary

This release adds EXPLAIN clause support, connection recovery, CLI improvements, and parallel worker processing support for PostgreSQL backend.

Changes

Added

Fixed

  • Fix worker test directory issues for pytest 8.x compatibility
  • Rename worker test file to avoid name conflict

Changed

  • Refactor introspection tests to eliminate tests.* imports
  • Switch testsuite dependency from git to PyPI (v1.0.0.dev8)
  • Use PyPI source for rhosocial-activerecord dependency (v1.0.0.dev21)

Commits

Commit Description
e215146 ci: use PyPI source for rhosocial-activerecord dependency
f99aa77 ci: switch testsuite from git to PyPI (v1.0.0.dev8)
0588eed ci: trigger CI after core package update
2f5200a fix: rename worker test file to avoid name conflict
757f03e fix: fix worker test directory issues for pytest 8.x compatibility
8a7f11c feat(test,docs): add parallel worker processing support
b318ac7 feat(cli): improve info command with connection status and add introspect usage examples (#17)
afc3c1f feat(backend): add EXPLAIN clause support and connection recovery for PostgreSQL (#16)
d042c21 refactor(test): eliminate tests.* imports in introspection tests
3225ca6 chore: bump version to 1.0.0.dev8

Version

  • Version: 1.0.0.dev8
  • Release Branch: release/v1.0.0.dev8
  • Target Branch: main

Checklist

  • Version bumped in pyproject.toml
  • Changelog fragment created (not required for dev release)
  • Tests passed (skipped by user)
  • Ready for review

Related PRs

vistart and others added 10 commits March 29, 2026 11:43
Replace `from tests.providers.scenarios` and `from tests.rhosocial...`
imports with local implementations to match the coding style used in
other test files.

This ensures tests can run with both `pytest tests/` and
`python -m pytest tests/` without path issues.
… PostgreSQL (#16)

* feat(backend): add explain() interface with typed PostgresExplainResult

Implement backend.explain(expression, options) for PostgresBackend and
AsyncPostgresBackend, following the sync/async parity principle.

Changes:
- New postgres/explain/ submodule with PostgresExplainPlanLine (wraps
  the single "QUERY PLAN" column per row) and PostgresExplainResult
  with analyze_index_usage() / is_full_scan / is_index_used /
  is_covering_index helpers (text-matching on Seq Scan / Index Scan /
  Index Only Scan keywords)
- PostgresBackend and AsyncPostgresBackend now mixin
  SyncExplainBackendMixin and AsyncExplainBackendMixin respectively
- Override _parse_explain_result() to extract "QUERY PLAN" key from
  each raw row and construct typed PostgresExplainPlanLine objects
- Add format_explain_statement() to PostgresDialect using PostgreSQL
  bracket-option syntax: EXPLAIN [(ANALYZE, FORMAT JSON)] stmt
- Export PostgresExplainResult and PostgresExplainPlanLine from the
  package __init__ (postgres execute() already included EXPLAIN in its
  DQL detection tuple — no fix needed)
- Add integration tests covering protocol check, result structure,
  full-scan / index detection, EXPLAIN ANALYZE, and async parity

* fix(dialect): return complete (sql, params) tuple from format_explain_statement

The overridden format_explain_statement() in PostgresDialect was returning
a plain str (the EXPLAIN prefix only), while ExplainExpression.to_sql()
passes the return value directly to backend_mixin which unpacks it as
(sql, params). This caused a ValueError at runtime.

Fix by building the full EXPLAIN SQL string inside the method and
returning (sql, params) consistent with the base class contract.

Also fix test_backend_explain.py: replace executescript() calls (a
MySQL-only method) with per-statement execute() calls, matching the
pattern used in all other PostgreSQL backend tests.

Add EXPLAIN documentation (en_US and zh_CN) and update the feature
index README files.

* feat(backend): add dual-layer connection recovery for PostgreSQL

Implement automatic reconnection mechanism with two layers:
- Plan A: Pre-query connection check in _get_cursor() using psycopg's
  closed/broken attributes
- Plan B: Error retry mechanism in execute() detecting connection
  errors via SQLSTATE codes and error message patterns

Supported connection error SQLSTATE codes:
- 08000-08007: Connection exception class
- 57P01-57P04: Server shutdown class

Added fixtures for connection resilience testing and comprehensive
documentation covering connection loss scenarios and recovery behavior.

* ci: update rhosocial-activerecord installation source to git+https

Install from release/v1.0.0.dev21 branch instead of PyPI dev20.

* chore: add changelog fragment for PR #16
…pect usage examples (#17)

* feat(cli): improve info command with connection status and add introspect usage examples

- Display connection status in info command output
  - Show "(from actual connection)" when connected to database
  - Show "(default value - no database connection)" when not connected
  - Use actual dialect from backend instead of creating new instance
  - Display installed extensions when connected
- Add detailed usage examples to introspect subcommand help
  - Examples for all introspection types (tables, views, columns, etc.)
  - JSON output example
  - Schema parameter example (PostgreSQL specific)
  - Environment variables connection example

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* chore: add changelog fragment for PR #17

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
- Add WorkerTestProtocol implementation to BasicProvider and QueryProvider
- Add supports_for_update() method to PostgresDialect
- Add worker pool tests for basic and query features:
  - Worker pool lifecycle management
  - Parallel CRUD operations
  - Connection management
  - Parallel query execution
  - Transaction isolation
- Add parallel workers scenario documentation (EN/CN)
- Add parallel workers example code
- Update CI to use git branch for testsuite installation
- Remove conftest.py files with pytest_plugins (not allowed in non-top-level)
- Remove __init__.py files that cause module resolution conflicts
- Fix bridge files to import correct fixtures (user_class_for_worker)
Renamed test_transaction_isolation.py to test_worker_transaction_isolation.py
to avoid conflict with feature/backend/test_transaction_isolation.py
Change installation source from GitHub to PyPI for rhosocial-activerecord,
fixed at version 1.0.0.dev21. This simplifies dependency management and
aligns with the package being published to PyPI.
@vistart vistart self-assigned this Apr 5, 2026
@vistart vistart added the release label Apr 5, 2026
@codecov

codecov Bot commented Apr 5, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 52.58216% with 101 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.70%. Comparing base (d659c46) to head (13aa6a4).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...ord/backend/impl/postgres/backend/async_backend.py 46.25% 34 Missing and 9 partials ⚠️
...activerecord/backend/impl/postgres/backend/sync.py 46.25% 34 Missing and 9 partials ⚠️
...ctiverecord/backend/impl/postgres/explain/types.py 75.00% 5 Missing and 3 partials ⚠️
...cial/activerecord/backend/impl/postgres/dialect.py 61.11% 4 Missing and 3 partials ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             main      #18    +/-   ##
========================================
  Coverage   71.69%   71.70%            
========================================
  Files         110      112     +2     
  Lines        6030     6191   +161     
  Branches      959      991    +32     
========================================
+ Hits         4323     4439   +116     
- Misses       1415     1440    +25     
- Partials      292      312    +20     
Flag Coverage Δ
postgres-18 71.70% <52.58%> (+<0.01%) ⬆️
python-3.14 71.70% <52.58%> (+<0.01%) ⬆️
unittests 71.70% <52.58%> (+<0.01%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 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.

@sonarqubecloud

sonarqubecloud Bot commented Apr 5, 2026

Copy link
Copy Markdown

@vistart
vistart merged commit 3eb7096 into main Apr 5, 2026
23 of 24 checks passed
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