Repository navigation
feat(postgres): Implement field and column mapping support - #2
Merged
Merged
Conversation
- Adds the ype_adapter_tests.sql schema file for PostgreSQL. - Adds the bridge test file est_type_adapter.py to integrate the generic type adapter tests from python-activerecord-testsuite. - Implements the setup_type_adapter_model_and_schema and get_yes_no_adapter methods in ests/providers/basic.py for the PostgreSQL backend.
Introduces `testing.md` for the PostgreSQL backend, detailing its testing setup, integration with the shared test suite, and backend-specific testing practices. Adapts content from the existing MySQL testing guide, ensuring consistency in documentation style and structure. Provides clear instructions on PostgreSQL-specific dependencies (`psycopg`), scenario configuration (`postgres_scenarios.yaml`), and Docker setup. Emphasizes the capability declaration process at backend instantiation and the importance of comprehensive test imports for compatibility. Includes examples for PostgreSQL-specific features like JSONB operators and troubleshooting tips.
Corrects the schema definition for the ype_adapter_tests table in the PostgreSQL backend. The last_login column is now properly defined to store timezone-aware datetime values, resolving the est_optional_datetime_conversion failures. This ensures consistent handling of datetime types between application and PostgreSQL database.
Adds implementation for `setup_annotated_query_fixtures` in `tests/providers/query.py` for the PostgreSQL backend. Creates `searchable_items.sql` schema adapted for PostgreSQL. Introduces `test_annotated_adapter_queries.py` bridge file to run the new generic tests from the testsuite. This enables testing of `Annotated` type adapters in query scenarios for the PostgreSQL backend.
This commit brings the PostgreSQL backend up to date with the latest testing requirements from the core testsuite, specifically for the new field-to-column mapping and type adapter features. - Updated `tests/providers/basic.py` and `tests/providers/query.py` to implement the new required fixture setup methods (`setup_mapped_models`, `setup_mixed_models`, `setup_annotated_query_fixtures`). - Added the necessary test "bridge" files (e.g., `test_field_column_mapping.py`, `test_annotated_adapter_queries.py`) to integrate the generic tests from the testsuite. - Created PostgreSQL-specific versions of the schema files (`posts.sql`, `comments.sql`, etc.) required by the new test cases. - Patched the `insert` and `async insert` methods in the `PostgresBackend` to accept the `column_mapping` argument and correctly handle `SERIAL` primary keys by omitting them from the INSERT statement when their value is None. This resolves the `NotNullViolation` errors. With these changes, all tests in the `feature/basic` and `feature/query` directories now pass for the PostgreSQL backend.
Adds low-level backend tests for the column name mapping feature, targeting both the synchronous and asynchronous PostgreSQL backends. - Introduces `test_column_mapping_backend.py` and `test_async_column_mapping_backend.py` to validate `column_mapping` and `column_adapters` functionality directly against the backend. Additionally, this commit modernizes the project's dependencies: - Replaces separate `psycopg` and `psycopg-binary` packages with the consolidated `psycopg[binary]` dependency. - Makes the `rhosocial-activerecord` core library an explicit dependency in `pyproject.toml` and `requirements.txt` for clarity and better dependency management.
…mapping support [skip ci]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This pull request introduces comprehensive support for field and column mapping within the
rhosocial-activerecord-postgresbackend. It includes implementation for annotated type adapters and direct backend tests, ensuring that custom column names and type conversions work seamlessly with PostgreSQL.Related Issues
Proposed Changes
Annotatedtype adapters, ensuring proper data conversion and validation for fields with custom types.Type of change
Please select all that apply:
feat: A new featuretest: Adding missing tests or correcting existing tests (for the new feature)docs: Documentation only changes (if related to 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 commitBreaking Change
Applicable
rhosocial-activerecordVersion Range:This change is compatible with
rhosocial-activerecordversion==1.0.0.dev14.Related Repositories/Packages
This change is dependent on the
rhosocial-activerecordcore library'sv1.0.0.dev14release, which introduced the core column mapping and annotated type adapter features.Testing
Test Plan:
Ran
pytest tests/rhosocial/activerecord_postgres_test/feature/to verify field and column mapping, as well as annotated adapter functionality.Checklist
README.md, etc.).changelog.d/2.added,fixed.md).Additional Notes
This feature brings
rhosocial-activerecord-postgresup to date with the latest data modeling capabilities of the core library.