Skip to content

Keep PostgreSQL BC dates queryable#271

Merged
Maxteabag merged 1 commit into
mainfrom
test/issue-263-postgres-bc-date
Jul 14, 2026
Merged

Keep PostgreSQL BC dates queryable#271
Maxteabag merged 1 commit into
mainfrom
test/issue-263-postgres-bc-date

Conversation

@Maxteabag

Copy link
Copy Markdown
Owner

Summary

  • preserve native psycopg2 temporal types for supported dates
  • return BC/out-of-range dates and timestamps as text, including arrays
  • add live PostgreSQL regression coverage

Verification

  • 1,046 unit tests passed
  • 36 PostgreSQL tests passed
  • targeted Ruff passed

Fixes #263

PostgreSQL can return temporal values outside Python's representable year range. Register connection-local psycopg2 casters that preserve normal date and datetime objects while falling back to raw text for unsupported values and arrays.

Constraint: Python datetime cannot represent BC years

Rejected: Rewrite user queries with explicit text casts | unsafe for arbitrary SQL and changes query semantics

Confidence: high

Scope-risk: narrow

Directive: Preserve psycopg2 native temporal objects whenever Python can represent the value

Tested: 8 live PostgreSQL regressions; 28 existing PostgreSQL integrations; 1039 unit tests; targeted Ruff

Not-tested: CockroachDB-specific temporal decoding

Related: #263
@Maxteabag
Maxteabag merged commit 74dea20 into main Jul 14, 2026
21 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.

Postgres. Table column named 'year' is not recognized or mapped correctly

1 participant