Skip to content

fix(#152): match issued_at default to naive column schema#166

Merged
winwinashwin merged 1 commit into
corridor:mainfrom
Anubhav-2003:fix-issue-152
Apr 28, 2026
Merged

fix(#152): match issued_at default to naive column schema#166
winwinashwin merged 1 commit into
corridor:mainfrom
Anubhav-2003:fix-issue-152

Conversation

@Anubhav-2003
Copy link
Copy Markdown

The issued_at column is defined as a timezone-naive DateTime, but
its default value (datetime.now(timezone.utc)) was returning a
timezone-aware object.

While some database drivers silently fix this mismatch for us behind
the scenes, stricter ones will immediately crash with a TypeError
during inserts.

This commit fixes the root problem by explicitly removing the timezone
info (.replace(tzinfo=None)) before the value hits the database.
This ensures the data perfectly matches the expected column schema,
preventing crashes across different environments. A regression test
has also been added.

@coveralls
Copy link
Copy Markdown

coveralls commented Apr 26, 2026

Coverage Report for CI Build 25058656330

Warning

No base build found for commit 1956003 on main.
Coverage changes can't be calculated without a base build.
If a base build is processing, this comment will update automatically when it completes.

Coverage: 95.115%

Details

  • Patch coverage: 8 of 8 lines across 3 files are fully covered (100%).

Uncovered Changes

No uncovered changes found.

Coverage Regressions

Requires a base build to compare against. How to fix this →


Coverage Stats

Coverage Status
Relevant Lines: 5384
Covered Lines: 5121
Line Coverage: 95.12%
Coverage Strength: 9.44 hits per line

💛 - Coveralls

Copy link
Copy Markdown
Contributor

@winwinashwin winwinashwin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a bunch of test cases where we are passing datetime.now(...) as defaults when creating models for unit tests. Let's also refactor those to make them offset naive?

Also, another minor note - the autolink reference to the issue in the commit message is not getting resolved correctly. Can you fix that? Most likely it's just changing fix(issue#152) -> fix(#152)

@winwinashwin winwinashwin changed the title fix(issue#152): match issued_at default to naive column schema fix(#152): match issued_at default to naive column schema Apr 28, 2026
@Anubhav-2003
Copy link
Copy Markdown
Author

There are a bunch of test cases where we are passing datetime.now(...) as defaults when creating models for unit tests. Let's also refactor those to make them offset naive?

Also, another minor note - the autolink reference to the issue in the commit message is not getting resolved correctly. Can you fix that? Most likely it's just changing fix(issue#152) -> fix(#152)

Sure Ashwin, let me refactor those tests to make them naive as well. Also thank you, for fixing the PR title issue.

Regards,
Anubhav

Comment thread tests/test_transaction.py Outdated
The issued_at column is defined as a timezone-naive DateTime, but
its default value (datetime.now(timezone.utc)) was returning a
timezone-aware object.

While some database drivers silently fix this mismatch for us behind
the scenes, stricter ones will immediately crash with a TypeError
during inserts.

This commit fixes the root problem by explicitly removing the timezone
info (.replace(tzinfo=None)) before the value hits the database.
This ensures the data perfectly matches the expected column schema,
preventing crashes across different environments. A regression test
has also been added.
@winwinashwin winwinashwin merged commit 2ac0271 into corridor:main Apr 28, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants