Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix interval encoding to allow 0s and avoid extra spaces #2035

Merged
merged 1 commit into from
May 31, 2024

Conversation

exekias
Copy link
Contributor

@exekias exekias commented May 30, 2024

Fix a bugs introduced by 01d649b, also add some tests

closes #2034

Fix a bugs introduced by 01d649b, also add some tests
@@ -132,29 +132,25 @@ func (encodePlanIntervalCodecText) Encode(value any, buf []byte) (newBuf []byte,

if interval.Days != 0 {
buf = append(buf, strconv.FormatInt(int64(interval.Days), 10)...)
buf = append(buf, " day"...)
buf = append(buf, " day "...)

Choose a reason for hiding this comment

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

If months is 0, this will produce " day hh:mm:ss"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nope, the number goes just before. There is a test with 0 months that looks good: https://github.com/jackc/pgx/pull/2035/files#diff-deeaa7f4bfb6897c6bb770fb12921f2350ce60ca3a2a5416c84a1ec23bb2b11eR151

Choose a reason for hiding this comment

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

Ah, my mistake!

@jackc jackc merged commit ec557e8 into jackc:master May 31, 2024
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.

Interval of 0s is invalid
3 participants