Skip to content

Print + before a positive interval count that follows a negative one - #172

Merged
LucaCappelletti94 merged 1 commit into
mainfrom
upstream/interval-mixed-sign
Oct 29, 2026
Merged

LucaCappelletti94 merged 1 commit into
mainfrom
upstream/interval-mixed-sign

Conversation

@LucaCappelletti94

Copy link
Copy Markdown
Collaborator

PostgreSQL prints interval '-1 day 2 hours' as -1 days +02:00:00. Under the default IntervalStyle it marks a positive count or clock with + when the count printed just before it was negative. pg2sqlite joined the counts with a plain space and stored -1 days 02:00:00, so the same mixed-sign interval written as a literal and synced from the server became two different strings in the replica, and an equality filter or DISTINCT saw two values.

to_postgres_text now follows AddPostgresIntPart in PostgreSQL's datetime.c, where the sign of each non-zero count decides the + of the next count only, so -1 year 1 day 2 hours prints -1 years +1 day 02:00:00. The new test pins literals checked against PostgreSQL 18. Reading the stored text back already accepted the +.

CI needs connetto-rs/sql-traits#172 first, because sqlparser main currently breaks sql-traits main.

@LucaCappelletti94 LucaCappelletti94 added the bug Something isn't working label Oct 28, 2026
@LucaCappelletti94
LucaCappelletti94 force-pushed the upstream/interval-mixed-sign branch from 6fd777f to 69c6460 Compare October 28, 2026 22:23
@codecov

codecov Bot commented Oct 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@LucaCappelletti94
LucaCappelletti94 merged commit cfdf983 into main Oct 29, 2026
21 checks passed
@LucaCappelletti94
LucaCappelletti94 deleted the upstream/interval-mixed-sign branch November 1, 2026 09:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant