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

SQLite3: PrimitiveDateTime cannot be used in macros #3624

Open
moubctez opened this issue Dec 3, 2024 · 0 comments
Open

SQLite3: PrimitiveDateTime cannot be used in macros #3624

moubctez opened this issue Dec 3, 2024 · 0 comments
Labels

Comments

@moubctez
Copy link

moubctez commented Dec 3, 2024

Bug Description

When a field is defined PrimitiveDateTime it cannot be fetched from SQLite3 database using a macro.
Compiler emits: the trait From<OffsetDateTime> is not implemented for PrimitiveDateTime, which is required by OffsetDateTime: Into<_>

The query_as! macro gets expanded to something contaning:

#[allow(non_snake_case)]
let sqlx_query_as_last_check = row.try_get_unchecked:: <sqlx::types::time::OffsetDateTime,_>(5usize)? .into();           

Minimal Reproduction

struct Package {
    id: i64
    last_check: PrimitiveDateTime,
}

impl Package {
    async fn get(pool: &SqlitePool, id: i64) -> Result<Self, SqlxError> {
        query_as!(
            Self,
            "SELECT last_check FROM package WHERE id = $1",
            id
        )
        .fetch_one(pool)
        .await
    }
}

Info

  • SQLx version: v0.8.2
  • SQLx features enabled: "runtime-tokio-native-tls", "sqlite", "time"
  • Database server and version: SQLite 3.47.1
  • Operating system: macOS (Darwin Kernel Version 24.2.0)
  • rustc --version: rustc 1.83.0 (90b35a623 2024-11-26) (built from a source tarball)
@moubctez moubctez added the bug label Dec 3, 2024
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