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: decode postgres time without subsecond #2784

Conversation

granddaifuku
Copy link
Contributor

This resolves #2707

The cause of the issue

The issue is caused by Postgres.

Specifically, when we select 0:0:0.123 from Postgres, it properly returns 00:00:00.123.
However, in the case of selecting 0:0:0.0, it returns 00:00:00, removing after the .0.

This leads to the error Decode(ParseFromDescription(InvalidLiteral), because it does not match the Time format.

test=# select '0:0:0.0'::time;
   time
----------
 00:00:00
(1 row)

test=# select '0:0:0.123'::time;
     time
--------------
 00:00:00.123
(1 row)

To solve this, I implemented the same logic as datetime.

sqlx-postgres/src/types/time/time.rs Outdated Show resolved Hide resolved
@abonander abonander merged commit 846dcfe into launchbadge:main Oct 4, 2023
64 checks passed
mattfbacon pushed a commit to mattfbacon/sqlx that referenced this pull request Oct 6, 2023
* fix: decode postgres time without subsecond

* update: decode postgres time without subsecond by making subsecond optional
@granddaifuku granddaifuku deleted the fix/decode-postgres-time-without-subsecond branch December 16, 2023 10:22
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.

[BUG] Postgres: Decode Time ParseFromDescription(InvalidLiteral)
2 participants