Repository navigation
Commit dc5967f
authored
chore: PostgreSQL backend adaptation to new expression-dialect architecture (#4)
* feat(postgres): Refactor dialect formatting for SQL injection prevention and add RICH_AVAILABLE check
- Refactored ormat_limit_offset in dialect.py to separate SQL fragments and parameters.
- Added RICH_AVAILABLE check to __main__.py for conditional rich output.
* fix(postgres): parameterize LIMIT/OFFSET in PostgresDialect
Updated the `format_limit_offset` method in `PostgresDialect` to
return a tuple of `(sql_fragment, params_list)`. This change
aligns with the new parameterization strategy, ensuring that LIMIT
and OFFSET values are passed as parameters instead of being
embedded directly into the SQL string.
* feat(postgres): migrate backend to modern Mixin+Protocol architecture
- Replace old capabilities system with modern Mixin+Protocol architecture
- Update backend.py to use new StorageBackend base class
- Implement async backend with async/await support using psycopg
- Add async transaction manager for PostgreSQL
- Remove dependency on deprecated capabilities module
- Maintain all PostgreSQL-specific behaviors and features
- Ensure version-specific feature support remains intact
- Update imports to use correct module paths (DatabaseType, TypeMapping)
BREAKING CHANGE: Removes old capabilities system in favor of protocol-based architecture
* feat: Add async implementations for basic and query providers and test files
- Add async methods to BasicProvider and QueryProvider
- Update test files to include async fixtures
- Ensure parity between sync and async functionality
- Update schema files to support both sync and async models
* feat: Update backend implementations with proper execute method signatures
- Add async implementations for all backend methods
- Update execute methods to accept options parameter while maintaining backward compatibility
- Add missing methods like ping and _handle_error
- Ensure sync/async parity across all implementations
* feat(postgres): enhance PostgreSQL backend implementation with proper transaction management
- Fix transaction manager initialization for both sync and async backends
- Add proper auto-commit handling for PostgreSQL
- Enhance error handling for PostgreSQL-specific errors (duplicate keys, foreign key constraints, deadlocks)
- Implement get_default_adapter_suggestions method for both sync and async backends
- Align PostgreSQL backend implementation with base class requirements
- Follow SQLite implementation patterns for consistency
- Improve async transaction manager with complete async method implementations
- Ensure proper connection handling in transaction managers
- Add proper isolation level support for PostgreSQL transactions
* Add codex instructions
- Add codex.md with project-specific guidance
- Reference shared .gemini guidelines via relative paths
* fix: add placeholder conversion and async provider support
- Add _prepare_sql_and_params to convert '?' to '%s' for PostgreSQL
- Add async provider methods for PostgreSQL basic tests
- Add _active_async_backends tracking for proper cleanup
* refactor(postgres): consolidate transaction management and improve async support
- Merge AsyncPostgresTransactionManager into transaction.py module
- Add PostgresListAdapter for native PostgreSQL array type handling
- Improve connection parameter handling in async backend
- Add proper async test support in providers
- Enable pytest asyncio auto mode
* docs: add comprehensive documentation and query test bridges
- Rename .gemini/ to .claude/ for consistency with other repos
- Add complete bilingual documentation (en_US/zh_CN) covering:
- Introduction and supported versions
- Installation and configuration
- PostgreSQL-specific features (JSONB, arrays, UUID, etc.)
- Transaction support with isolation levels
- Type adapters for Python-PostgreSQL mapping
- Testing guide with parallel execution warning
- Troubleshooting for common issues
- Add query test bridge files for testsuite integration
* fix: update basic test schemas for PostgreSQL compatibility
- mixed_annotation_items.sql: Change id INT to SERIAL for auto-increment
- type_adapter_tests.sql: Increase VARCHAR length from 3 to 10 for custom_bool fields
These changes allow basic tests to pass when using custom column mappings with UseColumn annotations.
* fix: share backend instance across related models and use native TEXT[] for tags
- Fix _setup_multiple_models to share a single backend instance across all
related models, resolving foreign key constraint failures when setting up
tables with dependencies
- Change tags column from TEXT to TEXT[] to leverage PostgreSQL's native array
support for list fields
- Add PostgreSQL-specific PostgresMixedAnnotationModel with native list type
annotation for tags field
* docs: add array type comparison documentation
- Add array_comparison.md (EN/CN) comparing PostgreSQL arrays with
databases without native array support
- Update arrays.md with corrected operator syntax examples
- Add link to array_comparison.md in README.md
The documentation covers:
- Native array support differences
- Array operators (@>, &&, ANY(), ALL(), array_length)
- Portability strategies for multi-database projects
* docs: revamp README to AI-guided exploration style
* docs: add provider responsibilities to testing documentation
- Add Provider Responsibilities section to testing README
- Document cleanup order requirements: DROP TABLE → Close Cursors → Disconnect
- Document PostgreSQL-specific considerations (custom types)
* test: remove unreferenced testsuite files and update postgres backend
- Remove testsuite test files that are no longer referenced:
- test_function_expressions.py
- test_grouped_aggregate.py
- test_joins_2.py
- test_relation_cache.py
- test_relation_path_processing.py
- test_relations_complex.py
- Update postgres backend implementation files
* test(backend): rewrite PostgreSQL backend tests for new architecture
- Remove deprecated expression tests using old create_expression API
- Rewrite CRUD, transaction, dialect, and column mapping tests
- Fix version test to remove non-working cache check
- Fix adapters test for correct supported_types structure
- Fix async transaction test to avoid direct autocommit manipulation
* chore: add changelog fragment and update CI sources for backend dialect formatting1 parent 69c65e1 commit dc5967f
154 files changed
Lines changed: 6742 additions & 4008 deletions
File tree
- .claude
- .github/workflows
- changelog.d
- docs
- en_US
- installation_and_configuration
- introduction
- postgres_specific_features
- testing
- transaction_support
- troubleshooting
- type_adapters
- zh_CN
- installation_and_configuration
- introduction
- postgres_specific_features
- testing
- transaction_support
- troubleshooting
- type_adapters
- src/rhosocial/activerecord/backend/impl/postgres
- tests
- providers
- rhosocial/activerecord_postgres_test/feature
- backend
- basic
- fixtures
- schema
- query
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
File renamed without changes.
File renamed without changes.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
201 | 201 | | |
202 | 202 | | |
203 | 203 | | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
71 | | - | |
| 70 | + | |
| 71 | + | |
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| |||
0 commit comments