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

With sqlite and chrono, NaiveTime failed to parse from time type #3576

Open
rust-kotlin opened this issue Oct 24, 2024 · 0 comments
Open

With sqlite and chrono, NaiveTime failed to parse from time type #3576

rust-kotlin opened this issue Oct 24, 2024 · 0 comments
Labels

Comments

@rust-kotlin
Copy link

rust-kotlin commented Oct 24, 2024

Bug Description

When I name the type of a field in sqlite as date, and tried to use sqlx::query_as! to parse that field to a struct with chrono::NaiveDate type, I went ok with no problems.
image

It went wrong when defining the type of a field as time, and tried to parse that to chrono::NaiveTime, the error is that unsupported type TIME of column #2 ("start_time").
image

Minimal Reproduction

            #[derive(Debug)]
            pub struct Time {
                pub time_id: i64,
                pub start_time: NaiveTime,
                pub end_time: NaiveTime,
                pub persons: i64,
            }

            let times: Vec<Time> = sqlx::query_as!(Time, r#"
            SELECT 
                time_id, 
                start_time, 
                end_time, 
                persons 
            FROM times
            "#)
            .fetch_all(&self.pool)
            .await?;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant