feat: Add timezone-aware datetime support for PostgreSQL - #10535
feat: Add timezone-aware datetime support for PostgreSQL#10535Cristhianzl wants to merge 10 commits into
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThis pull request adds timezone-aware datetime support for PostgreSQL backends by introducing an Alembic migration that converts datetime columns to timezone-aware types, updating seven database models to explicitly specify Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Suggested labels
Suggested reviewers
Pre-merge checks and finishing touchesImportant Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional. ❌ Failed checks (1 error, 2 warnings)
✅ Passed checks (4 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. ❌ Your project status has failed because the head coverage (40.81%) is below the target coverage (60.00%). You can increase the head coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #10535 +/- ##
==========================================
- Coverage 34.25% 33.71% -0.54%
==========================================
Files 1409 1356 -53
Lines 66892 65334 -1558
Branches 9860 9465 -395
==========================================
- Hits 22912 22030 -882
+ Misses 42787 42278 -509
+ Partials 1193 1026 -167
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 3
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (11)
src/backend/base/langflow/alembic/versions/c8613607a100_add_timezone_support_for_asyncpg_.py(1 hunks)src/backend/base/langflow/services/database/models/api_key/model.py(1 hunks)src/backend/base/langflow/services/database/models/file/model.py(2 hunks)src/backend/base/langflow/services/database/models/flow/model.py(2 hunks)src/backend/base/langflow/services/database/models/message/model.py(2 hunks)src/backend/base/langflow/services/database/models/transactions/model.py(1 hunks)src/backend/base/langflow/services/database/models/user/model.py(2 hunks)src/backend/base/langflow/services/database/models/vertex_builds/model.py(1 hunks)src/backend/tests/integration/drivers/conftest.py(1 hunks)src/backend/tests/integration/drivers/test_postgresql_drivers.py(1 hunks)src/backend/tests/unit/test_datetime_timezone.py(1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
{src/backend/**/*.py,tests/**/*.py,Makefile}
📄 CodeRabbit inference engine (.cursor/rules/backend_development.mdc)
{src/backend/**/*.py,tests/**/*.py,Makefile}: Run make format_backend to format Python code before linting or committing changes
Run make lint to perform linting checks on backend Python code
Files:
src/backend/tests/integration/drivers/conftest.pysrc/backend/tests/unit/test_datetime_timezone.pysrc/backend/base/langflow/services/database/models/flow/model.pysrc/backend/base/langflow/services/database/models/transactions/model.pysrc/backend/base/langflow/services/database/models/file/model.pysrc/backend/base/langflow/services/database/models/api_key/model.pysrc/backend/tests/integration/drivers/test_postgresql_drivers.pysrc/backend/base/langflow/services/database/models/message/model.pysrc/backend/base/langflow/alembic/versions/c8613607a100_add_timezone_support_for_asyncpg_.pysrc/backend/base/langflow/services/database/models/user/model.pysrc/backend/base/langflow/services/database/models/vertex_builds/model.py
src/backend/tests/**/*.py
📄 CodeRabbit inference engine (.cursor/rules/testing.mdc)
src/backend/tests/**/*.py: Unit tests for backend code must be located in the 'src/backend/tests/' directory, with component tests organized by component subdirectory under 'src/backend/tests/unit/components/'.
Test files should use the same filename as the component under test, with an appropriate test prefix or suffix (e.g., 'my_component.py' → 'test_my_component.py').
Use the 'client' fixture (an async httpx.AsyncClient) for API tests in backend Python tests, as defined in 'src/backend/tests/conftest.py'.
When writing component tests, inherit from the appropriate base class in 'src/backend/tests/base.py' (ComponentTestBase, ComponentTestBaseWithClient, or ComponentTestBaseWithoutClient) and provide the required fixtures: 'component_class', 'default_kwargs', and 'file_names_mapping'.
Each test in backend Python test files should have a clear docstring explaining its purpose, and complex setups or mocks should be well-commented.
Test both sync and async code paths in backend Python tests, using '@pytest.mark.asyncio' for async tests.
Mock external dependencies appropriately in backend Python tests to isolate unit tests from external services.
Test error handling and edge cases in backend Python tests, including using 'pytest.raises' and asserting error messages.
Validate input/output behavior and test component initialization and configuration in backend Python tests.
Use the 'no_blockbuster' pytest marker to skip the blockbuster plugin in tests when necessary.
Be aware of ContextVar propagation in async tests; test both direct event loop execution and 'asyncio.to_thread' scenarios to ensure proper context isolation.
Test error handling by mocking internal functions using monkeypatch in backend Python tests.
Test resource cleanup in backend Python tests by using fixtures that ensure proper initialization and cleanup of resources.
Test timeout and performance constraints in backend Python tests using 'asyncio.wait_for' and timing assertions.
Test Langflow's Messag...
Files:
src/backend/tests/integration/drivers/conftest.pysrc/backend/tests/unit/test_datetime_timezone.pysrc/backend/tests/integration/drivers/test_postgresql_drivers.py
src/backend/tests/unit/**/*.py
📄 CodeRabbit inference engine (.cursor/rules/backend_development.mdc)
Test component integration within flows using create_flow, build_flow, and get_build_events utilities
Files:
src/backend/tests/unit/test_datetime_timezone.py
src/backend/base/langflow/services/database/models/**/*.py
📄 CodeRabbit inference engine (.cursor/rules/backend_development.mdc)
Place database models in src/backend/base/langflow/services/database/models/
Files:
src/backend/base/langflow/services/database/models/flow/model.pysrc/backend/base/langflow/services/database/models/transactions/model.pysrc/backend/base/langflow/services/database/models/file/model.pysrc/backend/base/langflow/services/database/models/api_key/model.pysrc/backend/base/langflow/services/database/models/message/model.pysrc/backend/base/langflow/services/database/models/user/model.pysrc/backend/base/langflow/services/database/models/vertex_builds/model.py
🧠 Learnings (19)
📚 Learning: 2025-07-21T14:16:14.125Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-21T14:16:14.125Z
Learning: Applies to src/backend/tests/**/*.py : Use the 'client' fixture (an async httpx.AsyncClient) for API tests in backend Python tests, as defined in 'src/backend/tests/conftest.py'.
Applied to files:
src/backend/tests/integration/drivers/conftest.py
📚 Learning: 2025-07-18T18:25:54.486Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-07-18T18:25:54.486Z
Learning: Applies to tests/**/*.py : Use the client fixture from conftest.py for API endpoint tests
Applied to files:
src/backend/tests/integration/drivers/conftest.py
📚 Learning: 2025-07-21T14:16:14.125Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-21T14:16:14.125Z
Learning: Applies to conftest.py : Use 'conftest.py' to define and share fixtures for backend Python tests.
Applied to files:
src/backend/tests/integration/drivers/conftest.py
📚 Learning: 2025-07-21T14:16:14.125Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-21T14:16:14.125Z
Learning: Applies to src/backend/tests/**/*.py : Test resource cleanup in backend Python tests by using fixtures that ensure proper initialization and cleanup of resources.
Applied to files:
src/backend/tests/integration/drivers/conftest.pysrc/backend/tests/integration/drivers/test_postgresql_drivers.py
📚 Learning: 2025-07-21T14:16:14.125Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-21T14:16:14.125Z
Learning: Applies to src/backend/tests/**/*.py : Mock external dependencies appropriately in backend Python tests to isolate unit tests from external services.
Applied to files:
src/backend/tests/integration/drivers/conftest.pysrc/backend/tests/unit/test_datetime_timezone.pysrc/backend/tests/integration/drivers/test_postgresql_drivers.py
📚 Learning: 2025-07-18T18:25:54.486Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-07-18T18:25:54.486Z
Learning: Applies to tests/**/*.py : Use in-memory SQLite for database tests
Applied to files:
src/backend/tests/integration/drivers/conftest.py
📚 Learning: 2025-07-21T14:16:14.125Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-21T14:16:14.125Z
Learning: Applies to src/backend/tests/**/*.py : Test timeout and performance constraints in backend Python tests using 'asyncio.wait_for' and timing assertions.
Applied to files:
src/backend/tests/unit/test_datetime_timezone.pysrc/backend/tests/integration/drivers/test_postgresql_drivers.py
📚 Learning: 2025-07-21T14:16:14.125Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-21T14:16:14.125Z
Learning: Applies to src/backend/tests/**/*.py : Be aware of ContextVar propagation in async tests; test both direct event loop execution and 'asyncio.to_thread' scenarios to ensure proper context isolation.
Applied to files:
src/backend/tests/unit/test_datetime_timezone.pysrc/backend/tests/integration/drivers/test_postgresql_drivers.py
📚 Learning: 2025-07-21T14:16:14.125Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-21T14:16:14.125Z
Learning: Applies to src/backend/tests/**/*.py : Test both sync and async code paths in backend Python tests, using 'pytest.mark.asyncio' for async tests.
Applied to files:
src/backend/tests/unit/test_datetime_timezone.pysrc/backend/tests/integration/drivers/test_postgresql_drivers.py
📚 Learning: 2025-07-18T18:25:54.486Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-07-18T18:25:54.486Z
Learning: Applies to src/backend/tests/unit/components/**/*.py : Create comprehensive unit tests for all new components
Applied to files:
src/backend/tests/unit/test_datetime_timezone.pysrc/backend/tests/integration/drivers/test_postgresql_drivers.py
📚 Learning: 2025-07-21T14:16:14.125Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-21T14:16:14.125Z
Learning: Applies to src/backend/tests/**/*.py : Validate input/output behavior and test component initialization and configuration in backend Python tests.
Applied to files:
src/backend/tests/unit/test_datetime_timezone.pysrc/backend/tests/integration/drivers/test_postgresql_drivers.py
📚 Learning: 2025-07-21T14:16:14.125Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-21T14:16:14.125Z
Learning: Applies to src/backend/tests/**/*.py : Test error handling by mocking internal functions using monkeypatch in backend Python tests.
Applied to files:
src/backend/tests/unit/test_datetime_timezone.py
📚 Learning: 2025-07-21T14:16:14.125Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-21T14:16:14.125Z
Learning: Applies to src/backend/tests/**/*.py : Use 'anyio' and 'aiofiles' for async file operations in backend Python tests that involve file handling.
Applied to files:
src/backend/tests/unit/test_datetime_timezone.pysrc/backend/tests/integration/drivers/test_postgresql_drivers.py
📚 Learning: 2025-07-21T14:16:14.125Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-21T14:16:14.125Z
Learning: Applies to src/backend/tests/**/*.py : Test real-time event streaming endpoints in backend Python tests by consuming and validating NDJSON event streams.
Applied to files:
src/backend/tests/unit/test_datetime_timezone.py
📚 Learning: 2025-07-21T14:16:14.125Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-21T14:16:14.125Z
Learning: Applies to src/backend/tests/**/*.py : Test error handling and edge cases in backend Python tests, including using 'pytest.raises' and asserting error messages.
Applied to files:
src/backend/tests/unit/test_datetime_timezone.py
📚 Learning: 2025-07-21T14:16:14.125Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-21T14:16:14.125Z
Learning: Applies to src/backend/tests/unit/test_database.py : For database-related tests that may fail in batch runs but pass individually, consider running them sequentially and be aware of this behavior when writing such tests.
Applied to files:
src/backend/tests/unit/test_datetime_timezone.pysrc/backend/tests/integration/drivers/test_postgresql_drivers.py
📚 Learning: 2025-07-21T14:16:14.125Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-21T14:16:14.125Z
Learning: Applies to src/backend/tests/**/*.py : Test Langflow's REST API endpoints in backend Python tests using the async client fixture and asserting response codes and payloads.
Applied to files:
src/backend/tests/unit/test_datetime_timezone.pysrc/backend/tests/integration/drivers/test_postgresql_drivers.py
📚 Learning: 2025-07-18T18:25:54.486Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-07-18T18:25:54.486Z
Learning: Applies to src/backend/base/langflow/services/database/models/**/*.py : Place database models in src/backend/base/langflow/services/database/models/
Applied to files:
src/backend/base/langflow/services/database/models/flow/model.pysrc/backend/base/langflow/services/database/models/transactions/model.pysrc/backend/base/langflow/services/database/models/file/model.pysrc/backend/base/langflow/services/database/models/vertex_builds/model.py
📚 Learning: 2025-07-21T14:16:14.125Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-21T14:16:14.125Z
Learning: Applies to src/backend/tests/**/*.py : Test backward compatibility across Langflow versions in backend Python tests by mapping component files to supported versions using 'VersionComponentMapping'.
Applied to files:
src/backend/tests/integration/drivers/test_postgresql_drivers.py
🧬 Code graph analysis (3)
src/backend/tests/unit/test_datetime_timezone.py (6)
src/backend/base/langflow/services/database/models/api_key/model.py (1)
ApiKey(25-36)src/backend/base/langflow/services/database/models/flow/model.py (1)
Flow(188-214)src/backend/base/langflow/services/database/models/message/model.py (1)
MessageTable(126-171)src/backend/base/langflow/services/database/models/user/model.py (1)
User(25-55)src/backend/base/langflow/services/database/utils.py (1)
session_getter(65-74)src/backend/base/langflow/services/deps.py (1)
get_db_service(138-147)
src/backend/base/langflow/services/database/models/transactions/model.py (1)
src/backend/base/langflow/serialization/serialization.py (3)
get_max_items_length(37-39)get_max_text_length(31-33)serialize(253-305)
src/backend/base/langflow/services/database/models/vertex_builds/model.py (1)
src/backend/base/langflow/serialization/serialization.py (3)
get_max_items_length(37-39)get_max_text_length(31-33)serialize(253-305)
🪛 GitHub Actions: Ruff Style Check
src/backend/tests/integration/drivers/conftest.py
[error] 1-1: INP001: File is part of an implicit namespace package. Add an init.py.
🪛 GitHub Check: Ruff Style Check (3.13)
src/backend/tests/integration/drivers/conftest.py
[failure] 1-1: Ruff (INP001)
src/backend/tests/integration/drivers/conftest.py:1:1: INP001 File src/backend/tests/integration/drivers/conftest.py is part of an implicit namespace package. Add an __init__.py.
src/backend/tests/integration/drivers/test_postgresql_drivers.py
[failure] 1-1: Ruff (INP001)
src/backend/tests/integration/drivers/test_postgresql_drivers.py:1:1: INP001 File src/backend/tests/integration/drivers/test_postgresql_drivers.py is part of an implicit namespace package. Add an __init__.py.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (16)
- GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 3
- GitHub Check: Run Backend Tests / Integration Tests - Python 3.10
- GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 5
- GitHub Check: Run Frontend Tests / Determine Test Suites and Shard Distribution
- GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 4
- GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 2
- GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 1
- GitHub Check: Run Backend Tests / LFX Tests - Python 3.10
- GitHub Check: Run Backend Tests / Test CLI - Python 3.10
- GitHub Check: Lint Backend / Run Mypy (3.13)
- GitHub Check: Lint Backend / Run Mypy (3.10)
- GitHub Check: Lint Backend / Run Mypy (3.12)
- GitHub Check: Test Starter Templates
- GitHub Check: Update Component Index
- GitHub Check: Update Starter Projects
- GitHub Check: Optimize new Python code in this PR
🔇 Additional comments (13)
src/backend/base/langflow/services/database/models/api_key/model.py (1)
20-20: LGTM! Timezone-aware mapping aligns with migration.The
last_used_atfield correctly maps to a timezone-aware SQLAlchemy column, matching the migration changes for PostgreSQL.src/backend/base/langflow/services/database/models/transactions/model.py (2)
5-6: LGTM! Import updated to support timezone-aware column.The DateTime import is correctly added to support the sa_column usage in the timestamp field.
12-14: LGTM! Timezone-aware timestamp aligns with migration.The
timestampfield correctly maps to a timezone-aware SQLAlchemy column with UTC default, matching the migration for the transaction table.src/backend/base/langflow/services/database/models/file/model.py (2)
4-4: LGTM! Import updated to support timezone-aware columns.The DateTime import is correctly added to support the sa_column usage in the timestamp fields.
17-22: LGTM! Timezone-aware timestamps align with migration.Both
created_atandupdated_atfields correctly map to timezone-aware SQLAlchemy columns with UTC defaults, matching the migration for the file table.src/backend/base/langflow/services/database/models/message/model.py (2)
7-7: LGTM! Import updated to support timezone-aware column.The DateTime import is correctly added to support the sa_column usage in the timestamp field.
19-20: LGTM! Timezone-aware timestamp aligns with migration.The
timestampfield correctly maps to a timezone-aware SQLAlchemy column, matching the migration for the message table. The existing serializer at lines 35-45 properly handles timezone conversion.src/backend/base/langflow/services/database/models/vertex_builds/model.py (2)
5-5: LGTM! Import updated to support timezone-aware column.The DateTime import is correctly added to support the sa_column usage in the timestamp field.
12-14: LGTM! Timezone-aware timestamp aligns with migration.The
timestampfield correctly maps to a timezone-aware SQLAlchemy column with UTC default, matching the migration for the vertex_build table. The serializer at lines 35-40 properly handles timezone conversion.src/backend/base/langflow/alembic/versions/c8613607a100_add_timezone_support_for_asyncpg_.py (2)
21-111: LGTM! Migration correctly implements PostgreSQL-specific timezone support.The upgrade function properly:
- Gates changes to PostgreSQL only (line 26), avoiding SQLite incompatibility
- Converts datetime columns to timezone-aware types across all affected tables
- Preserves nullable constraints for each column
- Aligns with the model changes in this PR
114-203: LGTM! Downgrade path is complete and correct.The downgrade function provides a proper rollback path by reverting all timezone-aware columns back to timezone-naive types while preserving the original nullable constraints.
src/backend/base/langflow/services/database/models/flow/model.py (2)
14-14: LGTM! Imports updated to support timezone-aware column.The DateTime import is correctly added to support the sa_column usage in the updated_at field.
43-45: LGTM! Timezone-aware timestamp aligns with migration.The
updated_atfield correctly maps to a timezone-aware SQLAlchemy column with UTC default, matching the migration for the flow table. The serializer at lines 166-175 properly handles timezone conversion to ISO format.
| """Conftest for PostgreSQL driver tests. | ||
|
|
||
| This conftest overrides the _start_app fixture from the parent integration/conftest.py | ||
| to prevent it from loading the client fixture, which would override the database URL. | ||
| """ | ||
|
|
||
| import pytest | ||
|
|
||
|
|
||
| @pytest.fixture(autouse=True) | ||
| def _start_app(): | ||
| """Override parent _start_app fixture to skip client loading. | ||
|
|
||
| PostgreSQL driver tests create their own database connections | ||
| and don't need the app client fixture. | ||
| """ | ||
| # Do nothing - this prevents the parent fixture from running | ||
| return |
There was a problem hiding this comment.
Add __init__.py to resolve namespace package error.
The static analysis tool and pipeline both flag that this file is part of an implicit namespace package. To resolve this, create an __init__.py file in the src/backend/tests/integration/drivers/ directory.
To fix this, create an empty __init__.py file:
#!/bin/bash
touch src/backend/tests/integration/drivers/__init__.py🧰 Tools
🪛 GitHub Actions: Ruff Style Check
[error] 1-1: INP001: File is part of an implicit namespace package. Add an init.py.
🪛 GitHub Check: Ruff Style Check (3.13)
[failure] 1-1: Ruff (INP001)
src/backend/tests/integration/drivers/conftest.py:1:1: INP001 File src/backend/tests/integration/drivers/conftest.py is part of an implicit namespace package. Add an __init__.py.
🤖 Prompt for AI Agents
In src/backend/tests/integration/drivers/conftest.py lines 1-18: static analysis
reports this module is part of an implicit namespace package; fix by adding an
empty __init__.py in the same directory
(src/backend/tests/integration/drivers/__init__.py) so the package is explicit
and import resolution/static analysis pass; create the file with normal text
file permissions (empty content is fine).
| """Integration tests for PostgreSQL driver compatibility. | ||
|
|
||
| This test suite validates that DateTime(timezone=True) works with: | ||
| - asyncpg (async PostgreSQL driver) | ||
| - psycopg (modern async/sync driver) | ||
| - psycopg2 (legacy sync driver) | ||
|
|
||
| These tests only run on PostgreSQL databases. | ||
|
|
||
| Related to: Migration c8613607a100_add_timezone_support_for_asyncpg | ||
| GitHub Issue: Verizon case - asyncpg compatibility | ||
| """ |
There was a problem hiding this comment.
Add package initializer for Ruff compliance.
Ruff is failing with INP001 because src/backend/tests/integration/drivers/ is now an implicit namespace package. Please add an empty __init__.py (or otherwise adjust the package layout) so the linter passes.
🧰 Tools
🪛 GitHub Check: Ruff Style Check (3.13)
[failure] 1-1: Ruff (INP001)
src/backend/tests/integration/drivers/test_postgresql_drivers.py:1:1: INP001 File src/backend/tests/integration/drivers/test_postgresql_drivers.py is part of an implicit namespace package. Add an __init__.py.
🤖 Prompt for AI Agents
In src/backend/tests/integration/drivers/ around lines 1-12 the directory is an
implicit namespace package causing Ruff INP001; add a new file
src/backend/tests/integration/drivers/__init__.py (can be empty or contain a
brief module docstring or __all__ = []) to make it an explicit package, commit
that file so the linter recognizes the package and rerun tests/CI.
| @pytest.mark.api_key_required | ||
| async def test_user_create_with_timezone_aware_datetime(): | ||
| """Test that User model accepts timezone-aware datetimes.""" | ||
| now = datetime.now(timezone.utc) | ||
|
|
||
| async with session_getter(get_db_service()) as session: | ||
| user = User( | ||
| id=uuid4(), |
There was a problem hiding this comment.
Mark async tests with pytest.mark.asyncio.
Every test here is async def, but there’s no pytest.mark.asyncio (module-level or per test). Per our testing guidelines this marker is required so pytest-asyncio actually runs these coroutines instead of erroring out. Please add a module-level mark right after the imports, e.g.:
from uuid import uuid4
import pytest
+pytestmark = pytest.mark.asyncio
+Committable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
In src/backend/tests/unit/test_datetime_timezone.py around lines 23 to 30, the
async test functions lack the pytest-asyncio marker so pytest won't run
coroutines; add the required marker by either applying @pytest.mark.asyncio to
each async test or (preferred) adding a module-level pytestmark =
pytest.mark.asyncio immediately after the imports to mark all tests in this file
as asyncio.
|
|
||
| # Only apply changes if using PostgreSQL | ||
| # SQLite and other databases don't have timezone-aware datetime types | ||
| if conn.dialect.name == "postgresql": |
There was a problem hiding this comment.
@Cristhianzl let's add a paragraph explaining why we're doing this migration somewhere in this file. I think that'll be good practice for future changes, and easier than digging through commit history to find a PR description (especially if we do any refactoring).
|
|
|
|
|
|
|
|
|
|
This pull request adds comprehensive timezone-aware datetime support for PostgreSQL compatibility across all major database models and updates the Alembic migration to reflect these changes. The main focus is to ensure all relevant timestamp fields in the models and database tables use timezone-aware datetimes, improving consistency and compatibility, especially when using asyncpg with PostgreSQL. Additionally, a new conftest file is introduced to support PostgreSQL-specific integration tests.
Database schema and model updates for timezone support:
c8613607a100) that alters relevant datetime columns in the PostgreSQL database to useTIMESTAMP WITH TIME ZONE, and provides a downgrade path to revert to timezone-naive columns. The migration covers tables:user,apikey,flow,message,file,transaction, andvertex_build.User,ApiKey,File,Flow,Message,Transaction, andVertexBuildto use SQLAlchemy'sDateTime(timezone=True)for their datetime columns, ensuring the ORM layer matches the database schema. [1] [2] [3] [4] [5] [6] [7]Codebase imports and consistency:
DateTimefrom SQLAlchemy in all relevant model files to support the new timezone-aware columns. [1] [2] [3] [4] [5]Testing infrastructure:
conftest.pyfor PostgreSQL driver integration tests, overriding the default app startup fixture to prevent interference with test database URLs.Summary by CodeRabbit