Skip to content

add postgres faithful/raw model for intervals#26

Open
eratio08 wants to merge 1 commit intotsloughter:mainfrom
eratio08:feat/interval-raw-decode
Open

add postgres faithful/raw model for intervals#26
eratio08 wants to merge 1 commit intotsloughter:mainfrom
eratio08:feat/interval-raw-decode

Conversation

@eratio08
Copy link
Copy Markdown

@eratio08 eratio08 commented Mar 4, 2026

Adds a new model for intervals which is faithful to the postgres output format.
This would ideally be usable in as an alternative format such that lpil/pog#67 (comment) can access it. This new type is opt-in and should not break the existing type or dependencies

Add interval_config option following the established pg_types config
pattern (like timestamp_config, uuid_format). When set to raw, decode
returns {interval, Microseconds, Days, Months} matching the PostgreSQL
wire format directly. Also accept the raw tuple format for encoding.
@tsloughter
Copy link
Copy Markdown
Owner

Oh, are we losing precision by doing this time conversion instead of just returning milliseconds?

@eratio08
Copy link
Copy Markdown
Author

Oh, are we losing precision by doing this time conversion instead of just returning milliseconds?

You mean the current implementation which uses pg_time:decode_time? The pg format actually returns Microseconds and not only milliseconds

@tsloughter
Copy link
Copy Markdown
Owner

@eratio08 right, the current implementation.

@eratio08
Copy link
Copy Markdown
Author

@eratio08 right, the current implementation.

I do no thinks so, the pg_time:decode_time does treat the microseconds properly like wall-clock time an there should be no problems as long as non-negative intervals are used or intervals which have a time part <= 24h, at least this is my understanding of it.

@eratio08 eratio08 marked this pull request as ready for review March 28, 2026 16:32
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.

2 participants